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

I have created wizard with target new.


<field name="target">new</field>

In wizard python code, I have wizard_action_send() that is triggered after clicking wizard confirm button is clicked.


How can I programmatically call wizard_action_send() when wizard is opened, without clicking wizard confirm button?

Awatar
Odrzuć

if this wizard is being open on click of any button then you can trigger that method from the same method along with returning of wizard action.

def your_method():
# your function process
...
    # calling wizard
view_id = self.env.ref('wizard_id').id
return {
'name':_("Display Name") 'view_mode': 'form', 'view_id': view_id 'view_type': 'form', 'res_model': 'object name' 'type': 'ir.actions.act_window', 'target': 'new', }


Najlepsza odpowiedź

You can override the init methods of the main parent class "models.BaseModel" witch is used by the TransientModel and call your method there :

1) view_init
@api.model
def view_init(self, fields_list):
""" Override this method to do specific things when a form view is
opened. This method is invoked by :meth:`~default_get`.
"""

    self.wizard_action_send()

2) init
def init(self):
""" This method is called after :meth:`~._auto_init`, and may be
overridden to create or modify a model's database schema.
"""
     self.wizard_action_send()



Happy to help :) an upvote will be awesome

Awatar
Odrzuć
Autor

Hi, thanks for response. Is there a method that this opened each time wizard window is opened? And is it possible to override it?

Yes the view_init will by called every time you open the form view of a wizard @Pauilus

Powiązane posty Odpowiedzi Widoki Czynność
2
mar 22
4222
0
sty 23
2083
0
wrz 22
1923
0
lip 22
2250
0
lut 22
5174