Skip to Content
Menu
This question has been flagged
1 Reply
4139 Views

I am new to Odoo development. I am trying to override the default picking validate action to add a shipment booking process to it with a third party shipping delegate. I can see that is done in stock.picking. There is a method action_done changes the status of the picking status to done. So I created a class that extends this stock.picking and have this method like this,

from odoo import api, fields, models
class StockPicking(models.Model):   

 _inherit = 'stock.picking'

 @api.multi

def action_done(self):        

res = super(StockPicking, self).action_done()        

print('BOOKING THE SHIPMENT NOW!!')        

return res


I was wondering what else I need to do to make it use my class as I did not see my model method was executed when I click on the validate button in the picking. 

The other question is about the 2 step picking/packing. I have set up the fulfilment workflow to be 2 step fulfilment, eg, picking -> packing/shipment booking. It seems that the validate button always runs action_done method in the stock.picking. I would like to add a shipment booking only in the packing step. How do I do this? Is this place the best place to add the shipment booking logic? Or how do I tell if that is in picking or in packing step in the code? 

Thanks so much!

Avatar
Discard
Author Best Answer

I forgot to add the class in the model/__init__.py. Once that is done. The method works when the validate button is clicked. 

How to check the phase of this transfer whether it is in picking or packing so it only book the shipment once? 

Avatar
Discard
Author

I think I can retrieve the name of the picking object, if that is WH/PICK/XXXX then that is a picking object. If that is WH/OUT/XXXX, then that is packing object. Then I can book the shipment. I am not sure if that is the right way though.

That'll work fine, as long as nobody changes the sequence codes.

If you want to do it properly, take a look at the picking_type_code on the picking. That will be incoming, outgoing or internal.

Author

I think using the picking_type_id is a more robust approach. Thanks Jake!