Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Hide a field based on user groups?

Subscribe

Get notified when there's activity on this post

This question has been flagged
securitygroupsopenerp7
4 Replies
19605 Views
Avatar
Matias Garcia Isaia

I have a module that adds a flag to res.partner. If the flag for an object is enabled, that object only has to be visible to users in a Priviliged group. In addition, as only those users can set which objects have this flag enabled, they are the only ones who should see the flag field in the views.

I'm using OpenERP 7 and read here (://doc openerp com /trunk/server/04_security/) the use of groups properties, both at object-level and view-level.

But when I open the view with a non-Priviliged user, I get an Access Denied by ACLs for operation: read, uid: 5, model: res.partner, fields: priviliged error.

How can I manage to do this? Am I doing something wrong?

partner_modif.py:

class partner_modif(osv.osv):
    _name = "res.partner"
    _inherit = "res.partner"
    _columns = { 
                  'priviliged': fields.boolean('Priviliged', required=False, groups="my-module.priviliged_users")
                  }
    _defaults = {
                  'priviliged': lambda *a: 0
                 }
partner_modif()

partner_view_modif.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_partner_address_form1_inherit" model="ir.ui.view">
            <field name="name">res.partner.address.form1.inherit</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="arch" type="xml">
                    <field name="function" position="after">
                        <field name="priviliged" groups="my-module.priviliged_users"/>
                    </field>
              </field>
        </record>

    <record id="my-module.priviliged_users" model="res.groups">
        <field name="name">Priviliged</field>
        <field name="comment">Priviliged users</field>
    </record>

    <record model="ir.rule" id="partner_priviliged_users">
        <field name="name">Priviliged users see all partners</field>
        <field name="model_id" ref="model_res_partner"/>
        <field name="domain_force">[(True, '=', True)]</field>
        <field name="groups" eval="[(4, ref('my-module.priviliged_users'))]"/>
    </record>

    <record model="ir.rule" id="partner_unpriviliged_users">
        <field name="name">Non priviliged users see un-priviliged partners</field>
        <field name="model_id" ref="model_res_partner"/>
        <field name="domain_force">[('priviliged', '=', False)]</field>
        <field name="groups" eval="[(4, ref('base.group_user'))]"/>
    </record>
    </data>
</openerp>
0
Avatar
Discard
Xsias

Have you create a ir_model_access.csv in the folder security of your module ?

Matias Garcia Isaia
Author

@Xsias: no, I haven't. Never read about. I'm searching now, if you have any recommended link, it'll be appreciated :)

Sehrish

1- How to check login user group in odoo: https://goo.gl/Ts3qqK

2- How to visible and invisible fields in odoo: https://goo.gl/BCxCpk

Avatar
Xsias
Best Answer

Here some links about ir_model_access :

https://accounts.openerp.com/forum/Help-1/question/12430

In this link you can read :

For :

id  name    model_id/id group_id/id perm_read   perm_write  
perm_create perm_unlink
model_bpl_worker_manager    bpl_worker  model_bpl_worker    
group_checkroll_manager 1   1   1   1
  • id = unique identify for the permission (Example: MY_MODULE_res_partner_manager)
  • name = unique name for the permission (Example: res_partner manager)
  • model_id/id = the model unique name of the class you want apply permission on (Example model_res_partner)
  • group_id/id = group permission apply on (yopu can define it in xml group file or call an existing group with syntax module.group_id)
  • perm_read,perm_write,perm_create,perm_unlink = the 4 values for the relative permission to read, write,create,unlink record on defined class. 1 is True (you can do this action) and 0 is Faslse (you can't)

A simple way to understand this file is to read an existing csv in some OpenERP base module like sale, account, product, etc...

Some useful link: http://www.zbeanztech.com/blog/security-openerp

I can give you others links likes :

http://forum.openerp.com/forum/topic16596.html

http://stackoverflow.com/questions/15966676/openerp-7-access-rights-for-user-roles

-2
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Security Fear: Make fields of a model secret without using groups attribute
security groups
Avatar
0
Nov 15
5855
access rights manual Solved
security groups
Avatar
Avatar
1
Mar 15
5838
How to display a view with one field removed for certain groups?
security groups
Avatar
Avatar
1
Mar 15
9419
Permission for a group to edit a single field only? Solved
security v7 groups
Avatar
Avatar
Avatar
Avatar
Avatar
10
Dec 23
38081
Make Field Read Only for specific Group Solved
security fields groups
Avatar
Avatar
1
Oct 25
11121
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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