[FIX] account_invoice: due date is reset to current date when we have no payment...
authorAmit Dodiya <ado@tinyerp.com>
Fri, 17 May 2013 05:03:25 +0000 (10:33 +0530)
committerAmit Dodiya <ado@tinyerp.com>
Fri, 17 May 2013 05:03:25 +0000 (10:33 +0530)
bzr revid: ado@tinyerp.com-20130517050325-08798zuz7oun7m05

1  2  3 
addons/account/account_invoice.py

@@@@ -527,10 -527,10 -539,13 +527,15 @@@@ class account_invoice(osv.osv)
   
       def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice):
           res = {}
  -        inv_record = self.browse(cr, uid, ids)
+++        if isinstance(ids, int):
+++            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
  -        if not payment_term_id and inv_record.date_due:
  -            return {'value':{'date_due': inv_record.date_due}} #To make sure the invoice due date should contain due date which is entered by user when there is no payment term defined
  -        if not payment_term_id and not inv_record.date_due:
  -            return {'value':{'date_due': date_invoice}} #To make sure that the invoice due date contain current date when there is no payment term and no due date defined
+++        for invoice_record in self.browse(cr, uid, ids):
+++            if not payment_term_id and invoice_record.date_due:
+++                return {'value':{'date_due': invoice_record.date_due}} #To make sure the invoice due date should contain due date which is entered by user when there is no payment term defined
+++            if not payment_term_id and not invoice_record.date_due:
+++                return {'value':{'date_due': date_invoice}} #To make sure that the invoice due date contain current date when there is no payment term and no due date defined
           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]
               if res and res['value']:
                   self.write(cr, uid, [inv.id], res['value'])
           return True
---
+++    
       def finalize_invoice_move_lines(self, cr, uid, invoice_browse, move_lines):
           """finalize_invoice_move_lines(cr, uid, invoice, move_lines) -> move_lines
           Hook method to be overridden in additional modules to verify and possibly alter the