コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5309 ビュー

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?

アバター
破棄

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


最善の回答

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

アバター
破棄
著作者

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

関連投稿 返信 ビュー 活動
2
3月 22
4270
0
1月 23
2158
0
9月 22
1968
0
7月 22
2299
0
2月 22
5255