From 987cd0dd9e13793079c7768d2beaf32183920a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 24 Jun 2020 23:00:48 +0200 Subject: [PATCH] Add with agent option to credit invoice We do not always want to keep the agent on the credit note. issue9407 review301791002 --- invoice.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/invoice.py b/invoice.py index a43c14d968..d69c137206 100644 --- a/invoice.py +++ b/invoice.py @@ -2914,16 +2914,20 @@ class CreditInvoice(Wizard): default['with_refund'] = False return default + @property + def _credit_options(self): + return dict( + refund=self.start.with_refund, + invoice_date=self.start.invoice_date, + ) + def do_credit(self, action): pool = Pool() Invoice = pool.get('account.invoice') - refund = self.start.with_refund - invoice_date = self.start.invoice_date invoices = Invoice.browse(Transaction().context['active_ids']) - credit_invoices = Invoice.credit( - invoices, refund=refund, invoice_date=invoice_date) + credit_invoices = Invoice.credit(invoices, **self._credit_options) data = {'res_id': [i.id for i in credit_invoices]} if len(credit_invoices) == 1: