Browse Source

Merge pull request #114 from beescoop/12.0-mig-beesdoo-purchase

[MIG] beesdoo_purchase: migrate to 12.0
pull/148/head
Rémy Taymans 4 years ago
committed by GitHub
parent
commit
0209939cd2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      beesdoo_purchase/__init__.py
  2. 25
      beesdoo_purchase/__manifest__.py
  3. 22
      beesdoo_purchase/i18n/fr_BE.po
  4. 1
      beesdoo_purchase/models/__init__.py
  5. 41
      beesdoo_purchase/models/purchase.py
  6. 16
      beesdoo_purchase/report/report_purchaseorder.xml
  7. 39
      beesdoo_purchase/views/purchase_order.xml

1
beesdoo_purchase/__init__.py

@ -0,0 +1 @@
from . import models

25
beesdoo_purchase/__manifest__.py

@ -0,0 +1,25 @@
{
"name": "Bees Purchase",
"summary": """
Extends Purchase module.
""",
"description": """
Extends Purchase module:
- Adds a 'Responsible' field to purchase orders:
This is a user who will follow up the order. This users replaces
the creator in the order's mail messages followers list, and in the
create_uid ORM field. His user's contact info is printed on
purchases orders as 'Referent'.
- A filter w.r.t. the mail sellers is placed on the products field of a
purchase order.
""",
"author": "Beescoop - Cellule IT, " "Coop IT Easy SCRLfs",
"website": "https://github.com/beescoop/Obeesdoo",
"category": "Purchase",
"version": "12.0.1.1.0",
"depends": ["base", "purchase", "beesdoo_product"],
"data": [
"views/purchase_order.xml",
"report/report_purchaseorder.xml",
],
}

22
beesdoo_purchase/i18n/fr_BE.po

@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * beesdoo_purchase
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-11-13 15:25+0000\n"
"PO-Revision-Date: 2016-11-13 15:25+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: beesdoo_purchase
#: model:ir.model,name:beesdoo_purchase.model_purchase_order
msgid "Purchase Order"
msgstr "Commande fournisseur"

1
beesdoo_purchase/models/__init__.py

@ -0,0 +1 @@
from . import purchase

41
beesdoo_purchase/models/purchase.py

@ -0,0 +1,41 @@
from odoo import api, fields, models
class PurchaseOrder(models.Model):
_inherit = "purchase.order"
# create_uid must mirror the supervisor_id value.
# create_uid is a magic field that belongs to the ORM that is not
# editable via a form.
create_uid = fields.Many2one(
comodel_name="res.users", compute="_compute_create_uid"
)
supervisor_id = fields.Many2one(
comodel_name="res.users",
string="Responsible",
required=True,
default=lambda self: self.env.user,
)
@api.depends("supervisor_id")
def _compute_create_uid(self):
for rec in self:
if rec.supervisor_id:
rec.create_uid = rec.supervisor_id
@api.multi
def write(self, vals):
if "supervisor_id" in vals:
new_partner = (
self.env["res.users"]
.browse(vals["supervisor_id"])
.partner_id.id
)
for rec in self:
rec.message_unsubscribe(
partner_ids=rec.supervisor_id.partner_id.ids
)
rec.message_subscribe(
partner_ids=[new_partner], subtype_ids=[]
)
return super(PurchaseOrder, self).write(vals)

16
beesdoo_purchase/report/report_purchaseorder.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="report_purchaseorder_document" inherit_id="purchase.report_purchaseorder_document" name="beesdoo purchaseorder">
<div t-if="o.date_order" position="after">
<div t-if="o.create_uid.name" class="col-xs-3">
<strong>Your Referent:</strong>
<div t-field="o.create_uid"
t-options='{"widget": "contact", "fields": ["name", "phone", "mobile"], "no_marker": true, "phone_icons": true}'/>
</div>
</div>
</template>
</data>
</odoo>

39
beesdoo_purchase/views/purchase_order.xml

@ -0,0 +1,39 @@
<odoo>
<data>
<record model="ir.ui.view" id="beesdoo_purchase_order_form_view">
<field name="name">beesdoo.purchase.order.form.view</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<field name="date_order" position="after">
<field name="supervisor_id"/>
</field>
<field name="product_id" position="attributes">
<attribute name="domain">[('main_seller_id','=', parent.partner_id), ('purchase_ok', '=', True)]</attribute>
</field>
</field>
</record>
<record model="ir.ui.view" id="beesdoo_purchase_order_tree_view">
<field name="name">beesdoo.purchase.order.tree.view</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_tree" />
<field name="arch" type="xml">
<field name="origin" position="after">
<field name="supervisor_id"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="beesdoo_purchase_order_search_view">
<field name="name">beesdoo.purchase.order.search.view</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.view_purchase_order_filter"/>
<field name="arch" type="xml">
<field name="create_uid" position="after">
<field name="supervisor_id"/>
</field>
</field>
</record>
</data>
</odoo>
Loading…
Cancel
Save