Hello.
We recently encountered the same error on one of our
production databases. After a little bit of analysis, we realized we
were adding a field on the res.users
model and added this field on the inherited form view base.view_users_form_simple_modif
in a custom module.
What happens is that Odoo hr module introduces a new view on the res.users
model to allow any user to visualize any private information on
the employee connected to their user from the “My profile” view and
this new hr view res_users_view_form_simple_modif inherits in
mode primary from the base.view_users_form_simple_modif. Inheriting in
mode primary allows the base view to be extended from other modules but still
add the same edits on the hr extended view.
When the hr module is installed the base view is automatically overridden by the hr view,
res_users_view_form_simple_modif
and looks for which fields are accessible on the res.users model. Thus, res.users
must override the __init__() method to add the field to the list of
readable and writable fields in res.users. How the override of __init__ was done was looked up in the module mail (where it is done way more simply than how it is done in the hr module).
I
suggest having a look at these commits on github relative to
the hr module to better understand why it works like that:
- https://github.com/odoo/odoo/commit/d77ce4c2a92c1da48150e4e84b714dd93f64847d
- https://github.com/odoo/odoo/commit/c9ca3761464413327d2beb697553a3ccd7eef4d1
So our solution was:
res_users.py
new_field = fields.Boolean(string="Our New Field", default=False)
def __init__(self, pool, cr):
# Override of __init__ to add access rights on new_field.
# Access rights are disabled by default, but allowed
# on some specific fields defined in self.SELF_{READ/WRITE}ABLE_FIELDS.
init_res = super(Users, self).__init__(pool, cr)
# duplicate list to avoid modifying the original reference
type(self).SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
type(self).SELF_WRITEABLE_FIELDS.extend(['new_field'])
# duplicate list to avoid modifying the original reference
type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
type(self).SELF_READABLE_FIELDS.extend(['new_field'])
return init_res
res_users.xml
inherit on view ref="base.view_users_form_simple_modif" (for my profile)
and on view ref="base.view_users_form" (for general settings > users)
Hi, May I know if this issue can fix by any solutions?
I met the same issue, who can fix it?
This helped alot..