[FIX] sale: onchange_product_uom
The function "product_uom_change" was built to reset the price unit of a SO line when the uom was changed. Before this fix503820a, the price unit of the SO line only depended on the price list then it was not needed to pass the fiscal position to this function. After this fix503820a, the price unit of a SO line also depends on the taxes set on the SO line(e.g.:if an included tax is deleted, the price unit must be recomputed without this tax). Then to recompute the unit price, the function "product_id_change" must take into account the fiscal position set on the SO to consider the right taxes to recompute the unit price. The fiscal position set on a SO must be passed to onchange_product_uom each time it will be called because the price unit will be recomputed.
This commit is contained in:
@@ -1232,6 +1232,18 @@ class sale_order_line(osv.osv):
|
||||
partner_id=partner_id, lang=lang, update_tax=update_tax,
|
||||
date_order=date_order, context=context)
|
||||
|
||||
def onchange_product_uom(self, cursor, user, ids, pricelist, product, qty=0,
|
||||
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
|
||||
lang=False, update_tax=True, date_order=False, fiscal_position=False, context=None):
|
||||
context = context or {}
|
||||
lang = lang or ('lang' in context and context['lang'])
|
||||
if not uom:
|
||||
return {'value': {'price_unit': 0.0, 'product_uom' : uom or False}}
|
||||
return self.product_id_change(cursor, user, ids, pricelist, product,
|
||||
qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name,
|
||||
partner_id=partner_id, lang=lang, update_tax=update_tax,
|
||||
date_order=date_order, fiscal_position=fiscal_position, context=context)
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)"/>
|
||||
<field name="product_uom" groups="product.group_uom" class="oe_inline oe_no_button"
|
||||
context="{'company_id': parent.company_id}"
|
||||
on_change="product_uom_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, context)"/>
|
||||
on_change="onchange_product_uom(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, parent.fiscal_position, context)"/>
|
||||
</div>
|
||||
<label for="product_uos_qty" groups="product.group_uos"/>
|
||||
<div groups="product.group_uos">
|
||||
@@ -175,7 +175,7 @@
|
||||
on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)"/>
|
||||
<field name="product_uom"
|
||||
context="{'company_id': parent.company_id}"
|
||||
on_change="product_uom_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, context)"
|
||||
on_change="onchange_product_uom(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, parent.fiscal_position, context)"
|
||||
groups="product.group_uom" options='{"no_open": True}'/>
|
||||
<field name="product_uos_qty" groups="product.group_uos" invisible="1"/>
|
||||
<field name="product_uos" string="UoS" groups="product.group_uos" invisible="1"/>
|
||||
|
||||
Reference in New Issue
Block a user