Create custom field at delivery order (stock.picking.out) which gets its value from sales order

放肆的年华 提交于 2019-12-08 09:01:46

问题


I have a sales order form which contains a custom delivery date field. Now I want to pass the value from delivery date field in sales order to the commitment date field in delivery order (stock.picking.out).

Did we make two columns in both stock.picking and stock.picking.out? And also how can I take the delivery date field value from sales order during the automatic creation of delivery order(at the click of confirm order button).

I am using v7. Thanks in advance


回答1:


I got the answer from the following link. Thanks too much for @Sudhir Arya for helping me.

link

Here is the full code

class StockPicking(orm.Model):
    _inherit = 'stock.picking'

    _columns = {
        'x_commitment_date': fields.date('Commitment Date', help="Committed date for delivery."),
    }

StockPicking()

class StockPickingOut(orm.Model):
    _inherit = 'stock.picking.out'

    def __init__(self, pool, cr):
        super(StockPickingOut, self).__init__(pool, cr)
        self._columns['x_commitment_date'] = self.pool['stock.picking']._columns['x_commitment_date']

StockPickingOut()

class Sale_Order(osv.Model):
    _inherit = 'sale.order'

    def _prepare_order_picking(self, cr, uid, order, context=None):
        vals = super(sale_order, self)._prepare_order_picking(cr, uid, order, context=context)
        vals.update({'x_commitment_date': order.commitment_date})
        return vals

 Sale_Order()


来源:https://stackoverflow.com/questions/25831240/create-custom-field-at-delivery-order-stock-picking-out-which-gets-its-value-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!