diff options
| author | Jigar Vaghela <jva@odoo.com> | 2019-11-01 09:06:02 +0000 |
|---|---|---|
| committer | Josse Colpaert <jco@odoo.com> | 2019-11-27 12:56:04 +0000 |
| commit | 441759a5f1362e9da44d1ee04433182de8a36254 (patch) | |
| tree | 545850c5479e148d868a3c4fcd3902f2acd7ebc7 | |
| parent | 0940bfcfd5321e6186fe0346074e62df4ffa6986 (diff) | |
[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>
| -rw-r--r-- | addons/l10n_ch/models/account_invoice.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py index d1a6a58c290..d68d786e12b 100644 --- a/addons/l10n_ch/models/account_invoice.py +++ b/addons/l10n_ch/models/account_invoice.py @@ -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', |
