FIX the key in the context
authorAlexis de Lattre <alexis@via.ecp.fr>
Sat, 4 Aug 2012 21:48:00 +0000 (23:48 +0200)
committerAlexis de Lattre <alexis@via.ecp.fr>
Sat, 4 Aug 2012 21:48:00 +0000 (23:48 +0200)
Add a comment

bzr revid: alexis@via.ecp.fr-20120804214800-ktq2yps1meefyx7x

addons/purchase/stock.py

index 084d105..27cd8d2 100644 (file)
@@ -61,8 +61,12 @@ class stock_picking(osv.osv):
         if picking.purchase_id:
             invoice_vals['fiscal_position'] = picking.purchase_id.fiscal_position.id
             invoice_vals['payment_term'] = picking.purchase_id.payment_term.id
+            # Fill the date_due on the invoice, for usability purposes.
+            # Note that when an invoice with a payment term is validated, the
+            # date_due is always recomputed from the invoice date and the payment
+            # term.
             if picking.purchase_id.payment_term and context.get('date_inv'):
-                invoice_vals['date_due'] = self.pool.get('account.invoice').onchange_payment_term_date_invoice(cr, uid, [], picking.purchase_id.payment_term.id, context.get('invoice_date'))['value'].get('date_due')
+                invoice_vals['date_due'] = self.pool.get('account.invoice').onchange_payment_term_date_invoice(cr, uid, [], picking.purchase_id.payment_term.id, context.get('date_inv'))['value'].get('date_due')
         return invoice_vals
 
     def get_currency_id(self, cursor, user, picking):