[IMP] product: name_get matching on commercial_partner_id for suppliers
authorMartin Trigaux <mat@openerp.com>
Thu, 2 Oct 2014 08:12:51 +0000 (10:12 +0200)
committerMartin Trigaux <mat@openerp.com>
Thu, 2 Oct 2014 08:59:18 +0000 (10:59 +0200)
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

addons/product/product.py

index 124ce31..7a36507 100644 (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 = {