Skip to content

Commit

Permalink
add QRR field and QRR in the pain message
Browse files Browse the repository at this point in the history
  • Loading branch information
Elico Corp - Odoo Docker committed Nov 24, 2020
1 parent d56e919 commit 85a93e8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
12 changes: 9 additions & 3 deletions l10n_ch_pain_base/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models, api

import logging
_logger = logging.getLogger(__name__)

class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
Expand All @@ -11,8 +12,13 @@ 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'
_logger.info('PREPARE '+self.invoice_id.partner_bank_id.sanitized_acc_number[4:6])
if self.invoice_id.partner_bank_id.sanitized_acc_number[4:6] in ['30', '31'] \
and self.invoice_id.partner_bank_id.acc_type == 'iban':
vals['communication_type'] = 'qrr'
else:
vals['local_instrument'] = 'CH01'
vals['communication_type'] = 'isr'
if vals['communication']:
vals['communication'] = vals['communication'].replace(' ', '')
return vals
2 changes: 1 addition & 1 deletion l10n_ch_pain_base/models/account_payment_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
22 changes: 22 additions & 0 deletions l10n_ch_pain_base/models/account_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 85a93e8

Please sign in to comment.