[FIX] website_quote: old api on_change_product_id
The old api on_change_product_id function in model 'sale.order.option'
doesn't receive the order_id to compute correctly the price unit for
suggested products. The new api _onchange_product_id function has exactly
the same logic as on_change_product_id and this function receives the order_id.
Then the new one can replace the old one. But to keep the compatibility with partners
who overwrite this old function, it is kept in the code.
This bug was introduced by 5047f4e, this commit defined the product_uom_change function
which called on_change_product_id. This commit was applied in saas-6.
The onchange calls in the views have be removed because all the new api onchange are called
even if they were still there.
opw:656494
This commit is contained in:
@@ -405,14 +405,17 @@ class sale_order_option(osv.osv):
|
||||
domain = {'uom_id': [('category_id', '=', product_obj.uom_id.category_id.id)]}
|
||||
return {'value': vals, 'domain': domain}
|
||||
|
||||
# TODO master: to remove, replaced by onchange of the new api
|
||||
def product_uom_change(self, cr, uid, ids, product, uom_id, context=None):
|
||||
context = context or {}
|
||||
if not uom_id:
|
||||
return {'value': {'price_unit': 0.0, 'uom_id': False}}
|
||||
return self.on_change_product_id(cr, uid, ids, product, uom_id=uom_id, context=context)
|
||||
|
||||
@api.onchange('product_id')
|
||||
@api.onchange('product_id', 'uom_id')
|
||||
def _onchange_product_id(self):
|
||||
if not self.product_id:
|
||||
return
|
||||
product = self.product_id.with_context(lang=self.order_id.partner_id.lang)
|
||||
self.price_unit = product.list_price
|
||||
self.website_description = product.quote_description or product.website_description
|
||||
@@ -424,6 +427,10 @@ class sale_order_option(osv.osv):
|
||||
partner_id = self.order_id.partner_id.id
|
||||
pricelist = self.order_id.pricelist_id.id
|
||||
self.price_unit = self.order_id.pricelist_id.price_get(product.id, self.quantity, partner_id)[pricelist]
|
||||
if self.uom_id and self.uom_id != self.product_id.uom_id:
|
||||
self.price_unit = self.product_id.uom_id._compute_price(self.price_unit, self.uom_id.id)
|
||||
domain = {'uom_id': [('category_id', '=', self.product_id.uom_id.category_id.id)]}
|
||||
return {'domain': domain}
|
||||
|
||||
|
||||
class product_template(osv.Model):
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<field name="product_id"/>
|
||||
<field name="name"/>
|
||||
<field name="quantity"/>
|
||||
<field name="uom_id" groups="product.group_uom" on_change="product_uom_change(product_id, uom_id)"/>
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="discount" groups="sale.group_discount_per_so_line"/>
|
||||
<field name="website_description" invisible="1"/>
|
||||
@@ -118,10 +118,10 @@
|
||||
<page string="Suggested Products">
|
||||
<field name="options">
|
||||
<tree string="Sales Quotation Template Lines" editable="bottom">
|
||||
<field name="product_id" on_change="on_change_product_id(product_id, uom_id)"/>
|
||||
<field name="product_id"/>
|
||||
<field name="name"/>
|
||||
<field name="quantity"/>
|
||||
<field name="uom_id" groups="product.group_uom" on_change="product_uom_change(product_id, uom_id)"/>
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="discount" groups="sale.group_discount_per_so_line"/>
|
||||
<field name="website_description" invisible="1"/>
|
||||
|
||||
Reference in New Issue
Block a user