[IMP] intrastat_base: is_accessory_cost is now a computed field

This commit is contained in:
Alexis de Lattre
2025-02-06 19:26:33 +01:00
parent de1d1c147b
commit a33c53945e
2 changed files with 11 additions and 4 deletions

View File

@@ -1,7 +1,3 @@
[checklog-odoo]
ignore=
<<<<<<< before updating
WARNING.* 0 failed, 0 error\(s\).*
=======
WARNING.* 0 failed, 0 error\(s\).*
>>>>>>> after updating

View File

@@ -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: