[FIX] account_invoice: due date is reset to current date when we have no payment term and due date is manually defined

lp bug: https://launchpad.net/bugs/1102078 fixed

bzr revid: mat@openerp.com-20130724123421-nrd143m3g1a0qa67
This commit is contained in:
Martin Trigaux
2013-07-24 14:34:21 +02:00
+5 -1
View File
@@ -560,10 +560,14 @@ class account_invoice(osv.osv):
def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice):
res = {}
if isinstance(ids, (int, long)):
ids = [ids]
if not date_invoice:
date_invoice = time.strftime('%Y-%m-%d')
if not payment_term_id:
return {'value':{'date_due': date_invoice}} #To make sure the invoice has a due date when no payment term
inv = self.browse(cr, uid, ids[0])
#To make sure the invoice due date should contain due date which is entered by user when there is no payment term defined
return {'value':{'date_due': inv.date_due and inv.date_due or date_invoice}}
pterm_list = self.pool.get('account.payment.term').compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice)
if pterm_list:
pterm_list = [line[0] for line in pterm_list]