[FIX] sale_stock: when checkign the available quantity, do not include uom as it is already present in the context and will be included in the computation of product_obj.virtual_available (opw 607150)

fixing error message that does not match chosen units when not enough stock
This commit is contained in:
Martin Trigaux 2014-05-13 17:02:13 +02:00
commit 7dbfcede36
1 changed files with 5 additions and 5 deletions

View File

@ -618,13 +618,13 @@ class sale_order_line(osv.osv):
res_packing = self.product_packaging_change(cr, uid, ids, pricelist, product, qty, uom, partner_id, packaging, context=context)
res['value'].update(res_packing.get('value', {}))
warning_msgs = res_packing.get('warning') and res_packing['warning']['message'] or ''
compare_qty = float_compare(product_obj.virtual_available * uom2.factor, qty * product_obj.uom_id.factor, precision_rounding=product_obj.uom_id.rounding)
compare_qty = float_compare(product_obj.virtual_available, qty, precision_rounding=uom2.rounding)
if (product_obj.type=='product') and int(compare_qty) == -1 \
and (product_obj.procure_method=='make_to_stock'):
and (product_obj.procure_method=='make_to_stock'):
warn_msg = _('You plan to sell %.2f %s but you only have %.2f %s available !\nThe real stock is %.2f %s. (without reservations)') % \
(qty, uom2 and uom2.name or product_obj.uom_id.name,
max(0,product_obj.virtual_available), product_obj.uom_id.name,
max(0,product_obj.qty_available), product_obj.uom_id.name)
(qty, uom2.name,
max(0,product_obj.virtual_available), uom2.name,
max(0,product_obj.qty_available), uom2.name)
warning_msgs += _("Not enough stock ! : ") + warn_msg + "\n\n"
#update of warning messages