Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
1206 Zobrazení

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šit
Nejlepší odpověď

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šit
Related Posts Odpovědi Zobrazení Aktivita
0
bře 21
2113
1
kvě 25
1028
2
lis 24
2219
4
úno 24
12413
1
led 24
1695