From d4f8b89f43bd151b31f689397b640cfb8a43a395 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Sat, 23 Oct 2021 18:46:52 +0200 Subject: [PATCH] [14.0][IMP] intrastat_*: Improve tests and code --- .../models/intrastat_product_declaration.py | 82 ------------------- 1 file changed, 82 deletions(-) diff --git a/intrastat_product/models/intrastat_product_declaration.py b/intrastat_product/models/intrastat_product_declaration.py index a13a5c8..d7e3c42 100644 --- a/intrastat_product/models/intrastat_product_declaration.py +++ b/intrastat_product/models/intrastat_product_declaration.py @@ -41,50 +41,6 @@ class IntrastatProductDeclaration(models.Model): ) return res - company_id = fields.Many2one( - comodel_name="res.company", - string="Company", - required=True, - states={"done": [("readonly", True)]}, - default=lambda self: self._default_company_id(), - ) - company_country_code = fields.Char( - compute="_compute_company_country_code", - string="Company Country Code", - readonly=True, - store=True, - help="Used in views and methods of localization modules.", - ) - year = fields.Char( - string="Year", required=True, states={"done": [("readonly", True)]} - ) - month = fields.Selection( - selection=[ - ("01", "01"), - ("02", "02"), - ("03", "03"), - ("04", "04"), - ("05", "05"), - ("06", "06"), - ("07", "07"), - ("08", "08"), - ("09", "09"), - ("10", "10"), - ("11", "11"), - ("12", "12"), - ], - string="Month", - required=True, - states={"done": [("readonly", True)]}, - ) - year_month = fields.Char( - compute="_compute_year_month", - string="Period", - readonly=True, - tracking=True, - store=True, - help="Year and month of the declaration.", - ) declaration_type = fields.Selection( selection="_get_declaration_type", string="Type", @@ -133,19 +89,6 @@ class IntrastatProductDeclaration(models.Model): currency_id = fields.Many2one( "res.currency", related="company_id.currency_id", string="Currency" ) - state = fields.Selection( - selection=[("draft", "Draft"), ("done", "Done")], - string="State", - readonly=True, - tracking=True, - copy=False, - default="draft", - help="State of the declaration. When the state is set to 'Done', " - "the parameters become read-only.", - ) - note = fields.Text( - string="Notes", help="You can add some comments here if you want." - ) reporting_level = fields.Selection( selection="_get_reporting_level", string="Reporting Level", @@ -160,10 +103,6 @@ class IntrastatProductDeclaration(models.Model): related="xml_attachment_id.name", string="XML Filename" ) - @api.model - def _default_company_id(self): - return self.env.company - @api.model def _get_declaration_type(self): res = [] @@ -188,33 +127,12 @@ class IntrastatProductDeclaration(models.Model): ("nihil", _("Nihil")), ] - @api.depends("company_id") - def _compute_company_country_code(self): - for this in self: - if this.company_id: - if not this.company_id.country_id: - raise ValidationError(_("You must set company's country !")) - this.company_country_code = this.company_id.country_id.code.lower() - - @api.depends("year", "month") - def _compute_year_month(self): - for this in self: - if this.year and this.month: - this.year_month = "-".join([this.year, this.month]) - @api.depends("month") def _compute_check_validity(self): """ TO DO: logic based upon computation lines """ for this in self: this.valid = True - @api.model - @api.constrains("year") - def _check_year(self): - for this in self: - if len(this.year) != 4 or this.year[0] != "2": - raise ValidationError(_("Invalid Year !")) - @api.onchange("declaration_type") def _onchange_declaration_type(self): if self.declaration_type == "arrivals":