Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

Re: Group based editable tree vs form pop up edition?

by "Raphaël Valyi" <rvalyi@akretion.com> - 29/03/2024 03:13:17
Hello,

Thank you Holger, overriding _get_view and using user_has_group absolutely still works in v16!
I tried something like this for instance:
                   if self.user_has_groups('base.group_system'):
                    for sub_form_node in arch.xpath("//field[@name='invoice_line_ids']/tree"):
                        sub_form_node.attrib["editable"] = ""
I initially assumed the result of the method might be cached but fortunately that is not where the cache happens
(I could test with different users). So the change is pretty easy to deal with.

On Wed, Mar 27, 2024 at 3:17 PM Holger Brunn <notifications@odoo-community.org> wrote:
*Do you have an alternative solution to suggest for v16?*

override get_view for your model, and do group specific things there.
Or probably better, override _get_view_cache [1], and also override 
_get_view_cache_key to add 
self.env.user.has_group('the_group.youre_looking_for') or similar to the cache 
key.

I mourned the loss of group-specific view inheritance quite a bit, because you 
can do very nifty things with it. So I'm still of a mind to eventually write 
an addon that brings it back for models with some mixin applied.

[1] https://github.com/OCA/OCB/blob/16.0/odoo/addons/base/models/
ir_ui_view.py#L2635



-- 
Your partner for the hard Odoo problems
https://hunki-enterprises.com

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe



--
Raphaël Valyi
Founder and consultant

Reference