From cfb6b99989c0aacbeab3c13592c7ea8b18440d0b Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 12 Nov 2010 18:37:53 +0530 Subject: [PATCH] [FIX]Purchase:PO Line description doesnt take Supplier Product Name or Code in Products Suppliers Tab lp bug: https://launchpad.net/bugs/671386 fixed bzr revid: ron@tinyerp.com-20101112130753-shfjl1wzjvlwq2kh --- addons/product/product.py | 4 ++-- addons/purchase/purchase.py | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index b43f40b1cbc..1cbd9c9f5bf 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -24,7 +24,7 @@ import decimal_precision as dp import math from _common import rounding -import re +import re from tools.translate import _ def is_pair(x): @@ -649,7 +649,7 @@ class product_supplierinfo(osv.osv): return res and res[0] or False _columns = { - 'name' : fields.many2one('res.partner', 'Supplier', required=True, ondelete='cascade', help="Supplier of this product"), + 'name' : fields.many2one('res.partner', 'Supplier', required=True,domain = [('supplier','=',True)], ondelete='cascade', help="Supplier of this product"), 'product_name': fields.char('Supplier Product Name', size=128, help="This supplier's product name will be used when printing a request for quotation. Keep empty to use the internal one."), 'product_code': fields.char('Supplier Product Code', size=64, help="This supplier's product code will be used when printing a request for quotation. Keep empty to use the internal one."), 'sequence' : fields.integer('Sequence', help="Assigns the priority to the list of product supplier."), diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 5291df7d258..d93a1ec15b1 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -646,6 +646,11 @@ class purchase_order_line(osv.osv): return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or'', 'product_uom' : uom or False}, 'domain':{'product_uom':[]}} prod= self.pool.get('product.product').browse(cr, uid, product) + if prod.product_tmpl_id.seller_ids: + seller_get_id = prod.product_tmpl_id.seller_ids[0].name.id + else: + seller_get_id = False + lang=False if partner_id: lang=self.pool.get('res.partner').read(cr, uid, partner_id, ['lang'])['lang'] @@ -675,8 +680,15 @@ class purchase_order_line(osv.osv): 'date': date_order, })[pricelist] dt = (datetime.now() + relativedelta(days=int(seller_delay) or 0.0)).strftime('%Y-%m-%d %H:%M:%S') - prod_name = self.pool.get('product.product').name_get(cr, uid, [prod.id])[0][1] - + if seller_get_id == partner_id: + prod_suppl_name = self.pool.get('product.product').browse(cr, uid, prod.id).seller_ids[0].product_name + prod_suppl_code = self.pool.get('product.product').browse(cr, uid, prod.id).seller_ids[0].product_code + if prod_suppl_name == False or prod_suppl_code == False: + prod_name = self.pool.get('product.product').name_get(cr, uid, [prod.id])[0][1] + else: + prod_name= '[' + prod_suppl_code + '] '+ prod_suppl_name + else: + prod_name = self.pool.get('product.product').name_get(cr, uid, [prod.id])[0][1] res = {'value': {'price_unit': price, 'name': name or prod_name, 'taxes_id':map(lambda x: x.id, prod.supplier_taxes_id),