diff --git a/CHANGELOG b/CHANGELOG index 9560cb5277..07e7756109 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add invoice date on credit wizard * Take lines without maturity date as payable Version 5.4.0 - 2019-11-04 diff --git a/invoice.py b/invoice.py index f57593c318..230694586d 100644 --- a/invoice.py +++ b/invoice.py @@ -1344,11 +1344,11 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): InvoiceReport = Pool().get('account.invoice', type='report') InvoiceReport.execute([self.id], {}) - def _credit(self): + def _credit(self, **values): ''' Return values to credit invoice. ''' - credit = self.__class__() + credit = self.__class__(**values) for field in ('company', 'party', 'invoice_address', 'currency', 'journal', 'account', 'payment_term', 'description', @@ -1360,12 +1360,12 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): return credit @classmethod - def credit(cls, invoices, refund=False): + def credit(cls, invoices, refund=False, **values): ''' Credit invoices and return ids of new invoices. Return the list of new invoice ''' - new_invoices = [i._credit() for i in invoices] + new_invoices = [i._credit(**values) for i in invoices] cls.save(new_invoices) cls.update_taxes(new_invoices) if refund: @@ -2825,6 +2825,7 @@ class PayInvoice(Wizard): class CreditInvoiceStart(ModelView): 'Credit Invoice' __name__ = 'account.invoice.credit.start' + invoice_date = fields.Date("Invoice Date") with_refund = fields.Boolean('With Refund', states={ 'readonly': ~Eval('with_refund_allowed'), @@ -2865,9 +2866,11 @@ class CreditInvoice(Wizard): 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) + credit_invoices = Invoice.credit( + invoices, refund=refund, invoice_date=invoice_date) data = {'res_id': [i.id for i in credit_invoices]} if len(credit_invoices) == 1: diff --git a/tests/scenario_invoice.rst b/tests/scenario_invoice.rst index e747239911..8544d6b657 100644 --- a/tests/scenario_invoice.rst +++ b/tests/scenario_invoice.rst @@ -213,6 +213,7 @@ Credit invoice with refund:: >>> credit = Wizard('account.invoice.credit', [invoice]) >>> credit.form.with_refund = True + >>> credit.form.invoice_date = invoice.invoice_date >>> credit.execute('credit') >>> invoice.reload() >>> invoice.state diff --git a/view/credit_start_form.xml b/view/credit_start_form.xml index 31dd8287ae..51232c0bd2 100644 --- a/view/credit_start_form.xml +++ b/view/credit_start_form.xml @@ -9,5 +9,7 @@ this repository contains the full copyright notices and license terms. --> yalign="0.0" xalign="0.0" xexpand="1"/>