Add invoice date on credit wizard

issue8925
review264931002
This commit is contained in:
Cédric Krier
2020-01-24 00:23:28 +01:00
parent 300361bd90
commit 94503a41df
4 changed files with 12 additions and 5 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add invoice date on credit wizard
* Take lines without maturity date as payable
Version 5.4.0 - 2019-11-04
+8 -5
View File
@@ -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:
+1
View File
@@ -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
+2
View File
@@ -9,5 +9,7 @@ this repository contains the full copyright notices and license terms. -->
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>