diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 6201e9be162..9ff634a58d3 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -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]