在odoo中的选股中添加送货地址字段

Add shipping address field in stock picking in odoo

当我们从 sale order conform sale 时,它会在 all transfer 中生成 stock picking 并自动传递一些字段,例如 oder id 作为源文档、合作伙伴 ID 和stock picking 的其他事情现在我想与他们一起传输另一个字段,即 partner_shipping_id 字段的地址。 有人请告诉我我该怎么做。我会非常感激...

以下方法可以解决您的问题。

1.Set py 中 sale.order 和 stock.pirking 的自定义字段以及视图端。
2.Inherit 自定义模块中的 stock.move 并使用 _prepare_picking_assign() 覆盖方法。
3.Using super 并设置您的自定义字段值。
4.View 确认销售订单文件后更改。

例如:

from openerp import models, fields, api, _

class sale_order(models.Model):
    _inherit='sale.order'
    customer_field=fields.Char(string='Customer Field')

class stock_picking(models.Model):
    _inherit='stock.picking'
    customer_field=fields.Char(string='Customer Field')    

class stock_move(models.Model):
    _inherit='stock.move'

def _prepare_picking_assign(self,cr, uid, move, context=None):
    res=super(stock_move,self)._prepare_picking_assign(cr, uid, move, context)
    if move.procurement_id and move.procurement_id.sale_line_id and move.procurement_id.sale_line_id.order_id:
        sale_obj = move.procurement_id.sale_line_id.order_id
        if sale_obj.dif_pick_address:
            res.update({
                'customer_field':sale_obj.customer_field,
            })
    return res   

以上代码在 Odoo 8.0 版本中运行良好

另外,您应该在视图部分进行设置,以便您可以在确认销售订单后查看进入库存的销售订单价值。

希望我的回答对您有所帮助:)