Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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.




Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
mar 21
2113
1
maj 25
1029
2
lis 24
2219
4
lut 24
12415
sale / delivery Rozwiązane
1
sty 24
1695