Move ISR subscription fields under res.partner.bank
An Inpayment Slip with Reference (ISR) subscription number is provided by the bank or by Postfinance ISR When the ISR subscription comes from Postfinance it is a direct subscription. ISR (bank) When the ISR subscription comes from a bank it is the bank subscription toward Postfinance. Having the subscription number on res.bank has 2 drawbacks: If you have multiple accounts at Postfinance or If you have multicompany and each company has a Postfinance account you won't be able to emit with different ISR subscriber numbers. This also renames the fields to be accurate on the meaning. An ISR reference is a Payment reference that will apear on the invoice. It is better to name it subscription number. closes odoo/odoo#35873 Signed-off-by: Josse Colpaert <jco@openerp.com>
This commit is contained in:
@@ -15,8 +15,8 @@ l10n_ch_ISR_NUMBER_ISSUER_LENGTH = 12
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
l10n_ch_isr_postal = fields.Char(compute='_compute_l10n_ch_isr_postal', help='The postal reference identifying the bank managing this ISR.')
|
||||
l10n_ch_isr_postal_formatted = fields.Char(compute='_compute_l10n_ch_isr_postal', help="Postal reference of the bank, formated with '-' and without the padding zeros, to generate ISR report.")
|
||||
l10n_ch_isr_subscription = fields.Char(compute='_compute_l10n_ch_isr_subscription', help='ISR subscription number identifying your company or your bank to generate ISR.')
|
||||
l10n_ch_isr_subscription_formatted = fields.Char(compute='_compute_l10n_ch_isr_subscription', help="ISR subscription number your company or your bank, formated with '-' and without the padding zeros, to generate ISR report.")
|
||||
|
||||
l10n_ch_isr_number = fields.Char(compute='_compute_l10n_ch_isr_number', store=True, help='The reference number associated with this invoice')
|
||||
l10n_ch_isr_number_spaced = fields.Char(compute='_compute_l10n_ch_isr_number', help="ISR number split in blocks of 5 characters (right-justified), to generate ISR report.")
|
||||
@@ -28,34 +28,34 @@ class AccountMove(models.Model):
|
||||
l10n_ch_isr_sent = fields.Boolean(default=False, help="Boolean value telling whether or not the ISR corresponding to this invoice has already been printed or sent by mail.")
|
||||
l10n_ch_currency_name = fields.Char(related='currency_id.name', readonly=True, string="Currency Name", help="The name of this invoice's currency") #This field is used in the "invisible" condition field of the 'Print ISR' button.
|
||||
|
||||
@api.depends('invoice_partner_bank_id.bank_id.l10n_ch_postal_eur', 'invoice_partner_bank_id.bank_id.l10n_ch_postal_chf')
|
||||
def _compute_l10n_ch_isr_postal(self):
|
||||
""" Computes the postal reference identifying the bank managing this ISR and formats it accordingly"""
|
||||
def _format_isr_postal(isr_postal):
|
||||
@api.depends('invoice_partner_bank_id.l10n_ch_isr_subscription_eur', 'invoice_partner_bank_id.l10n_ch_isr_subscription_chf')
|
||||
def _compute_l10n_ch_isr_subscription(self):
|
||||
""" Computes the ISR subscription identifying your company or the bank that allows to generate ISR. And formats it accordingly"""
|
||||
def _format_isr_subscription(isr_subscription):
|
||||
#format the isr as per specifications
|
||||
currency_code = isr_postal[:2]
|
||||
middle_part = isr_postal[2:-1]
|
||||
trailing_cipher = isr_postal[-1]
|
||||
currency_code = isr_subscription[:2]
|
||||
middle_part = isr_subscription[2:-1]
|
||||
trailing_cipher = isr_subscription[-1]
|
||||
middle_part = re.sub('^0*', '', middle_part)
|
||||
return currency_code + '-' + middle_part + '-' + trailing_cipher
|
||||
|
||||
def _format_isr_postal_scanline(isr_postal):
|
||||
def _format_isr_subscription_scanline(isr_subscription):
|
||||
# format the isr for scanline
|
||||
return isr_postal[:2] + isr_postal[2:-1].rjust(6, '0') + isr_postal[-1:]
|
||||
return isr_subscription[:2] + isr_subscription[2:-1].rjust(6, '0') + isr_subscription[-1:]
|
||||
|
||||
for record in self:
|
||||
if record.invoice_partner_bank_id and record.invoice_partner_bank_id.bank_id:
|
||||
if record.invoice_partner_bank_id:
|
||||
if record.currency_id.name == 'EUR':
|
||||
isr_postal = record.invoice_partner_bank_id.bank_id.l10n_ch_postal_eur
|
||||
isr_subscription = record.invoice_partner_bank_id.l10n_ch_isr_subscription_eur
|
||||
elif record.currency_id.name == 'CHF':
|
||||
isr_postal = record.invoice_partner_bank_id.bank_id.l10n_ch_postal_chf
|
||||
isr_subscription = record.invoice_partner_bank_id.l10n_ch_isr_subscription_chf
|
||||
else:
|
||||
#we don't format if in another currency as EUR or CHF
|
||||
continue
|
||||
|
||||
if isr_postal:
|
||||
record.l10n_ch_isr_postal = _format_isr_postal_scanline(isr_postal)
|
||||
record.l10n_ch_isr_postal_formatted = _format_isr_postal(isr_postal)
|
||||
if isr_subscription:
|
||||
record.l10n_ch_isr_subscription = _format_isr_subscription_scanline(isr_subscription)
|
||||
record.l10n_ch_isr_subscription_formatted = _format_isr_subscription(isr_subscription)
|
||||
|
||||
@api.depends('name', 'invoice_partner_bank_id.l10n_ch_postal')
|
||||
def _compute_l10n_ch_isr_number(self):
|
||||
@@ -93,8 +93,8 @@ class AccountMove(models.Model):
|
||||
@api.depends(
|
||||
'currency_id.name', 'amount_total', 'name',
|
||||
'invoice_partner_bank_id.l10n_ch_postal',
|
||||
'invoice_partner_bank_id.bank_id.l10n_ch_postal_eur',
|
||||
'invoice_partner_bank_id.bank_id.l10n_ch_postal_chf')
|
||||
'invoice_partner_bank_id.l10n_ch_isr_subscription_eur',
|
||||
'invoice_partner_bank_id.l10n_ch_isr_subscription_chf')
|
||||
def _compute_l10n_ch_isr_optical_line(self):
|
||||
""" The optical reading line of the ISR looks like this :
|
||||
left>isr_ref+ bank_ref>
|
||||
@@ -113,7 +113,7 @@ class AccountMove(models.Model):
|
||||
bank supporting the ISR (including the zeros).
|
||||
"""
|
||||
for record in self:
|
||||
if record.l10n_ch_isr_number and record.l10n_ch_isr_postal and record.currency_id.name:
|
||||
if record.l10n_ch_isr_number and record.l10n_ch_isr_subscription and record.currency_id.name:
|
||||
#Left part
|
||||
currency_code = None
|
||||
if record.currency_id.name == 'CHF':
|
||||
@@ -126,19 +126,19 @@ class AccountMove(models.Model):
|
||||
left = currency_code + amount_ref
|
||||
left = mod10r(left)
|
||||
#Final assembly (the space after the '+' is no typo, it stands in the specs.)
|
||||
record.l10n_ch_isr_optical_line = left + '>' + record.l10n_ch_isr_number + '+ ' + record.l10n_ch_isr_postal + '>'
|
||||
record.l10n_ch_isr_optical_line = left + '>' + record.l10n_ch_isr_number + '+ ' + record.l10n_ch_isr_subscription + '>'
|
||||
|
||||
@api.depends(
|
||||
'type', 'name', 'currency_id.name',
|
||||
'invoice_partner_bank_id.l10n_ch_postal',
|
||||
'invoice_partner_bank_id.bank_id.l10n_ch_postal_eur',
|
||||
'invoice_partner_bank_id.bank_id.l10n_ch_postal_chf')
|
||||
'invoice_partner_bank_id.l10n_ch_isr_subscription_eur',
|
||||
'invoice_partner_bank_id.l10n_ch_isr_subscription_chf')
|
||||
def _compute_l10n_ch_isr_valid(self):
|
||||
"""Returns True if all the data required to generate the ISR are present"""
|
||||
for record in self:
|
||||
record.l10n_ch_isr_valid = record.type == 'out_invoice' and\
|
||||
record.name and \
|
||||
record.l10n_ch_isr_postal and \
|
||||
record.l10n_ch_isr_subscription and \
|
||||
record.invoice_partner_bank_id.l10n_ch_postal and \
|
||||
record.l10n_ch_currency_name in ['EUR', 'CHF']
|
||||
|
||||
|
||||
@@ -23,17 +23,13 @@ def _is_l10n_ch_postal(account_ref):
|
||||
return False
|
||||
|
||||
|
||||
class ResBank(models.Model):
|
||||
_inherit = 'res.bank'
|
||||
|
||||
l10n_ch_postal_chf = fields.Char(string='CHF ISR reference', help='The postal reference of the bank, used to generate ISR payment slips in CHF.')
|
||||
l10n_ch_postal_eur = fields.Char(string='EUR ISR reference', help='The postal reference of the bank, used to generate ISR payment slips in EUR.')
|
||||
|
||||
|
||||
class ResPartnerBank(models.Model):
|
||||
_inherit = 'res.partner.bank'
|
||||
|
||||
l10n_ch_postal = fields.Char(string='ISR reference', help='The ISR number of the company within the bank')
|
||||
l10n_ch_postal = fields.Char(string='Swiss postal account', help='Swiss postal account number eg. 01-162-8')
|
||||
# fields to configure ISR payment slip generation
|
||||
l10n_ch_isr_subscription_chf = fields.Char(string='CHF ISR subscription number', help='The subscription number provided by the bank or Postfinance, used to generate ISR in CHF. eg. 01-162-8')
|
||||
l10n_ch_isr_subscription_eur = fields.Char(string='EUR ISR subscription number', help='The subscription number provided by the bank or Postfinance, used to generate ISR in EUR. eg. 03-162-5')
|
||||
|
||||
@api.model
|
||||
def _get_supported_account_types(self):
|
||||
@@ -136,7 +132,7 @@ class ResPartnerBank(models.Model):
|
||||
t_street_deb = False
|
||||
|
||||
if(currency.name == 'EUR'):
|
||||
return (self.bank_id.l10n_ch_postal_eur and
|
||||
return (self.l10n_ch_postal_subscription_eur and
|
||||
self.company_id.zip and
|
||||
self.company_id.city and
|
||||
self.company_id.country_id.code and
|
||||
@@ -147,7 +143,7 @@ class ResPartnerBank(models.Model):
|
||||
debitor.country_id.code and
|
||||
(number != False) and (number_deb != False))
|
||||
elif(currency.name == 'CHF'):
|
||||
return (self.bank_id.l10n_ch_postal_chf and
|
||||
return (self.l10n_ch_postal_subscription_chf and
|
||||
self.company_id.zip and
|
||||
self.company_id.city and
|
||||
self.company_id.country_id.code and
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
|
||||
<div id="voucher-bank" t-if="not print_bank or not invoice.company_id.l10n_ch_isr_preprinted_account">
|
||||
<!--Konto/Compte/Conto-->
|
||||
<p id="voucher-bank_ref" t-field="invoice.l10n_ch_isr_postal_formatted"/>
|
||||
<p id="voucher-bank_ref" t-field="invoice.l10n_ch_isr_subscription_formatted"/>
|
||||
</div>
|
||||
|
||||
<p id="voucher-amount_units" t-esc="split_total_amount[0]"/>
|
||||
@@ -123,7 +123,8 @@
|
||||
|
||||
<div id="slip-bank" t-if="not print_bank or not invoice.company_id.l10n_ch_isr_preprinted_account">
|
||||
<!--Konto/Compte/Conto-->
|
||||
<p id="slip-bank_ref" t-field="invoice.l10n_ch_isr_postal_formatted"/>
|
||||
<!--aka ISR Subscriber number provided by the financial institution-->
|
||||
<p id="slip-bank_ref" t-field="invoice.l10n_ch_isr_subscription_formatted"/>
|
||||
</div>
|
||||
|
||||
<p id="slip-amount_units" t-esc="split_total_amount[0]"/>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
|
||||
<img class="swissqr" t-att-src="o.invoice_partner_bank_id.build_swiss_code_url(o.amount_residual, o.currency_id.name, o.invoice_date_due, o.partner_id, 'QRR',
|
||||
(o.invoice_partner_bank_id.bank_id.l10n_ch_postal_eur) if (o.invoice_partner_bank_id.currency_id.name == 'EUR') else o.invoice_partner_bank_id.bank_id.l10n_ch_postal_chf,
|
||||
(o.invoice_partner_bank_id.l10n_ch_isr_subscription_chf) if (o.invoice_partner_bank_id.currency_id.name == 'CHF') else o.invoice_partner_bank_id.l10n_ch_isr_subscription_chf,
|
||||
(o.ref) if (o.ref) else o.name)"/>
|
||||
<img class="ch_cross" src="/l10n_ch/static/src/img/CH-Cross_7mm.png"/>
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
|
||||
<span class="swissqr_text title">Reference number</span><br/>
|
||||
<t t-if="o.invoice_partner_bank_id.currency_id.name == 'EUR'">
|
||||
<span class="swissqr_text content" t-field="o.invoice_partner_bank_id.bank_id.l10n_ch_postal_eur"/><br/>
|
||||
<span class="swissqr_text content" t-field="o.invoice_partner_bank_id.l10n_ch_isr_subscription_eur"/><br/>
|
||||
</t>
|
||||
<t t-if="o.invoice_partner_bank_id.currency_id.name == 'CHF'">
|
||||
<span class="swissqr_text content" t-field="o.invoice_partner_bank_id.bank_id.l10n_ch_postal_chf"/><br/>
|
||||
<span class="swissqr_text content" t-field="o.invoice_partner_bank_id.l10n_ch_isr_subscription_chf"/><br/>
|
||||
</t>
|
||||
|
||||
<span class="swissqr_text title">Additional information</span><br/>
|
||||
@@ -68,8 +68,8 @@
|
||||
<div class="swissqr_body" t-if="(o.invoice_partner_bank_id.validate_swiss_code_arguments(o.invoice_partner_bank_id.currency_id, o.partner_id) == False) and ((o.currency_id.name == 'EUR') or (o.currency_id.name == 'CHF'))">
|
||||
<div class="swissqr_column_left procedure_zone">
|
||||
<span>Some pieces of this information are not set correctly to display the Swiss QR Code.<br/>
|
||||
-Bank > CHF ISR reference<br/>
|
||||
-Bank > EUR ISR reference<br/>
|
||||
-Bank > CHF ISR subscription<br/>
|
||||
-Bank > EUR ISR subscription<br/>
|
||||
-Your company > Street with number<br/>
|
||||
-Your company > City<br/>
|
||||
-Your company > Zip<br/>
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="isr_res_bank_form" model="ir.ui.view">
|
||||
<field name="name">l10n_ch.res.bank.form</field>
|
||||
<field name="model">res.bank</field>
|
||||
<field name="inherit_id" ref="base.view_res_bank_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='bic']" position="after">
|
||||
<field name="l10n_ch_postal_chf"/>
|
||||
<field name="l10n_ch_postal_eur"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="isr_partner_bank_form" model="ir.ui.view">
|
||||
<field name="name">l10n_ch.res.partner.bank.form</field>
|
||||
<field name="model">res.partner.bank</field>
|
||||
@@ -20,6 +8,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='acc_number']" position="after">
|
||||
<field name="l10n_ch_postal"/>
|
||||
<field name="l10n_ch_isr_subscription_chf"/>
|
||||
<field name="l10n_ch_isr_subscription_eur"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user