Skip to content

Commit

Permalink
[MIG] l10n_ch_pain_base: Migration to 16.0
Browse files Browse the repository at this point in the history
Remove dependency on l10n_ch_base_bank since it is obsolete
  • Loading branch information
BT-anieto committed Jun 12, 2024
1 parent 38f5891 commit a0ee66e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 73 deletions.
4 changes: 2 additions & 2 deletions l10n_ch_pain_base/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
2 changes: 1 addition & 1 deletion l10n_ch_pain_base/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +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():
if self.move_id.partner_bank_id.l10n_ch_qr_iban:
vals["communication_type"] = "qrr"

Check warning on line 18 in l10n_ch_pain_base/models/account_move_line.py

View check run for this annotation

Codecov / codecov/patch

l10n_ch_pain_base/models/account_move_line.py#L18

Added line #L18 was not covered by tests
else:
vals["local_instrument"] = "CH01"
Expand Down
12 changes: 2 additions & 10 deletions l10n_ch_pain_base/models/account_payment_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
60 changes: 0 additions & 60 deletions l10n_ch_pain_base/models/account_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,66 +71,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"""
Expand Down
1 change: 1 addition & 0 deletions l10n_ch_pain_base/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Alexis de Lattre <[email protected]>
* Denis Leemann <[email protected]>
* Mykhailo Panarin <[email protected]>
* Alberto Nieto <[email protected]>

0 comments on commit a0ee66e

Please sign in to comment.