Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
1208 Vizualizări

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.




Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
mar. 21
2113
1
mai 25
1029
2
nov. 24
2219
4
feb. 24
12415
1
ian. 24
1695