[IMP] sale_stock: do not verify inventory for non-stockable products (sale.order.line onchange)
This commit is contained in:
parent
0c20403744
commit
f1d5dfa85b
|
@ -301,6 +301,7 @@ class sale_order_line(osv.osv):
|
||||||
res['value'].update(res_packing.get('value', {}))
|
res['value'].update(res_packing.get('value', {}))
|
||||||
warning_msgs = res_packing.get('warning') and res_packing['warning']['message'] or ''
|
warning_msgs = res_packing.get('warning') and res_packing['warning']['message'] or ''
|
||||||
|
|
||||||
|
if product_obj.type == 'product':
|
||||||
#determine if the product is MTO or not (for a further check)
|
#determine if the product is MTO or not (for a further check)
|
||||||
isMto = False
|
isMto = False
|
||||||
if warehouse_id:
|
if warehouse_id:
|
||||||
|
@ -323,19 +324,19 @@ class sale_order_line(osv.osv):
|
||||||
|
|
||||||
#check if product is available, and if not: raise a warning, but do this only for products that aren't processed in MTO
|
#check if product is available, and if not: raise a warning, but do this only for products that aren't processed in MTO
|
||||||
if not isMto:
|
if not isMto:
|
||||||
uom2 = False
|
uom_record = False
|
||||||
if uom:
|
if uom:
|
||||||
uom2 = product_uom_obj.browse(cr, uid, uom, context=context)
|
uom_record = product_uom_obj.browse(cr, uid, uom, context=context)
|
||||||
if product_obj.uom_id.category_id.id != uom2.category_id.id:
|
if product_obj.uom_id.category_id.id != uom_record.category_id.id:
|
||||||
uom = False
|
uom_record = False
|
||||||
if not uom2:
|
if not uom_record:
|
||||||
uom2 = product_obj.uom_id
|
uom_record = product_obj.uom_id
|
||||||
compare_qty = float_compare(product_obj.virtual_available, qty, precision_rounding=uom2.rounding)
|
compare_qty = float_compare(product_obj.virtual_available, qty, precision_rounding=uom_record.rounding)
|
||||||
if (product_obj.type=='product') and int(compare_qty) == -1:
|
if compare_qty == -1:
|
||||||
warn_msg = _('You plan to sell %.2f %s but you only have %.2f %s available !\nThe real stock is %.2f %s. (without reservations)') % \
|
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.name,
|
(qty, uom_record.name,
|
||||||
max(0,product_obj.virtual_available), uom2.name,
|
max(0,product_obj.virtual_available), uom_record.name,
|
||||||
max(0,product_obj.qty_available), uom2.name)
|
max(0,product_obj.qty_available), uom_record.name)
|
||||||
warning_msgs += _("Not enough stock ! : ") + warn_msg + "\n\n"
|
warning_msgs += _("Not enough stock ! : ") + warn_msg + "\n\n"
|
||||||
|
|
||||||
#update of warning messages
|
#update of warning messages
|
||||||
|
|
Loading…
Reference in New Issue