From 8d7d2aeef30567eae47043a720d17aab8aa14cb6 Mon Sep 17 00:00:00 2001 From: Hardik Prajapati Date: Fri, 30 Aug 2019 05:10:14 +0000 Subject: [PATCH] [IMP] l10n_ch: treat BVR number as structured communication Now, Swiss users can auto populate BVR number generated for invoice in it's 'Payment Ref.' field by simply configure it in 'Communication Standard' of invoice's journal. task: 1999530 closes odoo/odoo#36253 Signed-off-by: Josse Colpaert --- addons/l10n_ch/models/account_invoice.py | 14 ++++++++++++++ addons/l10n_ch/models/account_journal.py | 1 + 2 files changed, 15 insertions(+) diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py index b8982977552..ec2a94abef9 100644 --- a/addons/l10n_ch/models/account_invoice.py +++ b/addons/l10n_ch/models/account_invoice.py @@ -185,3 +185,17 @@ class AccountInvoice(models.Model): if self.env.context.get('l10n_ch_mark_isr_as_sent'): self.filtered(lambda inv: not inv.l10n_ch_isr_sent).write({'l10n_ch_isr_sent': True}) return super(AccountInvoice, self.with_context(mail_post_autofollow=True)).message_post(**kwargs) + + def _get_reference_ch_invoice(self): + """ This sets ISR reference number which is generated based on customer's `Bank Account` and set it as + `Payment Reference` of the invoice when invoice's journal is using Switzerland's communication standard + """ + self.ensure_one() + return self.l10n_ch_isr_number_spaced + + def _get_reference_ch_partner(self): + """ This sets ISR reference number which is generated based on customer's `Bank Account` and set it as + `Payment Reference` of the invoice when invoice's journal is using Switzerland's communication standard + """ + self.ensure_one() + return self.l10n_ch_isr_number_spaced diff --git a/addons/l10n_ch/models/account_journal.py b/addons/l10n_ch/models/account_journal.py index a42e163a299..85646dfa396 100644 --- a/addons/l10n_ch/models/account_journal.py +++ b/addons/l10n_ch/models/account_journal.py @@ -14,6 +14,7 @@ class AccountJournal(models.Model): # creation of bank journals by giving the account number, allow craetion of the l10n_ch_postal = fields.Char(related='bank_account_id.l10n_ch_postal', readonly=False) + invoice_reference_model = fields.Selection(selection_add=[('ch', 'Switzerland')]) @api.model def create(self, vals):