Hi guys! I am new of Odoo, and I am studying how does this framework works!
I am trying to figure out how to hide a tab from a form of a user group, I try to explain better: I need to hide a tab "certifications" in employees form but not for group users of "Manager" and "Administrator" ... how to do this??
Inside the employees form view, I have created a tab using this code:
<xpath expr="//page[last()]" position="after">
<page name="certifications" string="Certifications">
<group>
<group>
<field name="corso_formazione_base"/>
<field name="corso_preposto"/>
<field name="corso_antincendio"/>
<field name="corso_primo_soccorso"/>
</group>
<group>
<field name="corso_ambienti_confinati"/>
<field name="corso_rls"/>
<field name="corso_pas_pev_pei"/>
<field name="corso_uso_ple"/>
</group>
</group>
</page>
</xpath>
# -*- coding: utf-8 -*-
from odoo import api, fields, models, exceptions
from datetime import datetime,date
from odoo import SUPERUSER_ID
class IEmployee(models.Model):
_inherit = "?????"
perm = fields.Boolean(string="Permission", store=False, compute="check_perm", default=True)
@api.one
def check_perm(self):
cuid = self.env.uid
if SUPERUSER_ID == cuid:
self.perm = True
else:
user = self.env['res.users'].browse(self.env.uid)
group_hr_manager = user.has_group('hr.group_hr_manager')
if group_hr_manager == True:
self.perm = True
else:
self.perm = False
<record id="view_employee_form_community" model="ir.ui.view">
<field name="name">hr.employee.community</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='category_ids']" position="after">
<field name="perm" invisible="True"/>
</xpath>
<xpath expr="//page[@name='certifications']" position="attributes">
<attribute name="attrs">{'invisible': [('perm','=',False)]}</attribute>
</xpath>
</field>
</record>
# I haven't test it
#you must debug it, you should use position="replace"
#https://pastebin.com/4uGjMA2L Python
#https://pastebin.com/rpaM5nRB XML
#Odoo 11 community
Hope this will helps: https://plus.google.com/collection/0hcEWE