def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom,
partner_id, date_order=False, fiscal_position=False, date_planned=False,
- name=False, price_unit=False, notes=False):
+ name=False, price_unit=False, notes=False, context=None):
+ if not context:
+ context = {}
if not pricelist:
raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist or a supplier in the purchase form !\nPlease set one before choosing a product.'))
if not partner_id:
lang=False
if partner_id:
lang=self.pool.get('res.partner').read(cr, uid, partner_id, ['lang'])['lang']
- context={'lang':lang}
- context['partner_id'] = partner_id
-
+
+ context_partner = {'lang':lang, 'partner_id': partner_id}
prod = self.pool.get('product.product').browse(cr, uid, product, context=context)
prod_uom_po = prod.uom_po_id.id
if not uom:
qty = qty or 1.0
seller_delay = 0
- prod_name = self.pool.get('product.product').name_get(cr, uid, [prod.id], context=context)[0][1]
+ prod_name = self.pool.get('product.product').name_get(cr, uid, [prod.id], context=context_partner)[0][1]
res = {}
for s in prod.seller_ids:
if s.name.id == partner_id:
def product_uom_change(self, cr, uid, ids, pricelist, product, qty, uom,
partner_id, date_order=False, fiscal_position=False, date_planned=False,
- name=False, price_unit=False, notes=False):
+ name=False, price_unit=False, notes=False, context=None):
res = self.product_id_change(cr, uid, ids, pricelist, product, qty, uom,
partner_id, date_order=date_order, fiscal_position=fiscal_position, date_planned=date_planned,
- name=name, price_unit=price_unit, notes=notes)
+ name=name, price_unit=price_unit, notes=notes, context=context)
if 'product_uom' in res['value']:
if uom and (uom != res['value']['product_uom']) and res['value']['product_uom']:
seller_uom_name = self.pool.get('product.uom').read(cr, uid, [res['value']['product_uom']], ['name'])[0]['name']
<form string="Purchase Order Line">
<notebook colspan="4">
<page string="Order Line">
- <field name="product_id" colspan="4" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_id_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes)"/>
- <field name="product_qty" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_id_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes)"/>
- <field name="product_uom" on_change="product_uom_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes)"/>
+ <field name="product_id" colspan="4" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_id_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/>
+ <field name="product_qty" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_id_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/>
+ <field name="product_uom" on_change="product_uom_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/>
<field colspan="4" name="name"/>
<field name="date_planned" widget="date"/>
<field name="price_unit"/>
partner_obj = self.pool.get('res.partner')
product_obj = self.pool.get('product.product')
if partner_id:
- lang = partner_obj.browse(cr, uid, partner_id).lang
+ partner_lang = partner_obj.browse(cr, uid, partner_id).lang
context = {'lang': lang, 'partner_id': partner_id}
+ context_partner = {'lang': partner_lang, 'partner_id': partner_id}
if not product:
return {'value': {'th_weight': 0, 'product_packaging': False,
result.update({'type': product_obj.procure_method})
if not flag:
- result['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context)[0][1]
+ result['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context_partner)[0][1]
domain = {}
if (not uom) and (not uos):
result['product_uom'] = product_obj.uom_id.id