From a33c53945e51f11f2d0f563451ebd98612c73a58 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 6 Feb 2025 19:26:33 +0100 Subject: [PATCH] [IMP] intrastat_base: is_accessory_cost is now a computed field --- checklog-odoo.cfg | 4 ---- intrastat_base/models/product_template.py | 11 +++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/checklog-odoo.cfg b/checklog-odoo.cfg index af88836..0b55b7b 100644 --- a/checklog-odoo.cfg +++ b/checklog-odoo.cfg @@ -1,7 +1,3 @@ [checklog-odoo] ignore= -<<<<<<< before updating - WARNING.* 0 failed, 0 error\(s\).* -======= WARNING.* 0 failed, 0 error\(s\).* ->>>>>>> after updating diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index 3229f99..a097919 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -16,9 +16,14 @@ class ProductTemplate(models.Model): ], compute="_compute_intrastat_type", store=True, + precompute=True, help="Type of product used for the intrastat declarations.", ) is_accessory_cost = fields.Boolean( + compute="_compute_is_accessory_cost", + store=True, + precompute=True, + readonly=False, help="Activate this option for shipping costs, packaging " "costs and all services related to the sale of products. " "This option is used for Intrastat reports.", @@ -38,6 +43,12 @@ class ProductTemplate(models.Model): break this.intrastat_type = intrastat_type + @api.depends("intrastat_type") + def _compute_is_accessory_cost(self): + for this in self: + if this.intrastat_type != "service": + this.is_accessory_cost = False + @api.constrains("intrastat_type", "is_accessory_cost") def _check_accessory_cost(self): for this in self: