I speak French, so I apologize more for the mistakes in English.
here is the code i wrote:
# I would like to display the field supplier_id of product_id
class sale_order_line(osv.Model):
_name = 'sale.order.line'
_inherit ='sale.order.line'
_columns = {
'supplier_id': fields.many2one('product.supplierinfo', 'Supplier',domain = [('product_id','=','product_tmpl_id')]),
}
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True,
date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
product_obj = self.pool.get('product.product')
partner_obj = self.pool.get('res.partner')
partner = partner_obj.browse(cr, uid, partner_id)
lang = partner.lang
context_partner = {'lang': lang, 'partner_id': partner_id}
res=super(sale_order_line, self).product_id_change(cr, uid, 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, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
#Above lines are going to call the native function and 'res' is going to store the result, so you can change the value right there
product_obj = product_obj.browse(cr, uid, product, context=context_partner)
if not flag:
res['value']['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context_partner)[0][1]
if product_obj.description_sale:
res['value']['name'] = product_obj.description_sale
return res
sale_order_line()
Help me please