mirror of
https://gitlab.com/flectra-community/bank-payment.git
synced 2024-11-26 07:32:05 +00:00
[IMP] account_banking_pain_base: add needed QRR information to generate correct XML file structure
This commit is contained in:
parent
1fb51dfbad
commit
a10188c7c4
@ -3,7 +3,7 @@
|
|||||||
# Copyright 2021 Tecnativa - Carlos Roca
|
# Copyright 2021 Tecnativa - Carlos Roca
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from flectra import fields, models
|
from flectra import fields, models, api, _
|
||||||
|
|
||||||
|
|
||||||
class AccountPaymentLine(models.Model):
|
class AccountPaymentLine(models.Model):
|
||||||
@ -173,3 +173,19 @@ class AccountPaymentLine(models.Model):
|
|||||||
communication_type = fields.Selection(
|
communication_type = fields.Selection(
|
||||||
selection_add=[("ISO", "ISO")], ondelete={"ISO": "cascade"}
|
selection_add=[("ISO", "ISO")], ondelete={"ISO": "cascade"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def create(self, vals):
|
||||||
|
if vals.get("name", "New") == "New":
|
||||||
|
vals["name"] = (
|
||||||
|
self.env["ir.sequence"].next_by_code("account.payment.line") or "New"
|
||||||
|
)
|
||||||
|
result = super(AccountPaymentLine, self).create(vals)
|
||||||
|
|
||||||
|
# set proper communication type
|
||||||
|
if result.communication.startswith('RF'):
|
||||||
|
result.communication_type = 'SCOR'
|
||||||
|
elif result.partner_bank_id._is_qr_iban():
|
||||||
|
result.communication_type = 'QRR'
|
||||||
|
|
||||||
|
return result
|
||||||
|
@ -12,6 +12,7 @@ from lxml import etree
|
|||||||
from flectra import _, api, fields, models, tools
|
from flectra import _, api, fields, models, tools
|
||||||
from flectra.exceptions import UserError
|
from flectra.exceptions import UserError
|
||||||
from flectra.tools.safe_eval import safe_eval
|
from flectra.tools.safe_eval import safe_eval
|
||||||
|
import flectra.release
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unidecode import unidecode
|
from unidecode import unidecode
|
||||||
@ -397,6 +398,11 @@ class AccountPaymentOrder(models.Model):
|
|||||||
initiating_party = etree.SubElement(parent_node, "InitgPty")
|
initiating_party = etree.SubElement(parent_node, "InitgPty")
|
||||||
initiating_party_name = etree.SubElement(initiating_party, "Nm")
|
initiating_party_name = etree.SubElement(initiating_party, "Nm")
|
||||||
initiating_party_name.text = my_company_name
|
initiating_party_name.text = my_company_name
|
||||||
|
initiating_party_software = etree.SubElement(initiating_party, 'CtctDtls')
|
||||||
|
initiating_party_software_name = etree.SubElement(initiating_party_software, 'Nm')
|
||||||
|
initiating_party_software_name.text = 'Flectra Open Source ERP and CRM'
|
||||||
|
initiating_party_software_version = etree.SubElement(initiating_party_software, 'Othr')
|
||||||
|
initiating_party_software_version.text = 'Version ' + flectra.release.version
|
||||||
initiating_party_identifier = (
|
initiating_party_identifier = (
|
||||||
self.payment_mode_id.initiating_party_identifier
|
self.payment_mode_id.initiating_party_identifier
|
||||||
or self.payment_mode_id.company_id.initiating_party_identifier
|
or self.payment_mode_id.company_id.initiating_party_identifier
|
||||||
@ -635,31 +641,43 @@ class AccountPaymentOrder(models.Model):
|
|||||||
creditor_ref_information, "CdtrRef"
|
creditor_ref_information, "CdtrRef"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if gen_args.get("structured_remittance_issuer", True):
|
if line.communication_type == 'QRR':
|
||||||
creditor_ref_info_type = etree.SubElement(
|
creditor_ref_info_type = etree.SubElement(
|
||||||
creditor_ref_information, "Tp"
|
creditor_ref_information, 'Tp')
|
||||||
)
|
|
||||||
creditor_ref_info_type_or = etree.SubElement(
|
creditor_ref_info_type_or = etree.SubElement(
|
||||||
creditor_ref_info_type, "CdOrPrtry"
|
creditor_ref_info_type, 'CdOrPrtry')
|
||||||
)
|
|
||||||
creditor_ref_info_type_code = etree.SubElement(
|
creditor_ref_info_type_code = etree.SubElement(
|
||||||
creditor_ref_info_type_or, "Cd"
|
creditor_ref_info_type_or, 'Prtry')
|
||||||
)
|
creditor_ref_info_type_code.text = 'QRR'
|
||||||
creditor_ref_info_type_code.text = "SCOR"
|
elif line.communication_type == 'SCOR':
|
||||||
|
creditor_ref_info_type = etree.SubElement(
|
||||||
|
creditor_ref_information, 'Tp')
|
||||||
|
creditor_ref_info_type_or = etree.SubElement(
|
||||||
|
creditor_ref_info_type, 'CdOrPrtry')
|
||||||
|
creditor_ref_info_type_code = etree.SubElement(
|
||||||
|
creditor_ref_info_type_or, 'Cd')
|
||||||
|
creditor_ref_info_type_code.text = 'SCOR'
|
||||||
|
elif gen_args.get('structured_remittance_issuer', True):
|
||||||
|
creditor_ref_info_type = etree.SubElement(
|
||||||
|
creditor_ref_information, 'Tp')
|
||||||
|
creditor_ref_info_type_or = etree.SubElement(
|
||||||
|
creditor_ref_info_type, 'CdOrPrtry')
|
||||||
|
creditor_ref_info_type_code = etree.SubElement(
|
||||||
|
creditor_ref_info_type_or, 'Cd')
|
||||||
|
creditor_ref_info_type_code.text = 'SCOR'
|
||||||
creditor_ref_info_type_issuer = etree.SubElement(
|
creditor_ref_info_type_issuer = etree.SubElement(
|
||||||
creditor_ref_info_type, "Issr"
|
creditor_ref_info_type, 'Issr')
|
||||||
)
|
creditor_ref_info_type_issuer.text = \
|
||||||
creditor_ref_info_type_issuer.text = line.communication_type
|
line.communication_type
|
||||||
|
|
||||||
creditor_reference = etree.SubElement(creditor_ref_information, "Ref")
|
creditor_reference = etree.SubElement(
|
||||||
|
creditor_ref_information, 'Ref')
|
||||||
|
|
||||||
creditor_reference.text = self._prepare_field(
|
creditor_reference.text = \
|
||||||
"Creditor Structured Reference",
|
self._prepare_field(
|
||||||
"line.communication",
|
'Creditor Structured Reference',
|
||||||
{"line": line},
|
'line.communication', {'line': line}, 35,
|
||||||
35,
|
gen_args=gen_args)
|
||||||
gen_args=gen_args,
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
Loading…
Reference in New Issue
Block a user