我在OPENERP中有“购买供应商”模块的代码。验证购买时,合作伙伴将在产品内的产品供应商中进行转换。
# -*- encoding: utf-8 -*-
from openerp.osv import osv
class purchase_order(osv.Model):
_inherit = "purchase.order"
def wkf_confirm_order(self, cr, uid, ids, context=None):
product_supp_obj = self.pool.get('product.supplierinfo')
company_id = self.pool.get(
'res.users').browse(cr, uid, uid).company_id.id
product_obj = self.pool.get('product.template')
if super(purchase_order, self).wkf_confirm_order(cr, uid, ids,
context=context):
for po in self.browse(cr, uid, ids, context=context):
partner_id = po.partner_id.id
for line in po.order_line:
product_id = line.product_id.product_tmpl_id.id
if not product_supp_obj.search(cr, uid,
[('product_id', '=',
product_id),
('name', '=', partner_id)]):
product_obj.write(cr, uid, [product_id],
{
'seller_ids': [(0, 0,
{'name': partner_id,
'min_qty': 1.0,
'delay': 1,
'sequence': 10,
'product_id':
product_id,
'company_id':
company_id,
'product_uom':
line and
line.product_id and
line.product_id.
uom_id and
line.product_id.
uom_id.id})]})
return True
else:
return False
我想扩展代码,因为创建了供应商,但没有更新,甚至没有从该采购订单创建新价格。我认为对象是'pricelist.partnerinfo',字段是价格(来自产品)。 我可以帮忙吗?
谢谢和问候!