Skip to content

[8.0][FIX] ActWindow from Python Method after Popup - #846

Merged
moylop260 merged 2 commits into
OCA:8.0from
Maartincm:8.0-act_window_message-python_act
Feb 6, 2018
Merged

moylop260 merged 2 commits into
OCA:8.0from
Maartincm:8.0-act_window_message-python_act

Conversation

@Maartincm

Copy link
Copy Markdown
Contributor

Allow python methods called from an ir.action.act_window.message
action to return window actions without specifying the views
key, as they would be if called from a button defined in xml.
view_mode key is used for creating the views array as it is required anyway.

Problem:

  • After calling a popup message defined like

      confirmation = {
          'type': 'ir.actions.act_window.message',
          'title': conf_vals['title'],
          'message': conf_vals['message'],
          'close_button_title': conf_vals['close_title'],
          'buttons': [
              {
                  'type': 'method',
                  'name': conf_vals['accept_title'],
                  'model': self._name,
                  'method': 'apply_method',
                  'args': [self.ids, expenses.ids],
              }
          ]
      }
      return confirmation
    

the action returned from the method apply_method which was something like

    action = {
        'name': 'Moves',
        'type': 'ir.actions.act_window',
        'res_model': 'account.move',
        'view_type': 'form',
        'view_mode': 'tree,form',
        'target': 'current',
    }

ended up in a JS error.
image

Allow python methods called from an ir.action.act_window.message
action to return window actions without specifying the ``views``
key, as they would be if called from a button defined in xml.
``view_mode`` key is used for creating the views array as it is required anyway

@hbrunn hbrunn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you really want to fix this here instead of the offending button handler, your code should do exactly what the server does: https://github.com/OCA/OCB/blob/8.0/addons/web/controllers/main.py#L373

I personally would be in favor of fixing the method you call.

@hbrunn hbrunn added this to the 8.0 milestone Jan 23, 2018
@Maartincm

Copy link
Copy Markdown
Contributor Author

I used the confirmation popup from a wizard button that was formerly calling my python method, and the action was working ok, but after I call the same method from the popup button itself it does not.
That's why I though it would be nice to fix this problem from here.
I'd be glad to check the backend code and modify this PR. Thank you for the suggestion.

@hbrunn

hbrunn commented Jan 23, 2018

Copy link
Copy Markdown
Member

thanks! I think you have a peculiar way of formatting your code, but given we have no formal conventions about js style, I won't discuss js style

@Maartincm

Copy link
Copy Markdown
Contributor Author

Haha Im a Python programmer, and not even that good to talk about conventions either, but being able to help is always nice 👌

@moylop260
moylop260 merged commit 2c90aba into OCA:8.0 Feb 6, 2018
Maartincm added a commit to Maartincm/web that referenced this pull request May 4, 2018
Pull Request OCA#846 was aimed to allow devs to return window actions from
python code without specifying the views, but introduced a bug when the
action was not of type window. This commit pretends to fix that.
Maartincm added a commit to Maartincm/web that referenced this pull request May 4, 2018
Pull Request OCA#846 was aimed to allow devs to return window actions from
python code without specifying the views, but introduced a bug when the
action was not of type window. This commit pretends to fix that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants