From 9cf14197ac575cbbca08687bc2815edd364e19f3 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 29 Apr 2014 14:42:56 +0200 Subject: [PATCH] [FIX] stock: recompute the qty_available based on the location instead of using the one in the result of the browse (opw 606423) The qty_available field is a function field that uses the information of the context (eg: location) to compute the value. Using the global browse record would return the same qty_available value for each location (and then produce way too many account.move) bzr revid: mat@openerp.com-20140429124256-ljph37kijosg5dqb --- addons/stock/product.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/stock/product.py b/addons/stock/product.py index 06f9c36332e..5db1e1b3164 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -105,7 +105,9 @@ class product_product(osv.osv): 'compute_child': False }) - qty = product.qty_available + # qty_available depends of the location in the context + qty = self.read(cr, uid, [product.id], ['qty_available'], context=c)[0]['qty_available'] + diff = product.standard_price - new_price if not diff: raise osv.except_osv(_('Error!'), _("No difference between standard price and new price!")) if qty: