From 36fdd24bf978448da4908876848deec592b040f4 Mon Sep 17 00:00:00 2001 From: Julien Ortet <julien@le-filament.com> Date: Wed, 31 Jul 2024 08:56:06 +0200 Subject: [PATCH] [ADD] ajout multiplicateur de paillage --- models/product_category.py | 4 ++++ models/product_template.py | 7 ++++++- models/sale_intervention.py | 2 ++ views/product_template_views.xml | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/models/product_category.py b/models/product_category.py index c2330f9..28593e3 100644 --- a/models/product_category.py +++ b/models/product_category.py @@ -12,6 +12,10 @@ class ProductCategory(models.Model): # ------------------------------------------------------ symbol = fields.Char("Symbole") accessory_label = fields.Char("Nom de l'accessoire associƩ") + mulch_quantity_multiplier = fields.Integer( + "Multiplicateur paillage", + default=1 + ) # ------------------------------------------------------ # SQL Constraints diff --git a/models/product_template.py b/models/product_template.py index fa2e3cf..d991d84 100644 --- a/models/product_template.py +++ b/models/product_template.py @@ -10,7 +10,12 @@ class ProductTemplate(models.Model): # Fields declaration # ------------------------------------------------------ nb_accesories = fields.Float("Nombre d'accessoires") - accessory_label = fields.Char(related="categ_id.accessory_label", readonly=True) + accessory_label = fields.Char( + related="categ_id.accessory_label", readonly=True + ) + mulch_quantity_multiplier = fields.Integer( + related="categ_id.mulch_quantity_multiplier", readonly=True + ) # ------------------------------------------------------ # SQL Constraints diff --git a/models/sale_intervention.py b/models/sale_intervention.py index f5d1946..363d97f 100644 --- a/models/sale_intervention.py +++ b/models/sale_intervention.py @@ -555,6 +555,7 @@ class SaleIntervention(models.Model): self.mulch_qty = self.plant_qty else: self.mulch_qty = 0.0 + self.mulch_qty *= self.mulch_id.mulch_quantity_multiplier @api.onchange("plant_qty", "intervention_length", "mulch2_id") def _onchange_mulch2_id(self): @@ -565,6 +566,7 @@ class SaleIntervention(models.Model): self.mulch2_qty = self.plant_qty else: self.mulch2_qty = 0.0 + self.mulch2_qty *= self.mulch2_id.mulch_quantity_multiplier @api.onchange("high_protection_qty") def _onchange_high_protection_qty(self): diff --git a/views/product_template_views.xml b/views/product_template_views.xml index f04b429..104603e 100644 --- a/views/product_template_views.xml +++ b/views/product_template_views.xml @@ -9,6 +9,13 @@ <field name="parent_id" position="after"> <field name="symbol" /> <field name="accessory_label" /> + <field name="name" /> + + <t t-if="record.name == 'Paillage'"> + <div> + <field name="mulch_quantity_multiplier" /> + </div> + </t> </field> </field> </record> -- GitLab