I want update a field in stock.picking with a value from sale.order.
in sale.order : 'client_order_ref'.
in stock.picking: I've created a new field 'x_order_description'
my server action code on update:
active_id = context.get('active_id')
sale_obj = self.pool.get('sale.order')
picking_obj = self.pool.get('stock.picking')
picking_ids = picking_obj.search(cr, uid, [('sale_id', '=', active_id)], context=context) #this returns all the pickings!
if picking_ids:
sale_record = self.browse(cr, uid, active_id, context=context)
picking_obj.write(cr, uid, picking_ids, {'x_order_description': sale_record.client_order_ref}, context=context)
the problem:
when updating the full table gets the new value of 'x_order_description', but I want only update the corresponding pickings
you can use the fields.related as like below: class stock_picking(osv.osv): _name = 'stock.picking' _inherit = 'stock.picking' _columns = { 'x_project_id' : fields.related('sale_id','x_project_id',type="char", readonly="True", string="Project ID"), #'x_project_id' : fields.char(string="Project ID"), }