Skip to Content
Menu
This question has been flagged
1 Reply
3622 Views

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?

Avatar
Discard

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', }


Best Answer

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

Avatar
Discard
Author

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

Related Posts Replies Views Activity
2
Mar 22
2776
0
Jan 23
1196
0
Sep 22
966
0
Jul 22
1366
0
Feb 22
3962