Skip to content

Commit

Permalink
# This is a combination of 4 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

85a93e8

# This is the commit message #2:

use qr_iban validation methode

# This is the commit message #3:

fix commit

# This is the commit message OCA#4:

remove debug info
  • Loading branch information
davidwul authored and ecino committed Oct 19, 2023
1 parent a6fe2c1 commit 5abd66c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
8 changes: 5 additions & 3 deletions l10n_ch_pain_base/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@

from odoo import models, api


class AccountMoveLine(models.Model):
_inherit = 'account.move.line'

@api.multi
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
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 5abd66c

Please sign in to comment.