Browse Source

[REF] beesdoo_purchase: remove message_subscribe_users, rename t-field-options, extend description, remove unnecessary files, blacken

pull/114/head
Manuel Claeys Bouuaert 5 years ago
parent
commit
368c3ac0d0
  1. 42
      beesdoo_purchase/__manifest__.py
  2. 2
      beesdoo_purchase/models/__init__.py
  3. 27
      beesdoo_purchase/models/purchase.py
  4. 9
      beesdoo_purchase/models/purchase_order.py
  5. 2
      beesdoo_purchase/report/report_purchaseorder.xml
  6. 1
      beesdoo_purchase/security/ir.model.access.csv

42
beesdoo_purchase/__manifest__.py

@ -1,25 +1,25 @@
{ {
'name': "Bees Purchase",
'summary': """
Extension du module Purchase""",
'description': """
Long description of module's purpose
"name": "Bees Purchase",
"summary": """
Extends Purchase module.
""", """,
'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',
'security/ir.model.access.csv',
'report/report_purchaseorder.xml',
"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",
], ],
} }

2
beesdoo_purchase/models/__init__.py

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

27
beesdoo_purchase/models/purchase.py

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

9
beesdoo_purchase/models/purchase_order.py

@ -1,9 +0,0 @@
from odoo import models, fields, api
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'

2
beesdoo_purchase/report/report_purchaseorder.xml

@ -7,7 +7,7 @@
<div t-if="o.create_uid.name" class="col-xs-3"> <div t-if="o.create_uid.name" class="col-xs-3">
<strong>Your Referent:</strong> <strong>Your Referent:</strong>
<div t-field="o.create_uid" <div t-field="o.create_uid"
t-field-options='{"widget": "contact", "fields": ["name", "phone", "mobile"], "no_marker": true, "phone_icons": true}'/>
t-options='{"widget": "contact", "fields": ["name", "phone", "mobile"], "no_marker": true, "phone_icons": true}'/>
</div> </div>
</div> </div>

1
beesdoo_purchase/security/ir.model.access.csv

@ -1 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
Loading…
Cancel
Save