Skip to Content
Menu
This question has been flagged
1 Odpoveď
1199 Zobrazenia

Hi community, I am a bit new to Odoo development.


I am trying to modify the create() method of the stock.picking model, because I need to insert a new data in a field called pick-up date. 


I need this new field to be filled at the moment of confirming the sales order, because this is the moment when the picks are generated (when pressing the confirm button).


That button executes the action_confirm method in the sale.order model, which in turn executes the private _action_confirm method, I have discovered that this last method is the one that triggers the create method of stock.picking, however I can't find where and how. Because it only needs _action_confirm to exist, even though it doesn't do anything, I have tried:


def _action_confirm(self):

pass


And inside action_confirm, just call it:


self._action_confirm(),


However, I can't see at what point the create method of stock.picking is instantiated.


If the _action_confirm method is not called in action_confirm, neither is the create method of stock.picking, just call it, even if it does nothing


I hope you understand my problem, I don't know if I'm doing the right analysis or I'm just complicating my existence.




Avatar
Zrušiť
Best Answer

You can modify the create() method of the stock.picking model like this,


class CustomStockPicking(models.Model): 

_inherit = 'stock.picking' 

@api.model 

def create(self, vals): 

  ​picking = super(CustomStockPicking, self).create(vals) 

​# Add new data you needed 

​# You can also check it contain sale.order[sale_id] or not 

​return picking

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
0
mar 21
2112
1
máj 25
1028
2
nov 24
2218
4
feb 24
12408
1
jan 24
1694