From 92d8c1aef65109ffb019a7a84f22c541edef0be1 Mon Sep 17 00:00:00 2001 From: BT-anieto Date: Tue, 11 Jun 2024 16:24:56 +0200 Subject: [PATCH] [MIG] l10n_ch_pain_base: Migration to 16.0 Remove dependency on l10n_ch_base_bank since it is obsolete --- l10n_ch_pain_base/__manifest__.py | 4 +- l10n_ch_pain_base/models/account_move_line.py | 6 +- .../models/account_payment_line.py | 12 +-- .../models/account_payment_order.py | 90 +------------------ l10n_ch_pain_base/readme/CONTRIBUTORS.rst | 1 + 5 files changed, 7 insertions(+), 106 deletions(-) diff --git a/l10n_ch_pain_base/__manifest__.py b/l10n_ch_pain_base/__manifest__.py index 7614c05ea..47735df3a 100644 --- a/l10n_ch_pain_base/__manifest__.py +++ b/l10n_ch_pain_base/__manifest__.py @@ -5,12 +5,12 @@ { "name": "Switzerland - ISO 20022", "summary": "ISO 20022 base module for Switzerland", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "category": "Finance", "website": "https://github.com/OCA/l10n-switzerland", "author": "Akretion,Camptocamp,Odoo Community Association (OCA)", "license": "AGPL-3", - "depends": ["account_banking_pain_base", "l10n_ch_base_bank"], + "depends": ["account_banking_pain_base"], "data": ["views/account_payment_line.xml"], "installable": True, } diff --git a/l10n_ch_pain_base/models/account_move_line.py b/l10n_ch_pain_base/models/account_move_line.py index a9bda5d40..2f82a52a8 100644 --- a/l10n_ch_pain_base/models/account_move_line.py +++ b/l10n_ch_pain_base/models/account_move_line.py @@ -14,11 +14,7 @@ def _prepare_payment_line_vals(self, payment_order): and self.move_id._has_isr_ref() and self.move_id.partner_bank_id ): - if self.move_id.partner_bank_id._is_qr_iban(): - vals["communication_type"] = "qrr" - else: - vals["local_instrument"] = "CH01" - vals["communication_type"] = "isr" + vals["communication_type"] = "qrr" if vals["communication"]: vals["communication"] = vals["communication"].replace(" ", "") return vals diff --git a/l10n_ch_pain_base/models/account_payment_line.py b/l10n_ch_pain_base/models/account_payment_line.py index a1d65ca41..b5696234f 100644 --- a/l10n_ch_pain_base/models/account_payment_line.py +++ b/l10n_ch_pain_base/models/account_payment_line.py @@ -7,15 +7,7 @@ class AccountPaymentLine(models.Model): _inherit = "account.payment.line" - local_instrument = fields.Selection( - selection_add=[("CH01", "CH01 (ISR)")], ondelete={"CH01": "set null"} - ) communication_type = fields.Selection( - selection_add=[("isr", "ISR"), ("qrr", "QRR")], - ondelete={"isr": "set default", "qrr": "set default"}, + selection_add=[("qrr", "QRR")], + ondelete={"qrr": "set default"}, ) - - def invoice_reference_type2communication_type(self): - res = super().invoice_reference_type2communication_type() - res["isr"] = "isr" - return res diff --git a/l10n_ch_pain_base/models/account_payment_order.py b/l10n_ch_pain_base/models/account_payment_order.py index 59f518b05..8e7500849 100644 --- a/l10n_ch_pain_base/models/account_payment_order.py +++ b/l10n_ch_pain_base/models/account_payment_order.py @@ -3,8 +3,7 @@ from lxml import etree -from odoo import _, api, models -from odoo.exceptions import UserError +from odoo import api, models class AccountPaymentOrder(models.Model): @@ -71,93 +70,6 @@ def generate_start_payment_info_block( gen_args, ) - @api.model - def generate_party_agent( - self, parent_node, party_type, order, partner_bank, gen_args, bank_line=None - ): - if gen_args.get("pain_flavor") == "pain.001.001.03.ch.02" and bank_line: - if bank_line.payment_line_ids[:1].local_instrument == "CH01": - # Don't set the creditor agent on ISR/CH01 payments - return True - elif not partner_bank.bank_bic: - raise UserError( - _( - "For pain.001.001.03.ch.02, for non-ISR payments, " - "the BIC is required on the bank '%(name)s' related to the " - "bank account '%(account)s'", - name=partner_bank.bank_id.name, - account=partner_bank.acc_number, - ) - ) - return super().generate_party_agent( - parent_node, - party_type, - order, - partner_bank, - gen_args, - bank_line=bank_line, - ) - - @api.model - def generate_party_acc_number( - self, parent_node, party_type, order, partner_bank, gen_args, bank_line=None - ): - if ( - gen_args.get("pain_flavor") == "pain.001.001.03.ch.02" - and bank_line - and bank_line.payment_line_ids[:1].local_instrument == "CH01" - ): - if not partner_bank.l10n_ch_postal: - raise UserError( - _( - "The field 'Postal account' is not set on the bank " - "account '%s'." - ) - % partner_bank.acc_number - ) - party_account = etree.SubElement(parent_node, "%sAcct" % party_type) - party_account_id = etree.SubElement(party_account, "Id") - party_account_other = etree.SubElement(party_account_id, "Othr") - party_account_other_id = etree.SubElement(party_account_other, "Id") - party_account_other_id.text = partner_bank.l10n_ch_postal - return True - else: - return super().generate_party_acc_number( - parent_node, - party_type, - order, - partner_bank, - gen_args, - bank_line=bank_line, - ) - - @api.model - def generate_address_block(self, parent_node, partner, gen_args): - """Generate the piece of the XML corresponding to PstlAdr""" - if partner.country_id: - postal_address = etree.SubElement(parent_node, "PstlAdr") - - country = etree.SubElement(postal_address, "Ctry") - country.text = self._prepare_field( - "Country", - "partner.country_id.code", - {"partner": partner}, - 2, - gen_args=gen_args, - ) - - if partner.street or partner.street2: - adrline1 = etree.SubElement(postal_address, "AdrLine") - adrline1.text = ", ".join( - filter(None, [partner.street, partner.street2]) - ) - - if partner.zip and partner.city: - adrline2 = etree.SubElement(postal_address, "AdrLine") - adrline2.text = " ".join([partner.zip, partner.city]) - - return True - @api.model def generate_remittance_info_block(self, parent_node, line, gen_args): if line.payment_line_ids[:1].communication_type == "qrr": diff --git a/l10n_ch_pain_base/readme/CONTRIBUTORS.rst b/l10n_ch_pain_base/readme/CONTRIBUTORS.rst index 4f35f64a5..f5ed57aa7 100644 --- a/l10n_ch_pain_base/readme/CONTRIBUTORS.rst +++ b/l10n_ch_pain_base/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * Alexis de Lattre * Denis Leemann * Mykhailo Panarin +* Alberto Nieto