Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwul committed Apr 2, 2024
1 parent 649bcad commit 54b8653
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
16 changes: 10 additions & 6 deletions l10n_ch_pain_base/models/account_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from odoo import _, api, models
from odoo.exceptions import UserError

ACCEPTED_PAIN_FLAVOURS = ("pain.001.001.03.ch.02", "pain.008.001.02.ch.03")

class AccountPaymentOrder(models.Model):
_inherit = "account.payment.order"
Expand All @@ -23,21 +24,21 @@ def generate_pain_nsmap(self):
self.ensure_one()
nsmap = super().generate_pain_nsmap()
pain_flavor = self.payment_mode_id.payment_method_id.pain_version
if pain_flavor in ["pain.001.001.03.ch.02", "pain.008.001.02.ch.01"]:
if pain_flavor in ACCEPTED_PAIN_FLAVOURS:
nsmap[None] = (
"http://www.six-interbank-clearing.com/de/" "%s.xsd" % pain_flavor
"http://www.six-interbank-clearing.com/de/%s.xsd" % pain_flavor
)

return nsmap

def generate_pain_attrib(self):
self.ensure_one()
pain_flavor = self.payment_mode_id.payment_method_id.pain_version
if pain_flavor in ["pain.001.001.03.ch.02", "pain.008.001.02.ch.01"]:
if pain_flavor in ACCEPTED_PAIN_FLAVOURS:
attrib = {
"{http://www.w3.org/2001/XMLSchema-instance}"
"schemaLocation": "http://www.six-interbank-clearing.com/de/"
"%s.xsd %s.xsd" % (pain_flavor, pain_flavor)
"{http://www.w3.org/2001/XMLSchema-instance}"
"schemaLocation": "http://www.six-interbank-clearing.com/de/%s.xsd %s.xsd"
% (pain_flavor, pain_flavor)
}
return attrib
else:
Expand All @@ -62,5 +63,8 @@ def generate_remittance_info_block(self, parent_node, line, gen_args):
creditor_ref_info_type_code.text = "QRR"
creditor_reference = etree.SubElement(creditor_ref_information, "Ref")
creditor_reference.text = line.payment_line_ids[0].communication
# to uncomment when schema pain.001.001.09.ch.03 is implemented in account_banking_pain_base
# remittance_info_structured = etree.SubElement(remittance_info, "AddtlRmtInf")
# remittance_info_structured.text = line.payment_line_ids[0].move_line_id.move_id.ref or ""
else:
super().generate_remittance_info_block(parent_node, line, gen_args)
23 changes: 0 additions & 23 deletions l10n_ch_pain_direct_debit/models/account_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,6 @@ def generate_payment_file(self):

return res

def generate_pain_nsmap(self):
self.ensure_one()
nsmap = super().generate_pain_nsmap()
pain_flavor = self.payment_mode_id.payment_method_id.pain_version
if pain_flavor in ACCEPTED_PAIN_FLAVOURS:
nsmap[None] = (
"http://www.six-interbank-clearing.com/de/%s.xsd" % pain_flavor
)
return nsmap

def generate_pain_attrib(self):
self.ensure_one()
pain_flavor = self.payment_mode_id.payment_method_id.pain_version
if pain_flavor in ACCEPTED_PAIN_FLAVOURS:
attrib = {
"{http://www.w3.org/2001/XMLSchema-instance}"
"schemaLocation": "http://www.six-interbank-clearing.com/de/%s.xsd %s.xsd"
% (pain_flavor, pain_flavor)
}
else:
attrib = super().generate_pain_attrib()
return attrib

@api.model
def _must_have_initiating_party(self, gen_args):
if gen_args.get("pain_flavor") in ACCEPTED_PAIN_FLAVOURS:
Expand Down

0 comments on commit 54b8653

Please sign in to comment.