Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0] groups attribute is ignored in list view with the states attribute #99770

Open
adrienpeiffer opened this issue Sep 7, 2022 · 7 comments

Comments

@adrienpeiffer
Copy link
Contributor

adrienpeiffer commented Sep 7, 2022

Impacted versions:

15.0

Groups attributes are evaluated here :

self._apply_groups(node, name_manager, node_info)

Basically, if the user hasn't the requested group, invisible is set to true in the modifiers dict

node_info['modifiers']['invisible'] = True

states attributes are evaluated just after. Basially, if invisible already exists and is not an instance of a list, Odoo just replace the value in invisible by the domain related to the states attribute.

modifiers['invisible'] = [('state', 'not in', node.get('states').split(','))]

Conclusion :

If the user hasn't the requested group but if the object is in the states requested by the states attribute, the node is displayed to the user in the list view.

Video/Screenshot link (optional):

An exemple in the time off module : https://youtu.be/fNzzJiP2S8Q

Support ticket number submitted via odoo.com/help (optional): OPW #2976708

@yelizariev
Copy link
Contributor

It looks as a bug indeed.

The view from the video:

<button string="Validate" name="action_validate" type="object"
icon="fa-check"
states="validate1"
groups="hr_holidays.group_hr_holidays_manager"/>
<button string="Refuse" name="action_refuse" type="object"
icon="fa-times"
states="confirm,validate1"
groups="hr_holidays.group_hr_holidays_manager"/>

@yelizariev
Copy link
Contributor

yelizariev commented Sep 13, 2022

This problem is fixed in master (v16), where groups are applied at the last moment: 1744870

Potential solution for v15 could be changing order of calls _apply_groups and transfer_node_to_modifiers.

self._apply_groups(node, name_manager, node_info)
transfer_node_to_modifiers(node, node_info['modifiers'], self._context)

However, it will change visibility of existing views, which is not something that users may expect. Imagine a company with a "Time off officier" user. They do Validation without knowing that they need Administrator access level for that. Then one day they open Time Off menu and find no Validate/Refuse buttons.

For this reason we can't fix it in stable. If you need to use states with groups in your custom modules, you should try some workarounds (e.g. add such buttons via extension view with field groups_id)

PS I'd keep this issue open to track this issue, post more info on workarounds, etc.

@adrienpeiffer
Copy link
Contributor Author

adrienpeiffer commented Sep 13, 2022

Yes, It'll change the visibility of existing views because it's the bug. For the moment, the user which hasn't the right to validate the leave can do it because of this bug. You cannot assume that users consider the bug as a default behavior.

@yelizariev
Copy link
Contributor

I ask my colleagues to review my conclusion.

@nle-odoo ?

@adrienpeiffer
Copy link
Contributor Author

Replace states attribute by attrs should make the job. Please fix it.

@Malek907
Copy link

Hello , any news about this bug ?

@Malek907
Copy link

@Yenthe666 Can you check this bug please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants