更新/创建从采购订单到产品开启程序的价格

2024-04-26 03:15:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我有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

我想扩展代码,因为创建了供应商,但是没有更新,甚至没有从该采购订单创建新价格。我认为目标是价格表.partnerinfo'字段是price(来自产品)。 我能帮忙吗?在

谢谢和问候!在


Tags: selfidobjidspartneruid产品context