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

Can I create ir.rule that lets groups have only specific permissions based on state.

Subscriure's

Get notified when there's activity on this post

This question has been flagged
securityrulesgroupsv14
2 Respostes
8880 Vistes
Avatar
Samo Arko

I need to define ir.rule that limits the permissions read, create, write, unlink based on state for a specific security group. If I understand correctly the domain_force filters the records.


<record id="tabla_sp_access_rule" model="ir.rule">
	<field name="name">Access ule</field>
	<field name="model_id" ref="tabla_price.tabla_price_group"/>
	<field name="domain_force">[('create_uid','=',user.id)]</field>
	<field name="groups" eval="[(4, ref('tabla_price.tabla_price_group'))]"/>
</record>
<record id="tabla_sp_state_rule" model="ir.rule">
	<field name="name">States rule</field>
	<field name="model_id" ref="tabla_price.tabla_price"/>
	<field name="domain_force">[('state','in', ['done', 'confirmed', 'canceled'])]</field>
	<field name="groups" eval="[(4, ref('tabla_price.tabla_price_group'))]"/>
	<field name="perm_unlink" eval="0"/>
	<field name="perm_write" eval="0"/>
	<field name="perm_read" eval="1"/>
	<field name="perm_create" eval="0"/>
</record>

Because of the domain force now only the records that are from the user and in states will be shown to the user. I need to show user his records and only prevent write and unlink permissions on state.


I cannot just set fields readonly based on states, because different user groups can do different things based on state.


What is the correct way to do this? Can I do this with ir.rules and I just don't undestand domain_force parameter? 

EDIT:

I've got 3 groups: Importer <- Validator <- Admin.

Importer can CRUD only his own records when the state is "draft", other states he can only Read them.

Validator can Read all records but he can only Update them when they are in state "update".

Admin can see all records and use CRUDE for states "draft", "update" and "cancel".

All have model rights 1,1,1,1.

Importer
<record id="tabla_sp_importer_access_rule" model="ir.rule">
	<field name="name">Importer Access Rule</field>
	<field name="model_id" ref="model_tabla"/>
	<field name="domain_force">['|', ('create_uid','=',user.id), ('partner_id', '=', user.partner_id.id)]</field>
	<field name="groups" eval="[(4, ref('tabla.tabla_sp_importer'))]"/>
</record>

<record id="tabla_sp_importer_state_rule" model="ir.rule">
	<field name="name">Importer States Rule</field>
	<field name="model_id" ref="model_tabla"/>
	<field name="domain_force">[('state','in', ['done', 'canceled'])]</field>
	<field name="groups" eval="[(4, ref('tabla.tabla_sp_importer'))]"/>
	<field name="perm_unlink" eval="0"/>
	<field name="perm_write" eval="0"/>
	<field name="perm_read" eval="1"/>
	<field name="perm_create" eval="0"/>
</record>


Validator
<record id="tabla_sp_validator_access_rule" model="ir.rule">
	<field name="name">Validator Access Rule</field>
	<field name="model_id" ref="model_tabla"/>
	<field name="domain_force">[(1, '=', 1)]</field>
	<field name="groups" eval="[(4, ref('tabla.tabla_sp_validator'))]"/>
</record>

<record id="tabla_sp_validator_state_rule" model="ir.rule">
	<field name="name">Validator States Rule</field>
	<field name="model_id" ref="model_tabla"/>
	<field name="domain_force">[('state','in', ['draft', 'done', 'canceled'])]</field>
	<field name="groups" eval="[(4, ref('tabla.tabla_sp_validator'))]"/>
	<field name="perm_unlink" eval="0"/>
	<field name="perm_write" eval="0"/>
	<field name="perm_read" eval="1"/>
	<field name="perm_create" eval="0"/>
</record>

Admin
<record id="admin_state_rule" model="ir.rule">
	<field name="name">Administrator States Rule</field>
	<field name="model_id" ref="model_tabla"/>
	<field name="domain_force">[('state','=', 'done')]</field>
	<field name="groups" eval="[(4, ref('tabla.tabla_sp_admin'))]"/>
	<field name="perm_unlink" eval="0"/>
	<field name="perm_write" eval="0"/>
	<field name="perm_read" eval="1"/>
	<field name="perm_create" eval="0"/>
</record>







 


0
Avatar
Descartar
Avatar
Iheb Ltaief
Best Answer

See this example in expense:

<record id="sale_order_rule_expense_user" model="ir.rule">
<field name="name">Expense Employee can read confirmed SO</field>
<field ref="sale.model_sale_order" name="model_id"/>
<field name="domain_force">[('state', '=', 'sale')]</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
-1
Avatar
Descartar
Samo Arko
Autor

Thanks... I looked at them, but I'm still having hard time to figure them out. The problem is that I have 3 different user groups that need to have different rights. Will update my question

Avatar
Iheb
Best Answer

Yes you can set specific rule for each group,

You have to define the group in  <field name="groups" eval="[(4, ref('base.group_user'))]"/>

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
How to create rule to display only subordinates leave records in openerp
security rules groups
Avatar
Avatar
1
de març 15
8628
Is the security "section" required in a new module ?
security action.rule rules groups
Avatar
Avatar
1
de maig 18
16716
odoo[v8] rules
security rules groups odooV8
Avatar
Avatar
1
de jul. 15
5122
How do I create a group and rules for Hr?
security hr rules groups hr_employee
Avatar
Avatar
1
d’ag. 24
2900
Odoo Security group
security rules groups Community OdooV13
Avatar
0
de juny 22
3172
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