问题
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