[IMP] product: name_get matching on commercial_partner_id for suppliers

The name_get of a product will use some information (e.g. default_code) based on the supplier.
The matching of the supplier should use the commercial_partner_id in case the supplier info are on the company and the partner_id in the context belongs to the company (e.g. creates quotation with a contact of the company).
Fixes #1219
This commit is contained in:
Martin Trigaux 2014-10-02 10:12:51 +02:00
parent e30a5a11a5
commit 78144410a4
1 changed files with 5 additions and 1 deletions

View File

@ -645,10 +645,14 @@ class product_product(osv.osv):
return (d['id'], name)
partner_id = context.get('partner_id', False)
if partner_id:
partner_ids = [partner_id, self.pool['res.partner'].browse(cr, user, partner_id, context=context).commercial_partner_id.id]
else:
partner_ids = []
result = []
for product in self.browse(cr, user, ids, context=context):
sellers = filter(lambda x: x.name.id == partner_id, product.seller_ids)
sellers = partner_ids and filter(lambda x: x.name.id in partner_ids, product.seller_ids) or []
if sellers:
for s in sellers:
mydict = {