From 5be3ac1fd08922a25f051263544b6642bb3b8ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lionel=20Sausin=20=28Num=C3=A9rigraphe=29?= Date: Fri, 19 Sep 2014 16:38:31 +0200 Subject: [PATCH] [FIX] sale_stock: use current product's UoM to check availability When selecting a product in a sale.order, the asked quantity is verified against the available quantity. If the user changes the UoM or the onchange from super call changes it, the context should be updated accordingly. Fixes #2559 --- addons/sale_stock/sale_stock.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index d389715e6c1..bc7a6737f07 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -601,6 +601,14 @@ class sale_order_line(osv.osv): res['value'].update({'product_packaging': False}) return res + # set product uom in context to get virtual stock in current uom + if res.get('value', {}).get('product_uom'): + # use the uom changed by super call + context.update({'uom': res['value']['product_uom']}) + elif uom: + # fallback on selected + context.update({'uom': uom}) + #update of result obtained in super function product_obj = product_obj.browse(cr, uid, product, context=context) res['value']['delay'] = (product_obj.sale_delay or 0.0)