From 2e879774a53c5cce0329bba8150871ebe73d52ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Didderen?= Date: Sat, 11 Nov 2023 11:51:46 +0100 Subject: [PATCH] [MIG] l10n_be_intrastat_product: Migration to 15.0 --- companyweb_base/README.rst | 2 +- companyweb_payment_info/README.rst | 2 +- l10n_be_intrastat_product/README.rst | 13 +- l10n_be_intrastat_product/__init__.py | 1 - l10n_be_intrastat_product/__manifest__.py | 5 +- .../data/intrastat_region.xml | 38 +-- .../data/intrastat_transaction.xml | 299 ++++++++++-------- .../l10n_be_intrastat_product_declaration.py | 16 +- .../readme/CONTRIBUTORS.rst | 4 +- .../security/intrastat_security.xml | 8 +- .../security/ir.model.access.csv | 2 - .../static/description/index.html | 14 +- .../tests/test_intrastat_be.py | 13 +- l10n_be_intrastat_product/wizards/__init__.py | 1 - .../wizards/intrastat_installer.py | 194 ------------ .../wizards/intrastat_installer_views.xml | 47 --- l10n_be_partner_kbo_bce/README.rst | 2 +- .../static/description/index.html | 2 +- 18 files changed, 243 insertions(+), 420 deletions(-) delete mode 100644 l10n_be_intrastat_product/wizards/__init__.py delete mode 100644 l10n_be_intrastat_product/wizards/intrastat_installer.py delete mode 100644 l10n_be_intrastat_product/wizards/intrastat_installer_views.xml diff --git a/companyweb_base/README.rst b/companyweb_base/README.rst index 608796678..91d7aa690 100644 --- a/companyweb_base/README.rst +++ b/companyweb_base/README.rst @@ -7,7 +7,7 @@ Companyweb !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:168b0c27e275cc0464faeec7aedcf51f91f2915b684f60ad9bfcc479bfbb53b8 + !! source digest: sha256:f840303f10e7bd3fe7848ded701859ffb3c83c57a64ecf5035c984b115f0dad8 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png diff --git a/companyweb_payment_info/README.rst b/companyweb_payment_info/README.rst index 27f3a2c21..bbb4ce53f 100644 --- a/companyweb_payment_info/README.rst +++ b/companyweb_payment_info/README.rst @@ -7,7 +7,7 @@ Companyweb Payment Info !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:c54816e96a58ce487542131cd55830b335ffa8caba87820af9809c47acba54c9 + !! source digest: sha256:a3abe879d486ce6beeffc5cf336e5db0a9c449f2feec5dcdfd99362d894e2d20 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png diff --git a/l10n_be_intrastat_product/README.rst b/l10n_be_intrastat_product/README.rst index efede54b8..0001c0889 100644 --- a/l10n_be_intrastat_product/README.rst +++ b/l10n_be_intrastat_product/README.rst @@ -7,7 +7,7 @@ Intrastat Product Declaration for Belgium !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:3404c542886fb42b2a854d16926932906645c0472aab9ea2090bc5604b6ec096 + !! source digest: sha256:035b9ad10d46e56d2d74c61be47e3f95566553feb694e6ea2449a9f92d535d0f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -179,7 +179,9 @@ Authors Contributors ~~~~~~~~~~~~ -* Luc De Meyer +* Noviat + * Luc De Meyer + * Jérémy Didderen Maintainers ~~~~~~~~~~~ @@ -197,10 +199,13 @@ promote its widespread use. .. |maintainer-luc-demeyer| image:: https://github.com/luc-demeyer.png?size=40px :target: https://github.com/luc-demeyer :alt: luc-demeyer +.. |maintainer-jdidderen-noviat| image:: https://github.com/jdidderen-noviat.png?size=40px + :target: https://github.com/jdidderen-noviat + :alt: jdidderen-noviat -Current `maintainer `__: +Current `maintainers `__: -|maintainer-luc-demeyer| +|maintainer-luc-demeyer| |maintainer-jdidderen-noviat| This module is part of the `OCA/l10n-belgium `_ project on GitHub. diff --git a/l10n_be_intrastat_product/__init__.py b/l10n_be_intrastat_product/__init__.py index aee8895e7..0650744f6 100644 --- a/l10n_be_intrastat_product/__init__.py +++ b/l10n_be_intrastat_product/__init__.py @@ -1,2 +1 @@ from . import models -from . import wizards diff --git a/l10n_be_intrastat_product/__manifest__.py b/l10n_be_intrastat_product/__manifest__.py index 1e862d7e5..427d12113 100644 --- a/l10n_be_intrastat_product/__manifest__.py +++ b/l10n_be_intrastat_product/__manifest__.py @@ -3,12 +3,12 @@ { "name": "Intrastat Product Declaration for Belgium", - "version": "14.0.1.1.2", + "version": "15.0.1.0.0", "category": "Intrastat", "license": "AGPL-3", "summary": "Intrastat Product Declaration for Belgium", "author": "Noviat,Odoo Community Association (OCA)", - "maintainers": ["luc-demeyer"], + "maintainers": ["luc-demeyer", "jdidderen-noviat"], "website": "https://github.com/OCA/l10n-belgium", "depends": ["intrastat_product"], "conflicts": ["l10n_be_intrastat", "report_intrastat"], @@ -19,7 +19,6 @@ "data/intrastat_transaction.xml", "views/account_move_views.xml", "views/l10n_be_intrastat_product_views.xml", - "wizards/intrastat_installer_views.xml", ], "installable": True, } diff --git a/l10n_be_intrastat_product/data/intrastat_region.xml b/l10n_be_intrastat_product/data/intrastat_region.xml index 07c0665b9..9a82ceefa 100644 --- a/l10n_be_intrastat_product/data/intrastat_region.xml +++ b/l10n_be_intrastat_product/data/intrastat_region.xml @@ -1,29 +1,29 @@ - - + - 1 - Flemish region - - Includes Antwerp, Flemish Brabant, West Flanders, East Flanders and Limburg provinces + 1 + Flemish region + + Includes Antwerp, Flemish Brabant, West Flanders, East Flanders and Limburg provinces + - 2 - Walloon region - - Includes Walloon Brabant, Hainaut, Liège, Luxembourg and Namur provinces + 2 + Walloon region + + Includes Walloon Brabant, Hainaut, Liège, Luxembourg and Namur provinces + - 3 - Brussels region - - Includes 19 districts + 3 + Brussels region + + Includes 19 districts - diff --git a/l10n_be_intrastat_product/data/intrastat_transaction.xml b/l10n_be_intrastat_product/data/intrastat_transaction.xml index 2a3bc4987..a2679bfa1 100644 --- a/l10n_be_intrastat_product/data/intrastat_transaction.xml +++ b/l10n_be_intrastat_product/data/intrastat_transaction.xml @@ -1,187 +1,238 @@ - - + - 11 - Transactions involving actual change of ownership with financial compensation. Outright sale/purchase except direct trade with/by private consumers. + 11 + Transactions involving actual change of ownership with financial compensation. Outright sale/purchase except + direct trade with/by private consumers. + - 12 - Transactions involving actual change of ownership with financial compensation. Direct trade with/by private consumers (incl. distance sale). + 12 + Transactions involving actual change of ownership with financial compensation. Direct trade with/by private + consumers (incl. distance sale). + - 21 - Return and replacement of goods free of charge after registration of the original transaction. Return of goods. + 21 + Return and replacement of goods free of charge after registration of the original transaction. Return of goods. + - 22 - Return and replacement of goods free of charge after registration of the original transaction. Replacement for returned goods. + 22 + Return and replacement of goods free of charge after registration of the original transaction. Replacement for + returned goods. + - 23 - Return and replacement of goods free of charge after registration of the original transaction. Replacement (e.g. under warranty) for goods not being returned. + 23 + Return and replacement of goods free of charge after registration of the original transaction. Replacement + (e.g. under warranty) for goods not being returned. + - 31 - Transactions involving intended change of ownership or change of ownership without financial compensation. Movements to/from a warehouse (excluding call-off and consignment stock). + 31 + Transactions involving intended change of ownership or change of ownership without financial compensation. + Movements to/from a warehouse (excluding call-off and consignment stock). + - 32 - Transactions involving intended change of ownership or change of ownership without financial compensation. Supply for sale on approval or after trial (including call-off and consignment stock). + 32 + Transactions involving intended change of ownership or change of ownership without financial compensation. + Supply for sale on approval or after trial (including call-off and consignment stock). + - 33 - Transactions involving intended change of ownership or change of ownership without financial compensation. Financial leasing. + 33 + Transactions involving intended change of ownership or change of ownership without financial compensation. + Financial leasing. + - 34 - Transactions involving intended change of ownership or change of ownership without financial compensation. Transactions involving transfer of ownership without financial compensation. + 34 + Transactions involving intended change of ownership or change of ownership without financial compensation. + Transactions involving transfer of ownership without financial compensation. + - 41 - Transactions with a view to processing under contract (not involving change of ownership). Goods expected to return to the initial Member State/country of export. + 41 + Transactions with a view to processing under contract (not involving change of ownership). Goods expected to + return to the initial Member State/country of export. + - 42 - Transactions with a view to processing under contract (not involving change of ownership). Goods not expected to return to the initial Member State/country of export. + 42 + Transactions with a view to processing under contract (not involving change of ownership). Goods not expected + to return to the initial Member State/country of export. + - 51 - Transactions following processing under contract (not involving change of ownership). Goods returning to the initial Member State/country of export. + 51 + Transactions following processing under contract (not involving change of ownership). Goods returning to the + initial Member State/country of export. + - 52 - Transactions following processing under contract (not involving change of ownership). Goods not returning to the initial Member State/country of export. + 52 + Transactions following processing under contract (not involving change of ownership). Goods not returning to + the initial Member State/country of export. + - 60 - Operations following repair or maintenance. This service can be both free of charge or against payment. These operations do not involve a (future) transfer of ownership. + 60 + Operations following repair or maintenance. This service can be both free of charge or against payment. These + operations do not involve a (future) transfer of ownership. + - 71 - Transactions with a view to/following customs clearance (not involving change of ownership, related to goods in quasi-import or export). Release of goods for free circulation in a Member State with a subsequent export to another Member State. + 71 + Transactions with a view to/following customs clearance (not involving change of ownership, related to goods in + quasi-import or export). Release of goods for free circulation in a Member State with a subsequent export to + another Member State. + - 72 - Transactions with a view to/following customs clearance (not involving change of ownership, related to goods in quasi-import or export). Transportation of goods from one Member State to another Member State to place the goods under the export procedure. + 72 + Transactions with a view to/following customs clearance (not involving change of ownership, related to goods in + quasi-import or export). Transportation of goods from one Member State to another Member State to place the + goods under the export procedure. + - 80 - Transactions involving the supply of building materials and technical equipment under a general construction or civil engineering contract for which no separate invoicing of the goods is required and an invoice for the total contract is issued. + 80 + Transactions involving the supply of building materials and technical equipment under a general construction or + civil engineering contract for which no separate invoicing of the goods is required and an invoice for the + total contract is issued. + - 91 - Other transactions which cannot be classified under other codes. Hire, loan, and operational leasing longer than 24 months. + 91 + Other transactions which cannot be classified under other codes. Hire, loan, and operational leasing longer + than 24 months. + - 99 - Other transactions which cannot be classified under other codes. Other. + 99 + Other transactions which cannot be classified under other codes. Other. + - 1 - Transactions involving an actual or intended transfer of ownership from residents to non-residents against financial or other compensation (except the transactions listed under 2, 7 and 8) - 0 + 1 + Transactions involving an actual or intended transfer of ownership from residents to non-residents against + financial or other compensation (except the transactions listed under 2, 7 and 8) + + 0 - 2 - Return and replacement of goods free of charge after registration of the original transaction - 0 + 2 + Return and replacement of goods free of charge after registration of the original transaction + + 0 - 3 - Transactions involving transfer of ownership without financial or in kind compensation (e.g. aid shipments) - 0 + 3 + Transactions involving transfer of ownership without financial or in kind compensation (e.g. aid shipments) + + 0 - 4 - Operations with a view to processing 1 under contract (no transfer of ownership to the processor) - 0 + 4 + Operations with a view to processing 1 under contract (no transfer of ownership to the processor) + + 0 - 5 - Operations following processing under contract (no transfer of ownership to the processor) - 0 + 5 + Operations following processing under contract (no transfer of ownership to the processor) + + 0 - 6 - Operations "following" repair or maintenance, other than under joint inter-governmental production programmes. Repair and maintenance can be against payment or free of charge. These operations do not involve a (future) transfer of ownership*. - 0 + 6 + Operations "following" repair or maintenance, other than under joint inter-governmental production programmes. + Repair and maintenance can be against payment or free of charge. These operations do not involve a (future) + transfer of ownership*. + + 0 - 7 - Operations under joint defence projects or other joint intergovernmental production programmes - 0 + 7 + Operations under joint defence projects or other joint intergovernmental production programmes + + 0 - 8 - Transactions involving the supply of building materials and technical equipment under a general construction or civil engineering contract for which no separate invoicing of the goods is required and an invoice for the total contract is issued - 0 + 8 + Transactions involving the supply of building materials and technical equipment under a general construction or + civil engineering contract for which no separate invoicing of the goods is required and an invoice for the + total contract is issued + + 0 - 9 - Other transactions which cannot be classified under other codes - 0 + 9 + Other transactions which cannot be classified under other codes + + 0 - diff --git a/l10n_be_intrastat_product/models/l10n_be_intrastat_product_declaration.py b/l10n_be_intrastat_product/models/l10n_be_intrastat_product_declaration.py index c0aa8b1fd..43b441d40 100644 --- a/l10n_be_intrastat_product/models/l10n_be_intrastat_product_declaration.py +++ b/l10n_be_intrastat_product/models/l10n_be_intrastat_product_declaration.py @@ -8,7 +8,7 @@ from lxml import etree from odoo import _, api, fields, models -from odoo.exceptions import RedirectWarning, UserError +from odoo.exceptions import UserError from odoo.addons.report_xlsx_helper.report.report_xlsx_abstract import ( ReportXlsxAbstract, @@ -201,6 +201,7 @@ def _update_computation_line_vals(self, inv_line, line_vals, notedict): if self.reporting_level == "extended": incoterm = self._get_incoterm(inv_line, notedict) line_vals.update({"incoterm_id": incoterm.id}) + return def _handle_invoice_accessory_cost( self, @@ -240,18 +241,15 @@ def _gather_invoices_init(self, notedict): lambda r: r.company_id == self.company_id ) or hs_code.filtered(lambda r: not r.company_id) if not hs_code: - action = self.env.ref("%s.intrastat_installer_action" % module) msg = ( _( "Intrastat Code '%s' not found. " "\nYou can update your codes " - "via the Intrastat Configuration Wizard." + "via the module intrastat_product_hscodes_import." ) % special_code ) - raise RedirectWarning( - msg, action.id, _("Go to the Intrastat Configuration Wizard.") - ) + raise UserError(msg) notedict["credit_note_code"] = hs_code[0] if self.year <= "2021": @@ -327,8 +325,8 @@ def _node_Item(self, parent, line, decl_code): for fld in ("src_dest_country_id", "transaction_id", "region_id", "hs_code_id"): if not line[fld]: raise UserError( - _("Error while processing %s:\nMissing '%s'.") - % (line, line._fields[fld].string) + _("Error while processing %(line)s:\nMissing '%(line_field)s'.") + % {"line": line, "line_field": line._fields[fld].string} ) Item = etree.SubElement(parent, "Item") etree.SubElement(Item, "Dim", attrib={"prop": "EXTRF"}).text = decl_code @@ -468,6 +466,7 @@ def _check_vat(self): for rec in self: if not rec.vat == "QV999999999999": super(L10nBeIntrastatProductComputationLine, rec)._check_vat() + return class L10nBeIntrastatProductDeclarationLine(models.Model): @@ -493,3 +492,4 @@ def _check_vat(self): for rec in self: if not rec.vat == "QV999999999999": super(L10nBeIntrastatProductDeclarationLine, rec)._check_vat() + return diff --git a/l10n_be_intrastat_product/readme/CONTRIBUTORS.rst b/l10n_be_intrastat_product/readme/CONTRIBUTORS.rst index 044d1a001..16051901b 100644 --- a/l10n_be_intrastat_product/readme/CONTRIBUTORS.rst +++ b/l10n_be_intrastat_product/readme/CONTRIBUTORS.rst @@ -1 +1,3 @@ -* Luc De Meyer +* Noviat + * Luc De Meyer + * Jérémy Didderen diff --git a/l10n_be_intrastat_product/security/intrastat_security.xml b/l10n_be_intrastat_product/security/intrastat_security.xml index e1378067b..2eb87a34b 100644 --- a/l10n_be_intrastat_product/security/intrastat_security.xml +++ b/l10n_be_intrastat_product/security/intrastat_security.xml @@ -1,14 +1,12 @@ - - + - Belgian Intrastat Product Declaration + Belgian Intrastat Product Declaration - + - diff --git a/l10n_be_intrastat_product/security/ir.model.access.csv b/l10n_be_intrastat_product/security/ir.model.access.csv index c13ea0c65..4f917cae4 100644 --- a/l10n_be_intrastat_product/security/ir.model.access.csv +++ b/l10n_be_intrastat_product/security/ir.model.access.csv @@ -2,5 +2,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_l10n_be_intrastat_product_declaration,l10n_be_intrastat_product_declaration accountant,model_l10n_be_intrastat_product_declaration,account.group_account_manager,1,1,1,1 access_l10n_be_intrastat_product_declaration_line,l10n_be_intrastat_product_declaration_line accountant,model_l10n_be_intrastat_product_declaration_line,account.group_account_manager,1,1,1,1 access_l10n_be_intrastat_product_computation_line,l10n_be_intrastat_product_computation_line accountant,model_l10n_be_intrastat_product_computation_line,account.group_account_manager,1,1,1,1 -access_intrastat_installer_admin,access_intrastat_installer_admin,model_intrastat_installer,base.group_system,1,1,1,1 -access_intrastat_installer_account_manager,access_intrastat_installer_account_manager,model_intrastat_installer,account.group_account_manager,1,1,1,0 diff --git a/l10n_be_intrastat_product/static/description/index.html b/l10n_be_intrastat_product/static/description/index.html index 2df90f972..a81b1c500 100644 --- a/l10n_be_intrastat_product/static/description/index.html +++ b/l10n_be_intrastat_product/static/description/index.html @@ -367,7 +367,7 @@

Intrastat Product Declaration for Belgium

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:3404c542886fb42b2a854d16926932906645c0472aab9ea2090bc5604b6ec096 +!! source digest: sha256:035b9ad10d46e56d2d74c61be47e3f95566553feb694e6ea2449a9f92d535d0f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/l10n-belgium Translate me on Weblate Try me on Runboat

This module implements the Belgian Intrastat reporting.

@@ -518,7 +518,15 @@

Authors

Contributors

@@ -528,8 +536,8 @@

Maintainers

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.

-

Current maintainer:

-

luc-demeyer

+

Current maintainers:

+

luc-demeyer jdidderen-noviat

This module is part of the OCA/l10n-belgium project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/l10n_be_intrastat_product/tests/test_intrastat_be.py b/l10n_be_intrastat_product/tests/test_intrastat_be.py index 9e70cea25..9926cc2dd 100644 --- a/l10n_be_intrastat_product/tests/test_intrastat_be.py +++ b/l10n_be_intrastat_product/tests/test_intrastat_be.py @@ -1,10 +1,10 @@ # Copyright 2009-2022 Noviat. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo.tests import Form, SavepointCase +from odoo.tests.common import Form, TransactionCase -class TestIntrastatBe(SavepointCase): +class TestIntrastatBe(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -20,16 +20,18 @@ def setUpClass(cls): ) cls.fpos = cls.fpos_obj.create( { - "name": "Intrastat Fiscal Position", + "name": "Intrastat Fiscal Position (B2B)", "intrastat": True, "vat_required": True, + "country_group_id": cls.env.ref("base.europe").id, } ) cls.fpos_na = cls.fpos_obj.create( { - "name": "Intrastat Fiscal Position", + "name": "Intrastat Fiscal Position (B2C)", "intrastat": True, "vat_required": False, + "country_group_id": cls.env.ref("base.europe").id, } ) cls.hs_code_cn = cls.env["hs.code"].create( @@ -104,6 +106,7 @@ def setUpClass(cls): "property_account_position_id": cls.fpos.id, } ) + cls.env["account.tax"].search([('company_id','=', cls.company.id)]).write({'country_id': cls.env.ref("base.be").id}) def test_be_sale_b2b(self): @@ -141,6 +144,7 @@ def test_be_sale_b2b(self): # OCA stock_picking_invoice_link module which is currently # not in the module dependency (we check the presence of # this module via hasattr) + sale_journal_rec = self.env["account.journal"].search([("type","=","sale")],limit=1) reversal = ( self.env["account.move.reversal"] .with_context(active_model="account.move", active_ids=inv_out.ids) @@ -149,6 +153,7 @@ def test_be_sale_b2b(self): "date": inv_out.date, "reason": "test refund", "refund_method": "refund", + "journal_id": sale_journal_rec.id, } ) .reverse_moves() diff --git a/l10n_be_intrastat_product/wizards/__init__.py b/l10n_be_intrastat_product/wizards/__init__.py deleted file mode 100644 index dc676fe3f..000000000 --- a/l10n_be_intrastat_product/wizards/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import intrastat_installer diff --git a/l10n_be_intrastat_product/wizards/intrastat_installer.py b/l10n_be_intrastat_product/wizards/intrastat_installer.py deleted file mode 100644 index 94c2a7a12..000000000 --- a/l10n_be_intrastat_product/wizards/intrastat_installer.py +++ /dev/null @@ -1,194 +0,0 @@ -# Copyright 2009-2022 Noviat. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -import csv -import io -import logging -import os - -import odoo -from odoo import _, api, fields, models -from odoo.exceptions import UserError - -_logger = logging.getLogger(__name__) - -CN_file_year = "2022" -CN_file_delimiter = ";" -CN_LANGS = { - "en": _("English"), - "nl": _("Dutch"), - "fr": _("French"), - "de": _("German"), -} - - -class IntrastatInstaller(models.TransientModel): - _name = "intrastat.installer" - _inherit = "res.config.installer" - _description = "Intrastat Installer" - - CN_file = fields.Selection( - selection="_selection_CN_file", - string="Intrastat Code File", - required=True, - default=lambda self: self._default_CN_file(), - ) - share_codes = fields.Boolean( - string="Share Codes", - default=True, - help="Set this flag to share the Intrastat Codes between all " - "Legal Entities defined in this Odoo Database.\n" - "This may cause conflicts when requiring Intrastat declarations " - " in multiple countries.", - ) - company_id = fields.Many2one( - comodel_name="res.company", - default=lambda self: self._default_company_id(), - required=True, - string="Company", - ) - - @api.model - def _selection_CN_file(self): - return [ - (CN_file_year + "_" + x, CN_file_year + " " + CN_LANGS[x]) for x in CN_LANGS - ] - - @api.model - def _default_CN_file(self): - lang = self.env.user.lang[:2] - if lang not in ["fr", "nl"]: - lang = "en" - return CN_file_year + "_" + lang - - @api.model - def _default_company_id(self): - return self.env.company - - def _set_intrastat_fpos(self, company): - module = ( - self.env["ir.module.module"] - .sudo() - .search( - [ - ("name", "in", ("l10n_be", "l10n_be_coa_multilang")), - ("state", "=", "installed"), - ] - ) - ) - if not module: - _logger.warning( - "No Belgian localisation module found. " - "The Intrastat flag on the Intracommunity Fiscal Position " - "has not been set." - ) - return - if module.name == "l10n_be": - fpt_name = "fiscal_position_template_3" - elif module.name == "l10n_be_coa_multilang": - fpt_name = "afptn_intracom" - fpos_ref = "{}.{}_{}".format(module.name, company.id, fpt_name) - if fpos_ref: - try: - fpos = self.env.ref(fpos_ref) - if not fpos.intrastat: - fpos.intrastat = True - except Exception: - _logger.warning("Fiscal position '%s' not found", fpos_ref) - - @api.model - def _load_code(self, row, be_cn_codes, cn_codes, cn_lookup): - company_id = self.company_id.id - if self.share_codes: - company_id = False - vals = { - "description": row["description"], - "company_id": company_id, - } - cn_unit_id = row["unit_id"] - if cn_unit_id: - cn_unit_ref = "intrastat_product." + cn_unit_id - cn_unit = self.env.ref(cn_unit_ref) - vals["intrastat_unit_id"] = cn_unit.id - cn_code = row["code"] - cn_code_i = cn_lookup.get(cn_code) - if isinstance(cn_code_i, int): - be_cn_codes[cn_code_i].write(vals) - else: - vals["local_code"] = cn_code - self.env["hs.code"].create(vals) - - def execute(self): - res = super().execute() - company = self.company_id - - # set company defaults - module = __name__.split("addons.")[1].split(".")[0] - transaction = self.env.ref("%s.intrastat_transaction_11" % module) - if not company.intrastat_transaction_out_invoice: - company.intrastat_transaction_out_invoice = transaction - if not company.intrastat_transaction_out_refund: - company.intrastat_transaction_out_refund = transaction - if not company.intrastat_transaction_in_invoice: - company.intrastat_transaction_in_invoice = transaction - if not company.intrastat_transaction_in_refund: - company.intrastat_transaction_in_refund = transaction - - # set intrastat flag on Intracommunity Fiscal Position - self._set_intrastat_fpos(company) - - # Set correct company_id on intrastat transactions. - # Installation of this module under OdooBot will - # set the company_id to 1 in stead of company that - # needs the Belgian Intrastat Declaration. - # TODO: make OCA PR for intrastat_product to make - # shared intrastat transactions the default behaviour - self.env.cr.execute( - """ - SELECT imd.res_id FROM ir_model_data imd - JOIN intrastat_transaction it ON imd.res_id=it.id - WHERE imd.module=%s AND imd.model='intrastat.transaction' - AND it.company_id IS NOT NULL - AND it.company_id != %s - """, - (module, self.company_id.id), - ) - trans_ids = [x[0] for x in self.env.cr.fetchall()] - if trans_ids: - self.env.cr.execute( - """ - UPDATE intrastat_transaction - SET company_id = %s - WHERE id IN %s - """, - (self.company_id.id, tuple(trans_ids)), - ) - - # load intrastat_codes - hs_codes = self.env["hs.code"].search( - ["|", ("company_id", "=", company.id), ("company_id", "=", False)] - ) - cn_lookup = {} - for i, c in enumerate(hs_codes): - cn_lookup[c.local_code] = i - for adp in odoo.addons.__path__: - module_path = adp + os.sep + module - if os.path.isdir(module_path): - break - CN_fn = self.CN_file + "_intrastat_codes.csv" - CN_fqn = module_path + os.sep + "static/data" + os.sep + CN_fn - iso_code = self.CN_file[-2:] - langs = self.env["res.lang"].search([("code", "=like", iso_code + "_%")]) - - if not langs: - raise UserError( - _("Language %s is not activated on your system") % CN_LANGS[iso_code] - ) - with io.open(CN_fqn, mode="r", encoding="Windows-1252") as CN_file: - cn_codes = csv.DictReader(CN_file, delimiter=CN_file_delimiter) - for lang in langs: - ctx = dict(self.env.context, lang=lang.code) - hs_codes = hs_codes.with_context(ctx) - for row in cn_codes: - self._load_code(row, hs_codes, cn_codes, cn_lookup) - return res diff --git a/l10n_be_intrastat_product/wizards/intrastat_installer_views.xml b/l10n_be_intrastat_product/wizards/intrastat_installer_views.xml deleted file mode 100644 index 6bdea0019..000000000 --- a/l10n_be_intrastat_product/wizards/intrastat_installer_views.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - intrastat.installer.view - intrastat.installer - - -
- Load Intrastat Codes -
- - - - - - - - - Load Intrastat Codes - - - Load - -
-
- - - Load Intrastat Codes - ir.actions.act_window - intrastat.installer - - form - new - - - - - 10 - - -
diff --git a/l10n_be_partner_kbo_bce/README.rst b/l10n_be_partner_kbo_bce/README.rst index af383f0ab..3d4cd840b 100644 --- a/l10n_be_partner_kbo_bce/README.rst +++ b/l10n_be_partner_kbo_bce/README.rst @@ -7,7 +7,7 @@ Belgium - KBO/BCE numbers !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:ee80e2e6dadc1043fe905a634ef6799a541cf3ed8926a44dbf46fb88e880d7b7 + !! source digest: sha256:a9a1f25ff95c0b96a5457af6e320adb35ffeb05dd9136cfa10a2c6cbb7a9f5a4 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/l10n_be_partner_kbo_bce/static/description/index.html b/l10n_be_partner_kbo_bce/static/description/index.html index db67130ad..67ad8d216 100644 --- a/l10n_be_partner_kbo_bce/static/description/index.html +++ b/l10n_be_partner_kbo_bce/static/description/index.html @@ -367,7 +367,7 @@

Belgium - KBO/BCE numbers

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:ee80e2e6dadc1043fe905a634ef6799a541cf3ed8926a44dbf46fb88e880d7b7 +!! source digest: sha256:a9a1f25ff95c0b96a5457af6e320adb35ffeb05dd9136cfa10a2c6cbb7a9f5a4 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/l10n-belgium Translate me on Weblate Try me on Runboat

This module adds support for KBO/BCE numbers on partner records including a