gpt4 book ai didi

python - Odoo 10 如何将字段数据从 sale.order 传递到 stock.picking

转载 作者:太空宇宙 更新时间:2023-11-03 14:23:52 25 4
gpt4 key购买 nike

我在销售订单标题中有一个字段,需要将这些字段值传递给选货。我们如何在 odoo 10 中做到这一点大家可以帮忙吗

最佳答案

对于这个问题你可以创建一个新模块并在按钮中添加此功能

def action_create_pq(self, cr, uid, ids, context=None):
i = 0
seller_ids = []
po_id = {}
for sale in self.browse(cr, uid, ids, context=context):
l_ids = self.pool.get('sale.order.line').search(cr, uid, [('order_id', '=', sale.id)])
for line in self.pool.get('sale.order.line').browse(cr, uid, l_ids, context=context):
if line.product_id.seller_ids.id:
product = line.product_id.id
qty = line.product_id.seller_ids.min_qty
price = line.product_id.seller_ids.price
partner_id = line.product_id.seller_ids.name.id
uom = line.product_uom.id
date_order = time.strftime('%Y-%m-%d')

if partner_id not in seller_ids:
seller_ids.extend([partner_id])
po_id[partner_id] = self.pool.get('purchase.order').create(cr, uid, {
'origin': sale.name,
'date_order': date_order,
'partner_id': partner_id,
'pricelist': line.price_unit,
'state': 'draft',
'shipped': 0,
'invoice_method': 'order',
'invoiced': 0,
'company_id': self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', context=None),
})


po_line_id = self.pool.get('purchase.order.line').create(cr, uid, {
'order_id': po_id[partner_id],
'name': line.name,
'product_id': product,
'product_qty': qty,
'state': 'draft',
'invoiced': 0,
'partner_id': partner_id,
'date_order': date_order,
'product_uom': uom,
'price_unit': price,
'date_planned': date_order,
})

return True;

关于python - Odoo 10 如何将字段数据从 sale.order 传递到 stock.picking,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47766438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com