From 41c31b08faea8df4a4b7a4494728af6c1f67585f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 4 Aug 2012 23:48:00 +0200 Subject: [PATCH] FIX the key in the context Add a comment bzr revid: alexis@via.ecp.fr-20120804214800-ktq2yps1meefyx7x --- addons/purchase/stock.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index 084d1052779..27cd8d2f094 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -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):