[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
This commit is contained in:
Lionel Sausin (Numérigraphe) 2014-09-19 16:38:31 +02:00 committed by Martin Trigaux
parent 717e4106ad
commit 5be3ac1fd0
1 changed files with 8 additions and 0 deletions

View File

@ -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)