diff --git a/data/product_category.xml b/data/product_category.xml index f0a8f08a4381c310ebff03b4ec44c2cbb1aab5e0..a3bd03fd661c572492fa24f573e20fa428c4591c 100644 --- a/data/product_category.xml +++ b/data/product_category.xml @@ -10,7 +10,8 @@ name="parent_id" ref="ap_sale_project.product_category_plantation_supply" /> - <field name="name">Paillage</field> + <field name="name">Paillage</field> + <field name="accessory_label">Agrafes</field> </record> <record id="product_category_stake" model="product.category"> <field @@ -25,6 +26,7 @@ ref="ap_sale_project.product_category_plantation_supply" /> <field name="name">Protections Hautes</field> + <field name="accessory_label">Piquets</field> </record> <record id="product_category_protection_low" model="product.category"> <field @@ -32,6 +34,7 @@ ref="ap_sale_project.product_category_plantation_supply" /> <field name="name">Protections Basses</field> + <field name="accessory_label">Bambous</field> </record> <record id="product_category_marker" model="product.category"> <field diff --git a/models/sale_intervention.py b/models/sale_intervention.py index ecafe2fc21b4f8539ca502bcaa23c396ea9a84f1..61b102e667cd3805ea9d0116590bfc609bc4651b 100644 --- a/models/sale_intervention.py +++ b/models/sale_intervention.py @@ -580,7 +580,12 @@ class SaleIntervention(models.Model): @api.onchange("low_protection_qty") def _onchange_low_protection_qty(self): - self.bamboo_qty = self.low_protection_qty * 2 + if self.low_protection_id.nb_accesories: + stake_multiplier = self.low_protection_id.nb_accesories + else: + stake_multiplier = 2 + + self.bamboo_qty = stake_multiplier * self.low_protection_qty @api.constrains("plant_interval") def _check_plant_interval(self): @@ -607,8 +612,9 @@ class SaleIntervention(models.Model): raise UserError( _( "La quantité de plants renseignée '%d' est différente de" - "la quantité de plants calculée '%d'.\n " - "Les quantités doivent être identiques, vérifier votre compositon." + " la quantité de plants calculée '%d'.\n " + "Les quantités doivent être identiques," + " vérifier votre compositon." ) % (rec.plant_qty, rec.plants_qty) ) @@ -676,6 +682,7 @@ class SaleIntervention(models.Model): ): # We retrieve pricelist from subvention where # intervention_type_id = our type of intervention + # ruff: noqa: B023 pricelist = rec.project_subvention_id.product_pricelist_ids.filtered( lambda i: i.intervention_type_id == forfait )[0] @@ -701,6 +708,7 @@ class SaleIntervention(models.Model): # of all interventions of the same type # Get all interventions of same type in the same project + # ruff: noqa: B023 interventions = self.project_id.intervention_ids.filtered( lambda r: r.intervention_type_id == rec.intervention_type_id )