Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

My profile gives access error for employee fields

Subscriure's

Get notified when there's activity on this post

This question has been flagged
employeeAccessError13.0
3 Respostes
11221 Vistes
Avatar
Sprintit Oy / Roy Nurmi

In v13, if user is related to an emplyee, and I g to My profile, gives the following error. I.e, user needs to be HR/Offices to be able to access "My profile", which is certainly wrong.

These fields are on hr.employee model, so basically I see the reason for the restriction, but in this use case this does not work at all.

The requested operation can not be completed due to security restrictions. Document type: Users (res.users) Operation: read User: 9 Fields: - address_home_id (allowed for groups 'Employees / Officer') ...

0
Avatar
Descartar
Minh Hong

Hi, May I know if this issue can fix by any solutions?

Robin

I met the same issue, who can fix it?

Bayside Aviation

This helped alot..

Avatar
Livia Filippi
Best Answer

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)


2
Avatar
Descartar
Bayside Aviation

This helped, however I'm still having issues with saving of the data, even though its been added to writeable_fields...strange

Livia Filippi

Hello @Cameron P, are you still encountering some error? Or it just doesn't save at all?

luna_22

I'm so grateful, it helped a lot. Thank you so much

Asma Ben Brahem

Hello, What can I do in case of adding two fields ?
I tried adding my two fields to the extend method like this
profession = fields.Char(String="Profession")
titre = fields.Char(string="Titre")
and in the init method we have:
init_res = super(user, 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(['profession', 'titre'])
type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
type(self).SELF_READABLE_FIELDS.extend(['profession', 'titre'])

and of course added the two new fields in the specified inherited views, your method works pretty fine for one field, but when I tried adding one second field, I get the access right error, I would be grateful if you can help me with this

Livia Filippi

Hello, @Asma Ben Brahem as far as I can tell it seems you defined everything I expected, except maybe the return of the function (unless you just didn't copy it to your comment). Have you tried checking out the original code in the mail module here and make sure everything reflects how odoo expects it? https://github.com/odoo/odoo/blob/deaf27a75b0b123636066679dd14ef6b62541091/addons/mail/models/res_users.py#L68

Michael Jurke

Thank you! We indeed added a field to users model and installed the hr module. And could solve the conflict with the instructions above.

In Odoo 16, I had to change __init__(self, pool, cr) to __init__(self, *args) and super().__init__(*args) repectively. There are more arguments now.

Avatar
Raúl
Best Answer

Did you find a solution? I have the same problem and I can't resolve it :S

0
Avatar
Descartar
Avatar
Muhammed Fasil
Best Answer


Did you tried after checked the 'Employee Edition'?
Settings --> Employee Tab


0
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
Access error when accesing "My profile", doing that requires "officer" access
hr employee permissions AccessError
Avatar
Avatar
1
de set. 22
4030
hr_employee_public.timesheet_manager_id does not exist
employee
Avatar
Avatar
1
d’ag. 25
4616
Recurring training
employee
Avatar
Avatar
1
d’oct. 24
8001
[odoo 13]Discuss template
13.0
Avatar
0
d’oct. 24
2124
Employee Bank Account Number Solved
employee
Avatar
Avatar
Avatar
2
de jul. 24
3019
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now