[FIX] sale: fix incorrect on_change on sale.order.line resetting the UoM field + added test

lp bug: https://launchpad.net/bugs/1082409 fixed

bzr revid: odo@openerp.com-20130131184356-y9ck1dr31nlsp73r
This commit is contained in:
Olivier Dony
2013-01-31 19:43:56 +01:00
parent 9b3e333d67
commit ec9859e0a0
2 changed files with 20 additions and 1 deletions
-1
View File
@@ -926,7 +926,6 @@ class sale_order_line(osv.osv):
elif uom: # whether uos is set or not
default_uom = product_obj.uom_id and product_obj.uom_id.id
q = product_uom_obj._compute_qty(cr, uid, uom, qty, default_uom)
result['product_uom'] = default_uom
if product_obj.uos_id:
result['product_uos'] = product_obj.uos_id.id
result['product_uos_qty'] = qty * product_obj.uos_coeff
+20
View File
@@ -14,3 +14,23 @@
!assert {model: sale.order, id: sale.sale_order_test1, string: The onchange function of product was not correctly triggered}:
- order_line[0].name == u'[LCD17] 17\u201d LCD Monitor'
- order_line[0].price_unit == 1350.0
- order_line[0].product_uom_qty == 8
- order_line[0].product_uom.id == ref('product.product_uom_unit')
-
I create another sale order
-
!record {model: sale.order, id: sale_order_test2}:
partner_id: base.res_partner_2
order_line:
- product_id: product.product_product_7
product_uom_qty: 16
product_uom: product.product_uom_dozen
-
I verify that the onchange was correctly triggered
-
!assert {model: sale.order, id: sale.sale_order_test2, string: The onchange function of product was not correctly triggered}:
- order_line[0].name == u'[LCD17] 17\u201d LCD Monitor'
- order_line[0].price_unit == 1350.0 * 12
- order_line[0].product_uom.id == ref('product.product_uom_dozen')
- order_line[0].product_uom_qty == 16