diff --git a/l10n_ch_pain_base/models/account_move_line.py b/l10n_ch_pain_base/models/account_move_line.py index 3882b42d9..ddb6663a9 100644 --- a/l10n_ch_pain_base/models/account_move_line.py +++ b/l10n_ch_pain_base/models/account_move_line.py @@ -3,7 +3,6 @@ from odoo import models, api - class AccountMoveLine(models.Model): _inherit = 'account.move.line' @@ -11,8 +10,11 @@ class AccountMoveLine(models.Model): def _prepare_payment_line_vals(self, payment_order): vals = super()._prepare_payment_line_vals(payment_order) if self.invoice_id and self.invoice_id._is_isr_reference(): - vals['local_instrument'] = 'CH01' - vals['communication_type'] = 'isr' + if self.invoice_id.partner_bank_id._is_qr_iban(): + vals['communication_type'] = 'qrr' + else: + vals['local_instrument'] = 'CH01' + vals['communication_type'] = 'isr' 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 28cd4c063..a63c28a32 100644 --- a/l10n_ch_pain_base/models/account_payment_line.py +++ b/l10n_ch_pain_base/models/account_payment_line.py @@ -9,7 +9,7 @@ class AccountPaymentLine(models.Model): local_instrument = fields.Selection( selection_add=[('CH01', 'CH01 (ISR)')]) - communication_type = fields.Selection(selection_add=[('isr', 'ISR')]) + communication_type = fields.Selection(selection_add=[('isr', 'ISR'), ('qrr', 'QRR')]) def invoice_reference_type2communication_type(self): res = super().invoice_reference_type2communication_type() diff --git a/l10n_ch_pain_base/models/account_payment_order.py b/l10n_ch_pain_base/models/account_payment_order.py index a8468a326..9a3047e64 100644 --- a/l10n_ch_pain_base/models/account_payment_order.py +++ b/l10n_ch_pain_base/models/account_payment_order.py @@ -127,3 +127,25 @@ def generate_address_block( adrline2.text = ' '.join([partner.zip, partner.city]) return True + + @api.model + def generate_remittance_info_block(self, parent_node, line, gen_args): + if line.communication_type == "qrr": + remittance_info = etree.SubElement( + parent_node, 'RmtInf') + remittance_info_structured = etree.SubElement( + remittance_info, 'Strd') + creditor_ref_information = etree.SubElement( + remittance_info_structured, 'CdtrRefInf') + 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, 'Prtry') + creditor_ref_info_type_code.text = 'QRR' + creditor_reference = etree.SubElement( + creditor_ref_information, 'Ref') + creditor_reference.text = line.payment_line_ids[0].communication + else: + super().generate_remittance_info_block(parent_node, line, gen_args)