[FIX] l10n_ch: avoid warning about not stored of l10n_ch_isr_number_spaced
two compute field have same method but one is store and other one is non store so we split compute method for both fields(l10n_ch_isr_number,l10n_ch_isr_number_spaced) closes odoo/odoo#40970 X-original-commit: d7a2d4aca37647ae568a5bb9f515ce2138245878 Signed-off-by: Josse Colpaert <jco@openerp.com>
This commit is contained in:
committed by
Josse Colpaert
parent
0940bfcfd5
commit
441759a5f1
@@ -19,7 +19,7 @@ class AccountMove(models.Model):
|
||||
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.")
|
||||
l10n_ch_isr_number_spaced = fields.Char(compute='_compute_l10n_ch_isr_number_spaced', help="ISR number split in blocks of 5 characters (right-justified), to generate ISR report.")
|
||||
|
||||
l10n_ch_isr_optical_line = fields.Char(compute="_compute_l10n_ch_isr_optical_line", help='Optical reading line, as it will be printed on ISR')
|
||||
|
||||
@@ -71,6 +71,19 @@ class AccountMove(models.Model):
|
||||
this number with zeros. The last character of the ISR number is the result
|
||||
of a recursive modulo 10 on its first 26 characters.
|
||||
"""
|
||||
for record in self:
|
||||
if record.name and record.invoice_partner_bank_id and record.invoice_partner_bank_id.l10n_ch_postal:
|
||||
invoice_issuer_ref = record.invoice_partner_bank_id.l10n_ch_postal.ljust(l10n_ch_ISR_NUMBER_ISSUER_LENGTH, '0')
|
||||
invoice_ref = re.sub('[^\d]', '', record.name)
|
||||
#We only keep the last digits of the sequence number if it is too long
|
||||
invoice_ref = invoice_ref[-l10n_ch_ISR_NUMBER_ISSUER_LENGTH:]
|
||||
internal_ref = invoice_ref.zfill(l10n_ch_ISR_NUMBER_LENGTH - l10n_ch_ISR_NUMBER_ISSUER_LENGTH - 1) # -1 for mod10r check character
|
||||
record.l10n_ch_isr_number = mod10r(invoice_issuer_ref + internal_ref)
|
||||
else:
|
||||
record.l10n_ch_isr_number = False
|
||||
|
||||
@api.depends('l10n_ch_isr_number')
|
||||
def _compute_l10n_ch_isr_number_spaced(self):
|
||||
def _space_isr_number(isr_number):
|
||||
to_treat = isr_number
|
||||
res = ''
|
||||
@@ -83,17 +96,11 @@ class AccountMove(models.Model):
|
||||
|
||||
for record in self:
|
||||
if record.name and record.invoice_partner_bank_id and record.invoice_partner_bank_id.l10n_ch_postal:
|
||||
invoice_issuer_ref = record.invoice_partner_bank_id.l10n_ch_postal.ljust(l10n_ch_ISR_NUMBER_ISSUER_LENGTH, '0')
|
||||
invoice_ref = re.sub('[^\d]', '', record.name)
|
||||
#We only keep the last digits of the sequence number if it is too long
|
||||
invoice_ref = invoice_ref[-l10n_ch_ISR_NUMBER_ISSUER_LENGTH:]
|
||||
internal_ref = invoice_ref.zfill(l10n_ch_ISR_NUMBER_LENGTH - l10n_ch_ISR_NUMBER_ISSUER_LENGTH - 1) # -1 for mod10r check character
|
||||
record.l10n_ch_isr_number = mod10r(invoice_issuer_ref + internal_ref)
|
||||
record.l10n_ch_isr_number_spaced = _space_isr_number(record.l10n_ch_isr_number)
|
||||
else:
|
||||
record.l10n_ch_isr_number = False
|
||||
record.l10n_ch_isr_number_spaced = False
|
||||
|
||||
|
||||
@api.depends(
|
||||
'currency_id.name', 'amount_total', 'name',
|
||||
'invoice_partner_bank_id.l10n_ch_postal',
|
||||
|
||||
Reference in New Issue
Block a user