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

时间:2017-12-12 06:20:12

标签: python odoo-10 erp

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

1 个答案:

答案 0 :(得分:0)

对于此问题,您可以创建一个新模块并在按钮

中添加此功能
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;