Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
5344 Visninger

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
Kassér

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


Bedste svar

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
Kassér
Forfatter

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 Besvarelser Visninger Aktivitet
2
mar. 22
4312
0
jan. 23
2178
0
sep. 22
1992
0
jul. 22
2321
0
feb. 22
5294