diff --git a/models/product_template.py b/models/product_template.py index 20c154c892caec2b6ef494fb5b091a53b96e24f0..1a24ffc09a84a9e163fa8e2b049921cfbaade542 100644 --- a/models/product_template.py +++ b/models/product_template.py @@ -18,7 +18,10 @@ class ProductTemplate(models.Model): # ------------------------------------------------------ # Fields declaration # ------------------------------------------------------ - nb_accesories = fields.Float(string="Nombre d'accessoires") + nb_accesories = fields.Float("Nombre d'accéssoires") + accessory_label = fields.Char( + related="categ_id.accessory_label", readonly=True + ) # ------------------------------------------------------ # SQL Constraints @@ -43,8 +46,7 @@ class ProductTemplate(models.Model): # ------------------------------------------------------ # Actions # ------------------------------------------------------ - def get_accessory_label(self): - return self.env["product.category"].browse(self.gateg_id).accessory_label + # ------------------------------------------------------ # Business methods # ------------------------------------------------------ diff --git a/views/product_template_views.xml b/views/product_template_views.xml index 61d95ce7321b112755af44227ac629ac2558f35e..f5247f547362c81fb9ef8396c9162d07c4f26d11 100644 --- a/views/product_template_views.xml +++ b/views/product_template_views.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8" ?> <odoo> <data> - <record id="product_category_form_view" model="ir.ui.view"> <field name="name">product.category.form.inherit</field> <field name="model">product.category</field> @@ -20,7 +19,8 @@ <field name="inherit_id" ref="product.product_template_form_view"/> <field name="arch" type="xml"> <field name="categ_id" position="after"> - <field name="nb_accesories"> Nombre d accessoire </field> + <field name="accessory_label" string="Accessoire de catégorie associé"/> + <field name="nb_accesories"/> </field> </field> </record>