Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

How to set up security groups properly in this case?

Naroči se

Get notified when there's activity on this post

This question has been flagged
securitymodelsgroups
1 Odgovori
4385 Prikazi
Avatar
John Doe

Hi. I've added one group called Manager. I want to restrict all access to some model (say, model B) if the user is not a manager.

The way I did this initially, is that I added groups="my_module.group_id" to menuitems and fields so that they only show if the user is in the manager group. However, I can still access the model B if I happen to sneak into its views using URL. So setting groups attribute is not enough.

Then I restricted access to model B directly from \ir.model.access.csv file, however, users now can't access model A (main model, which has one2many field referencing model B) at all.

It says: "You are not allowed to access 'model name' (model.name) records."

I want it to let me see all the other fields of model A except the ones that relate to model B.

I'll provide more info if necessary.

0
Avatar
Opusti
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

If we have to restrict access to a model using a security group, we can use groups attribute or set access rights in the ir.model.access.csv file. If you have conflict with One2many fields from the model in the view of another model, then you can try using a boolean field with a compute method and attrs attribute for the One2many field to hide it. Here, we are hiding the fields based on the user group and independent of the model:
(Example: Hiding the order lines of purchase order from custom module based on a group)
Security group:

< record id="group_purchase_editor" model="res.groups">
        < field name="name">Purchase Order Editor
        < field name="category_id" ref="base.module_category_inventory_purchase"/>
    < /record>
Boolean field and compute method added in the model:

class PurchaseOrder(models.Model):
_inherit = "purchase.order"

    purchase_order_editor = fields.Boolean(
        string='Editor', compute='_compute_purchase_order_editor')

    def _compute_purchase_order_editor(self):
        """
        This function is used to update the purchase_order_editor field
        based on the user group
        """
        for record in self:
            record.purchase_order_editor = False
            if record.user_has_groups('custom_module_name.group_purchase_editor'):
                record.purchase_order_editor = True
Update the form view:

< record id="purchase_order_view_form" model="" rel="ugc">ir.ui.view">
        < field name="name">purchase.order.view.form.inherit.custom_module_name
        < field name="model">purchase.order
        < field name="inherit_id" ref="purchase.purchase_order_form" />
        < field name="arch" type="xml">
            < xpath expr="//field[@name='partner_id']" position="after">
                < field name="purchase_order_editor" invisible="1" />
            < /xpath>
            < xpath expr="//field[@name='order_line']" position="attributes">
                < attribute name="attrs">{'invisible': [('purchase_order_editor', '=', False)]}
            < /xpath>
        < /field>
    < /record>
Hope it helps
0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Security Fear: Make fields of a model secret without using groups attribute
security groups
Avatar
0
nov. 15
5630
How to display a view with one field removed for certain groups?
security groups
Avatar
Avatar
1
mar. 15
9197
access rights manual Solved
security groups
Avatar
Avatar
1
mar. 15
5672
Permission for a group to edit a single field only? Solved
security v7 groups
Avatar
Avatar
Avatar
Avatar
Avatar
10
dec. 23
37769
Make Field Read Only for specific Group Solved
security fields groups
Avatar
Avatar
1
okt. 25
10821
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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