changeset 44cc1e5981e8 in modules/account_invoice:default
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset;node=44cc1e5981e8
description:
        Add invoice date on credit wizard

        issue8925
        review264931002
diffstat:

 CHANGELOG                  |   1 +
 invoice.py                 |  13 ++++++++-----
 tests/scenario_invoice.rst |   1 +
 view/credit_start_form.xml |   2 ++
 4 files changed, 12 insertions(+), 5 deletions(-)

diffs (83 lines):

diff -r ad089e5c7622 -r 44cc1e5981e8 CHANGELOG
--- a/CHANGELOG Mon Jan 20 11:07:12 2020 +0100
+++ b/CHANGELOG Fri Jan 24 00:23:28 2020 +0100
@@ -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 -r ad089e5c7622 -r 44cc1e5981e8 invoice.py
--- a/invoice.py        Mon Jan 20 11:07:12 2020 +0100
+++ b/invoice.py        Fri Jan 24 00:23:28 2020 +0100
@@ -1344,11 +1344,11 @@
         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 @@
         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 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 @@
         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 -r ad089e5c7622 -r 44cc1e5981e8 tests/scenario_invoice.rst
--- a/tests/scenario_invoice.rst        Mon Jan 20 11:07:12 2020 +0100
+++ b/tests/scenario_invoice.rst        Fri Jan 24 00:23:28 2020 +0100
@@ -213,6 +213,7 @@
 
     >>> 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 -r ad089e5c7622 -r 44cc1e5981e8 view/credit_start_form.xml
--- a/view/credit_start_form.xml        Mon Jan 20 11:07:12 2020 +0100
+++ b/view/credit_start_form.xml        Fri Jan 24 00:23:28 2020 +0100
@@ -9,5 +9,7 @@
             yalign="0.0" xalign="0.0" xexpand="1"/>
         <label name="with_refund"/>
         <field name="with_refund"/>
+        <label name="invoice_date"/>
+        <field name="invoice_date"/>
     </group>
 </form>

Reply via email to