[MIG] intrastat_product: Migration to 13.0

This commit is contained in:
Luc De Meyer
2020-02-26 22:16:50 +01:00
parent ba3cf5199b
commit 3da824f9c4
18 changed files with 941 additions and 817 deletions

View File

@@ -3,7 +3,7 @@
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
from odoo import api, fields, models, _
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
@@ -11,20 +11,26 @@ class HSCode(models.Model):
_inherit = "hs.code"
intrastat_unit_id = fields.Many2one(
comodel_name='intrastat.unit',
string='Intrastat Supplementary Unit')
comodel_name="intrastat.unit", string="Intrastat Supplementary Unit"
)
@api.constrains('local_code')
@api.constrains("local_code")
def _hs_code(self):
if self.company_id.country_id.intrastat:
if not self.local_code.isdigit():
raise ValidationError(_(
"Intrastat Codes should only contain digits. "
"This is not the case for code '%s'.")
% self.local_code)
raise ValidationError(
_(
"Intrastat Codes should only contain digits. "
"This is not the case for code '%s'."
)
% self.local_code
)
if len(self.local_code) != 8:
raise ValidationError(_(
"Intrastat Codes should "
"contain 8 digits. This is not the case for "
"Intrastat Code '%s' which has %d digits.")
% (self.local_code, len(self.local_code)))
raise ValidationError(
_(
"Intrastat Codes should "
"contain 8 digits. This is not the case for "
"Intrastat Code '%s' which has %d digits."
)
% (self.local_code, len(self.local_code))
)