Skip to Content
Menu
This question has been flagged
2 Replies
6617 Views

Hello,

I return multiple window actions in a function depending on conditions.
When the first window action pop up, i have a yes an no button, when the yes button is clicked, it runs the same function while passing a new context to it, this context prevent the first window action to pop up again and thus the function continue and when it it's find runan other window action return when it find it, but nothing appears in the UI, what is the problem in your opinion?

Avatar
Discard

Can you please show your wizard button code.

Best Answer

Hi,

When you are saying that there is no pop-up appears, then you mean after clicking the button to show the 1st pop-up window then it doesn't appear, or the 2nd one doesn't appear after you click the button? 

- If the 1st pop-up window doesn't appear, then maybe you didn't return an ir.actions.act_window dict or record to be executed. Then the problem is you either return nothing or True in the method which you call using <button name="method_to_be_called" type="object"/>

- If the 2nd pop-up window doesn't appear, then your first act_window is for a wizard or a model view? If the case is wizard, you need to implement the same method in the wizard. If it's a model view then you should consider checking the action['target'] of the act_window (should be 'new' in this case).

Finally, I suggest you to take a look at the documentation for \ir.actions.act_window

Avatar
Discard
Best Answer

The most obvious reason might be in the decorators you use and what you return in your methods. Both should be @api.multi and should return action dict. Something like:

@api.multi
def main_method_return(self):
"""
res should be a dict
"""
self.ensure_one()
# some calculations
if self.context("from_side"):
# some other calculations
return res

@api.multi
def side_method_return(self):
"""
res should be a dict
"""
self.ensure_one()
# link_to_main_model MUST be real record of main model. Not just empty recordset
res = self.link_to_main_model.with_context(from_side=True).main_method_return()
return res
Avatar
Discard