From 501deeafc613365109d4d853fe5911a438720879 Mon Sep 17 00:00:00 2001 From: Borruso Date: Thu, 25 May 2023 09:33:54 +0200 Subject: [PATCH] [MIG] l10n_it_intrastat_statement: Migration to 16.0 --- l10n_it_intrastat_statement/README.rst | 14 ++++---- l10n_it_intrastat_statement/__manifest__.py | 2 +- .../13.0.1.0.0/noupdate_changes.xml | 8 ----- .../migrations/13.0.1.0.0/post-migration.py | 34 ------------------- .../models/intrastat_statement.py | 20 ++++++----- .../intrastat_statement_purchase_section1.py | 2 +- .../intrastat_statement_purchase_section2.py | 3 +- .../intrastat_statement_purchase_section3.py | 9 ++--- .../intrastat_statement_purchase_section4.py | 10 +++--- .../intrastat_statement_sale_section1.py | 3 +- .../intrastat_statement_sale_section2.py | 3 +- .../intrastat_statement_sale_section3.py | 7 ++-- .../intrastat_statement_sale_section4.py | 11 +++--- .../models/intrastat_statement_section.py | 9 +++-- .../static/description/index.html | 8 ++--- .../tests/test_intrastat_statement.py | 6 ++-- .../views/intrastat.xml | 4 +-- .../wizard/export_file.py | 7 ++-- 18 files changed, 61 insertions(+), 99 deletions(-) delete mode 100644 l10n_it_intrastat_statement/migrations/13.0.1.0.0/noupdate_changes.xml delete mode 100644 l10n_it_intrastat_statement/migrations/13.0.1.0.0/post-migration.py diff --git a/l10n_it_intrastat_statement/README.rst b/l10n_it_intrastat_statement/README.rst index c7e42f0eb9af..b8afd2a24195 100644 --- a/l10n_it_intrastat_statement/README.rst +++ b/l10n_it_intrastat_statement/README.rst @@ -14,14 +14,14 @@ ITA - Dichiarazione Intrastat :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github - :target: https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_intrastat_statement + :target: https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_intrastat_statement :alt: OCA/l10n-italy .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_intrastat_statement + :target: https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_intrastat_statement :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/122/14.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/l10n-italy&target_branch=16.0 + :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -100,7 +100,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -138,6 +138,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/l10n-italy `_ project on GitHub. +This module is part of the `OCA/l10n-italy `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_it_intrastat_statement/__manifest__.py b/l10n_it_intrastat_statement/__manifest__.py index 22bd4f8acd05..8e01511e67b3 100644 --- a/l10n_it_intrastat_statement/__manifest__.py +++ b/l10n_it_intrastat_statement/__manifest__.py @@ -3,7 +3,7 @@ { "name": "ITA - Dichiarazione Intrastat", - "version": "14.0.1.3.0", + "version": "16.0.1.0.0", "category": "Account", "summary": "Dichiarazione Intrastat per l'Agenzia delle Dogane", "author": "Openforce, Link IT srl, Agile Business Group, " diff --git a/l10n_it_intrastat_statement/migrations/13.0.1.0.0/noupdate_changes.xml b/l10n_it_intrastat_statement/migrations/13.0.1.0.0/noupdate_changes.xml deleted file mode 100644 index a9f07e0d3657..000000000000 --- a/l10n_it_intrastat_statement/migrations/13.0.1.0.0/noupdate_changes.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - ['|',('company_id','=',False),('company_id','in',company_ids)] - - diff --git a/l10n_it_intrastat_statement/migrations/13.0.1.0.0/post-migration.py b/l10n_it_intrastat_statement/migrations/13.0.1.0.0/post-migration.py deleted file mode 100644 index a77f64ca6e72..000000000000 --- a/l10n_it_intrastat_statement/migrations/13.0.1.0.0/post-migration.py +++ /dev/null @@ -1,34 +0,0 @@ -from openupgradelib import openupgrade -from psycopg2 import sql - - -def migrate(cr, installed_version): - openupgrade.load_data( - cr, "l10n_it_intrastat_statement", "migrations/13.0.1.0.0/noupdate_changes.xml" - ) - - to_be_updated = ( - ("account_intrastat_statement_sale_section1", "invoice_id"), - ("account_intrastat_statement_sale_section2", "invoice_id"), - ("account_intrastat_statement_sale_section3", "invoice_id"), - ("account_intrastat_statement_sale_section4", "invoice_id"), - ("account_intrastat_statement_purchase_section1", "invoice_id"), - ("account_intrastat_statement_purchase_section2", "invoice_id"), - ("account_intrastat_statement_purchase_section3", "invoice_id"), - ("account_intrastat_statement_purchase_section4", "invoice_id"), - ) - - if openupgrade.table_exists(cr, "account_invoice"): - for table, column in to_be_updated: - openupgrade.logged_query( - cr, - sql.SQL( - """UPDATE {table} t - SET {column} = ai.move_id - FROM account_invoice ai - WHERE t.{column} = ai.id and ai.move_id is NOT NULL""" - ).format( - table=sql.Identifier(table), - column=sql.Identifier(column), - ), - ) diff --git a/l10n_it_intrastat_statement/models/intrastat_statement.py b/l10n_it_intrastat_statement/models/intrastat_statement.py index 4e6cb7e39a9d..2736febd1ebb 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement.py @@ -100,7 +100,11 @@ def _compute_amount_section(self, section_type, section_number): ] ): raise UserError( - _("Wrong section type %s or number %s") % (section_type, section_number) + _( + "Wrong section type %(section_type)s or number %(section_number)s", + section_type=section_type, + section_number=section_number, + ) ) for statement in self: op_number = len(statement[section_ids_field]) @@ -197,7 +201,6 @@ def _get_sequence(self): ("M", "Month"), ("T", "Quarter"), ], - string="Period Type", default="M", required=True, ) @@ -222,7 +225,6 @@ def _get_sequence(self): "Change Period in quarter: only first and second month " "operations", ), ], - string="Content Type", required=True, default="0", ) @@ -233,7 +235,6 @@ def _get_sequence(self): ("9", "First Statement in Ceasing Activity or Changing VAT Number"), ("0", "None of the above cases"), ], - string="Special Cases", required=True, default="0", ) @@ -410,11 +411,12 @@ def _get_sequence(self): compute="_compute_amount_purchase_s4", ) - @api.model - def create(self, vals): - statement = super().create(vals) - statement._normalize_statement() - return statement + @api.model_create_multi + def create(self, vals_list): + statements = super().create(vals_list) + for statement in statements: + statement._normalize_statement() + return statements def write(self, vals): res = super().write(vals) diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section1.py b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section1.py index c80f281cf49e..907dd5d37b1e 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section1.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section1.py @@ -22,7 +22,7 @@ class IntrastatStatementPurchaseSection1(models.Model): default=lambda m: m._default_transaction_nature_b_id(), ) weight_kg = fields.Integer(string="Net Mass (kg)") - additional_units = fields.Integer(string="Additional Units") + additional_units = fields.Integer() additional_units_required = fields.Boolean( string="Additional Unit Required", store=True, diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py index d85b9c9767d9..0276f7259c99 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section2.py @@ -75,7 +75,7 @@ def _prepare_statement_line(self, inv_intra_line, statement_id=None): return res def _export_line_checks(self, section_label, section_number): - super(IntrastatStatementPurchaseSection2, self)._export_line_checks( + res = super(IntrastatStatementPurchaseSection2, self)._export_line_checks( section_label, section_number ) if not self.year_id: @@ -102,6 +102,7 @@ def _export_line_checks(self, section_label, section_number): "on 'Purchases - Section 2' adjustment" ) ) + return res def _prepare_export_line(self): self._export_line_checks(_("Purchase"), self.get_section_number()) diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section3.py b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section3.py index 6dbd27f0e181..ac68583f3ac2 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section3.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section3.py @@ -11,14 +11,11 @@ class IntrastatStatementPurchaseSection3(models.Model): _name = "account.intrastat.statement.purchase.section3" _description = "Intrastat Statement - Purchases Section 3" - invoice_number = fields.Char(string="Invoice Number") - invoice_date = fields.Date(string="Invoice Date") - supply_method = fields.Selection( - selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method" - ) + invoice_number = fields.Char() + invoice_date = fields.Date() + supply_method = fields.Selection(selection=[("I", "Instant"), ("R", "Repeated")]) payment_method = fields.Selection( selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")], - string="Payment Method", ) country_payment_id = fields.Many2one( comodel_name="res.country", string="Payment Country" diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py index e4a5742d1015..96719e20b069 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section4.py @@ -24,14 +24,13 @@ class IntrastatStatementPurchaseSection4(models.Model): string="Progressive to Adjust ID", ) progressive_to_modify = fields.Integer(string="Progressive to Adjust") - invoice_number = fields.Char(string="Invoice Number") - invoice_date = fields.Date(string="Invoice Date") + invoice_number = fields.Char() + invoice_date = fields.Date() supply_method = fields.Selection( - selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method" + selection=[("I", "Instant"), ("R", "Repeated")], ) payment_method = fields.Selection( selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")], - string="Payment Method", ) country_payment_id = fields.Many2one( comodel_name="res.country", string="Payment Country" @@ -65,7 +64,7 @@ def _prepare_statement_line(self, inv_intra_line, statement_id=None): return res def _export_line_checks(self, section_label, section_number): - super(IntrastatStatementPurchaseSection4, self)._export_line_checks( + res = super(IntrastatStatementPurchaseSection4, self)._export_line_checks( section_label, section_number ) if not self.year_id: @@ -88,6 +87,7 @@ def _export_line_checks(self, section_label, section_number): raise ValidationError( _("Missing payment country on 'Purchases - Section 4'") ) + return res def _prepare_export_line(self): self._export_line_checks(_("Purchase"), 4) diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section1.py b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section1.py index 56dae4db1e89..f5cfb205a18f 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section1.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section1.py @@ -17,7 +17,7 @@ class IntrastatStatementSaleSection1(models.Model): default=lambda m: m._default_transaction_nature_id(), ) weight_kg = fields.Integer(string="Net Mass (kg)") - additional_units = fields.Integer(string="Additional Units") + additional_units = fields.Integer() additional_units_required = fields.Boolean( string="Additional Unit Required", store=True, @@ -49,7 +49,6 @@ class IntrastatStatementSaleSection1(models.Model): comodel_name="res.country", string="Origin Country" ) triangulation = fields.Boolean( - string="Triangulation", default=False, ) diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py index 798d2c84ab9b..0c9dcb866e30 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section2.py @@ -71,7 +71,7 @@ def _prepare_statement_line(self, inv_intra_line, statement_id=None): return res def _export_line_checks(self, section_label, section_number): - super(IntrastatStatementSaleSection2, self)._export_line_checks( + res = super(IntrastatStatementSaleSection2, self)._export_line_checks( section_label, section_number ) if not self.year_id: @@ -88,6 +88,7 @@ def _export_line_checks(self, section_label, section_number): raise ValidationError( _("Missing reference quarter on 'Sales - Section 2' adjustment") ) + return res @api.model def _prepare_export_line(self): diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section3.py b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section3.py index a6515abb5462..af97b11b1b59 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section3.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section3.py @@ -11,14 +11,13 @@ class IntrastatStatementSaleSection3(models.Model): _name = "account.intrastat.statement.sale.section3" _description = "Intrastat Statement - Sales Section 3" - invoice_number = fields.Char(string="Invoice Number") - invoice_date = fields.Date(string="Invoice Date") + invoice_number = fields.Char() + invoice_date = fields.Date() supply_method = fields.Selection( - selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method" + selection=[("I", "Instant"), ("R", "Repeated")], ) payment_method = fields.Selection( selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")], - string="Payment Method", ) country_payment_id = fields.Many2one( comodel_name="res.country", string="Payment Country" diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py index 9b03aaafd03a..faf09872deb2 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section4.py @@ -20,20 +20,18 @@ class IntrastatStatementSaleSection4(models.Model): year_id = fields.Integer(string="Ref. Year") protocol = fields.Integer(string="Protocol Number") progressive_to_modify = fields.Integer(string="Progressive to Adjust") - invoice_number = fields.Char(string="Invoice Number") - invoice_date = fields.Date(string="Invoice Date") + invoice_number = fields.Char() + invoice_date = fields.Date() supply_method = fields.Selection( - selection=[("I", "Instant"), ("R", "Repeated")], string="Supply Method" + selection=[("I", "Instant"), ("R", "Repeated")], ) payment_method = fields.Selection( selection=[("B", "Bank Transfer"), ("A", "Credit"), ("X", "Other")], - string="Payment Method", ) country_payment_id = fields.Many2one( comodel_name="res.country", string="Payment Country" ) cancellation = fields.Boolean( - string="Cancellation", help="The Adjustment is intended for cancellation", ) @@ -66,7 +64,7 @@ def _prepare_statement_line(self, inv_intra_line, statement_id=None): return res def _export_line_checks(self, section_label, section_number): - super(IntrastatStatementSaleSection4, self)._export_line_checks( + res = super(IntrastatStatementSaleSection4, self)._export_line_checks( section_label, section_number ) if not self.year_id: @@ -81,6 +79,7 @@ def _export_line_checks(self, section_label, section_number): ) if not self.country_payment_id and not self.cancellation: raise ValidationError(_("Missing payment country on 'Sales - Section 4'")) + return res @api.model def _prepare_export_line(self): diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_section.py b/l10n_it_intrastat_statement/models/intrastat_statement_section.py index 1b39c8663c6a..66fea39621a8 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_section.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_section.py @@ -66,8 +66,13 @@ def _export_line_checks(self, section_label, section_number): self.ensure_one() if not self.vat_code and section_number != 4: raise ValidationError( - _("Missing vat code for %s on '%s - Section %s'") - % (self.partner_id.display_name, section_label, section_number) + _( + "Missing vat code for %(display_name)s on " + "'%(section_label)s - Section %(section_number)s'", + display_name=self.partner_id.display_name, + section_label=section_label, + section_number=section_number, + ) ) country_id = self.country_partner_id or self.partner_id.country_id if country_id: diff --git a/l10n_it_intrastat_statement/static/description/index.html b/l10n_it_intrastat_statement/static/description/index.html index d627d8b551a9..6d2235ae079d 100644 --- a/l10n_it_intrastat_statement/static/description/index.html +++ b/l10n_it_intrastat_statement/static/description/index.html @@ -3,7 +3,7 @@ - + ITA - Dichiarazione Intrastat