Browse Source

fixup: Improve code readability (PEP8) and prevent users from creating new hazard labels on the fly from an article form.

20181114_155
Cyrille Bollu 4 years ago
parent
commit
6df0bf659c
  1. 24
      beesdoo_product/models/beesdoo_product.py
  2. 4
      beesdoo_product/views/beesdoo_product.xml

24
beesdoo_product/models/beesdoo_product.py

@ -15,23 +15,35 @@ class BeesdooProduct(models.Model):
_inherit = "product.template"
eco_label = fields.Many2one(
"beesdoo.product.label", domain=[("type", "=", "eco")]
"beesdoo.product.label",
domain=[("type", "=", "eco")]
)
local_label = fields.Many2one(
"beesdoo.product.label", domain=[("type", "=", "local")]
"beesdoo.product.label",
domain=[("type", "=", "local")]
)
fair_label = fields.Many2one(
"beesdoo.product.label", domain=[("type", "=", "fair")]
"beesdoo.product.label",
domain=[("type", "=", "fair")]
)
origin_label = fields.Many2one(
"beesdoo.product.label", domain=[("type", "=", "delivery")]
"beesdoo.product.label",
domain=[("type", "=", "delivery")]
)
fds_label = fields.Many2one(
"beesdoo.product.hazard", string="FDS label", domain=[("type", "=", "fds")], translate=True, default=lambda self: self.env['beesdoo.product.hazard'].search([["type", "=", "fds"],["name", "=", "Not required"]])
"beesdoo.product.hazard",
string="FDS label",
domain=[("type", "=", "fds")],
translate=True,
default=lambda self: self.env['beesdoo.product.hazard'].search([["type", "=", "fds"],["name", "=", "Not required"]])
)
hazard_label = fields.Many2one(
"beesdoo.product.hazard", string="Hazard label", domain=[("type", "=", "hazard")], translate=True, default=lambda self: self.env['beesdoo.product.hazard'].search([["type", "=", "hazard"],["name", "=", "No"]])
"beesdoo.product.hazard",
string="Hazard label",
domain=[("type", "=", "hazard")],
translate=True,
default=lambda self: self.env['beesdoo.product.hazard'].search([["type", "=", "hazard"],["name", "=", "No"]])
)
main_seller_id = fields.Many2one(

4
beesdoo_product/views/beesdoo_product.xml

@ -46,8 +46,8 @@
</group>
</group>
<group>
<field name="fds_label"/>
<field name="hazard_label"/>
<field name="fds_label" widget="selection"/>
<field name="hazard_label" widget="selection"/>
</group>
<group>
<field name="note"/>

Loading…
Cancel
Save