Contributors mailing list archives

Browse archives


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

by "Raphaël Valyi" <> - 29/03/2024 03:13:17

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 <> 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 

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.


Your partner for the hard Odoo problems

Post to:

Raphaël Valyi
Founder and consultant