Skip to content

Commit 186f2e0

Browse files
committed
[MIG] l10n_ch_pain_base: Migration to 16.0
Remove dependency on l10n_ch_base_bank since it is obsolete
1 parent 38f5891 commit 186f2e0

File tree

5 files changed

+7
-78
lines changed

5 files changed

+7
-78
lines changed

l10n_ch_pain_base/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
{
66
"name": "Switzerland - ISO 20022",
77
"summary": "ISO 20022 base module for Switzerland",
8-
"version": "14.0.1.0.0",
8+
"version": "16.0.1.0.0",
99
"category": "Finance",
1010
"website": "https://github.com/OCA/l10n-switzerland",
1111
"author": "Akretion,Camptocamp,Odoo Community Association (OCA)",
1212
"license": "AGPL-3",
13-
"depends": ["account_banking_pain_base", "l10n_ch_base_bank"],
13+
"depends": ["account_banking_pain_base"],
1414
"data": ["views/account_payment_line.xml"],
1515
"installable": True,
1616
}

l10n_ch_pain_base/models/account_move_line.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ def _prepare_payment_line_vals(self, payment_order):
1414
and self.move_id._has_isr_ref()
1515
and self.move_id.partner_bank_id
1616
):
17-
if self.move_id.partner_bank_id._is_qr_iban():
17+
if self.move_id.partner_bank_id.l10n_ch_qr_iban:
1818
vals["communication_type"] = "qrr"
19-
else:
20-
vals["local_instrument"] = "CH01"
21-
vals["communication_type"] = "isr"
2219
if vals["communication"]:
2320
vals["communication"] = vals["communication"].replace(" ", "")
2421
return vals

l10n_ch_pain_base/models/account_payment_line.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@
77
class AccountPaymentLine(models.Model):
88
_inherit = "account.payment.line"
99

10-
local_instrument = fields.Selection(
11-
selection_add=[("CH01", "CH01 (ISR)")], ondelete={"CH01": "set null"}
12-
)
1310
communication_type = fields.Selection(
14-
selection_add=[("isr", "ISR"), ("qrr", "QRR")],
15-
ondelete={"isr": "set default", "qrr": "set default"},
11+
selection_add=[("qrr", "QRR")],
12+
ondelete={"qrr": "set default"},
1613
)
17-
18-
def invoice_reference_type2communication_type(self):
19-
res = super().invoice_reference_type2communication_type()
20-
res["isr"] = "isr"
21-
return res

l10n_ch_pain_base/models/account_payment_order.py

+1-62
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
from lxml import etree
55

6-
from odoo import _, api, models
7-
from odoo.exceptions import UserError
6+
from odoo import api, models
87

98

109
class AccountPaymentOrder(models.Model):
@@ -71,66 +70,6 @@ def generate_start_payment_info_block(
7170
gen_args,
7271
)
7372

74-
@api.model
75-
def generate_party_agent(
76-
self, parent_node, party_type, order, partner_bank, gen_args, bank_line=None
77-
):
78-
if gen_args.get("pain_flavor") == "pain.001.001.03.ch.02" and bank_line:
79-
if bank_line.payment_line_ids[:1].local_instrument == "CH01":
80-
# Don't set the creditor agent on ISR/CH01 payments
81-
return True
82-
elif not partner_bank.bank_bic:
83-
raise UserError(
84-
_(
85-
"For pain.001.001.03.ch.02, for non-ISR payments, "
86-
"the BIC is required on the bank '%(name)s' related to the "
87-
"bank account '%(account)s'",
88-
name=partner_bank.bank_id.name,
89-
account=partner_bank.acc_number,
90-
)
91-
)
92-
return super().generate_party_agent(
93-
parent_node,
94-
party_type,
95-
order,
96-
partner_bank,
97-
gen_args,
98-
bank_line=bank_line,
99-
)
100-
101-
@api.model
102-
def generate_party_acc_number(
103-
self, parent_node, party_type, order, partner_bank, gen_args, bank_line=None
104-
):
105-
if (
106-
gen_args.get("pain_flavor") == "pain.001.001.03.ch.02"
107-
and bank_line
108-
and bank_line.payment_line_ids[:1].local_instrument == "CH01"
109-
):
110-
if not partner_bank.l10n_ch_postal:
111-
raise UserError(
112-
_(
113-
"The field 'Postal account' is not set on the bank "
114-
"account '%s'."
115-
)
116-
% partner_bank.acc_number
117-
)
118-
party_account = etree.SubElement(parent_node, "%sAcct" % party_type)
119-
party_account_id = etree.SubElement(party_account, "Id")
120-
party_account_other = etree.SubElement(party_account_id, "Othr")
121-
party_account_other_id = etree.SubElement(party_account_other, "Id")
122-
party_account_other_id.text = partner_bank.l10n_ch_postal
123-
return True
124-
else:
125-
return super().generate_party_acc_number(
126-
parent_node,
127-
party_type,
128-
order,
129-
partner_bank,
130-
gen_args,
131-
bank_line=bank_line,
132-
)
133-
13473
@api.model
13574
def generate_address_block(self, parent_node, partner, gen_args):
13675
"""Generate the piece of the XML corresponding to PstlAdr"""
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* Alexis de Lattre <alexis.delattre@akretion.com>
22
* Denis Leemann <denis.leemann@camptocamp.com>
33
* Mykhailo Panarin <m.panarin@mobilunity.com>
4+
* Alberto Nieto <alberto.nieto@braintec.com>

0 commit comments

Comments
 (0)