odooodoo-8picking

Set sales order fields reference in picking - odoo


I would like to set Sales Team reference in picking directly when sales order confirm and picking is getting created.

But I didn't get enough hint how can I achieve this. Because the method which is called at the time of sales order confirmation is as follow.

def action_button_confirm(self, cr, uid, ids, context=None):
    if not context:
        context = {}
    assert len(ids) == 1, 'This option should only be used for a single id at a time.'
    self.signal_workflow(cr, uid, ids, 'order_confirm')
    if context.get('send_email'):
        self.force_quotation_send(cr, uid, ids, context=context)
    return True

Here there is no any hint how can I pass it to picking ?

Purpose:

My aim is to set sales team reference in picking / shipment.


Solution

  • I got that method from where it create picking. So I have just inherited it and added my code. action_ship_create will always get called at the time of shipment creation from the sales order.

     @api.cr_uid_ids_context
        def action_ship_create(self,cr,uid,ids,context={}):
            result=super(sale_order,self).action_ship_create(cr,uid,ids,context=context)
            for order in self.browse(cr,uid,ids,context=context):
                order.picking_ids.write({'section_id':order.section_id.id})
            return result