Files
intrastat-extrastat/intrastat_base/models/product_template.py
Alexis de Lattre b03b74ad7b [MIG] intrastat_base from v13 to v14
Up-port PR #98
2020-10-14 22:22:07 +02:00

31 lines
1.1 KiB
Python

# Copyright 2010-2020 Akretion (<alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class ProductTemplate(models.Model):
_inherit = "product.template"
is_accessory_cost = fields.Boolean(
string="Is accessory cost",
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.",
)
@api.constrains("type", "is_accessory_cost")
def _check_accessory_cost(self):
for this in self:
if this.is_accessory_cost and this.type != "service":
raise ValidationError(
_(
"The option 'Is accessory cost?' should only be "
"activated on 'Service' products. You have activated "
"this option for the product '%s' which is of type "
"'%s'"
)
% (this.display_name, this.type)
)