[FIX] website_quote: take suggested product lang from partner

Use the lang from the sale order's partner when updating suggested
product line. To achieve this, the onchange has been replaced by an
onchange of the new api which gives access to all the fields.

closes #7268
opw-643098
This commit is contained in:
Nicolas Lempereur 2015-06-29 09:52:01 +02:00
parent fdb9aa29bf
commit 880c997e12
2 changed files with 15 additions and 1 deletions

View File

@ -19,6 +19,7 @@
#
##############################################################################
from openerp import api
from openerp.osv import osv, fields
import uuid
import time
@ -290,6 +291,8 @@ class sale_order_option(osv.osv):
_defaults = {
'quantity': 1,
}
# TODO master: to remove, replaced by onchange of the new api
def on_change_product_id(self, cr, uid, ids, product, context=None):
vals = {}
if not product:
@ -305,6 +308,17 @@ class sale_order_option(osv.osv):
vals['name'] += '\n'+product_obj.description_sale
return {'value': vals}
@api.onchange('product_id')
def _onchange_product_id(self):
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
self.name = product.name
if product.description_sale:
self.name += '\n' + product.description_sale
self.uom_id = product.product_tmpl_id.uom_id
class product_template(osv.Model):
_inherit = "product.template"

View File

@ -15,7 +15,7 @@
<label string="Optional Products &amp; Services" for="options"/>
<field name="options">
<tree string="Sales Quote Template Lines" editable="bottom">
<field name="product_id" on_change="on_change_product_id(product_id)"/>
<field name="product_id"/>
<field name="name"/>
<field name="quantity"/>
<field name="uom_id" groups="product.group_uom"/>