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

Can't make stock.landed.cost model read-only for Accounting and Inventory groups (Odoo 15)

Subscribe

Get notified when there's activity on this post

This question has been flagged
groupaccessaccessrightsodoo15
1 Reply
329 Views
Avatar
Uday

I’m really tired of trying to edit the existing access rights for the model stock.landed.cost 

All I want is to make it read-only for these 3 user groups:

  • Accounting / Accountant
  • Inventory / Administrator
  • Accounting / Chief Accountant

What I tried:

I added the following lines in my security/ir.model.access.csv file:

"access_stock_landed_cost_account_manager","stock.landed.cost.account.manager","stock_landed_costs.model_stock_landed_cost","account.group_account_manager",1,0,0,0 "access_stock_landed_cost_account_accountant","stock.landed.cost.account.manager","stock_landed_costs.model_stock_landed_cost","base_accounting_kit.group_account_accountant",1,0,0,0 "access_stock_landed_cost","stock.landed.cost","stock_landed_costs.model_stock_landed_cost","stock.group_stock_manager",1,0,0,0

I tried using both the same names as the existing access rules and also different names, but it still didn’t work.

Users from these groups continue to have full access (create, write, unlink).

I know that access rights can be edited manually via the Odoo UI, but that is not my goal.

I want to:

  1. Keep the existing groups (Accounting / Accountant, Inventory / Administrator, Accounting / Chief Accountant) as read-only.
  2. Create a new user group that has full access (read, write, create, delete) to this model only


What’s the correct way to make the existing groups read-only on this model?

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

Hi,


In Odoo, access rights are cumulative, meaning if a user belongs to multiple groups, they automatically inherit the highest level of permission from any of those groups. This is why your read-only access rules didn’t work, the users still had full rights inherited from existing rules defined in other modules.


To fix this, you first need to remove the existing ACLs for the stock.landed.cost model. You can do this in your custom module by adding <delete> tags in a security.xml file to delete the default access rules provided by the stock or accounting modules. After deleting the default rules, you can then define new access control entries in your ir.model.access.csv file that grant read-only permissions (1,0,0,0) to the three groups — Accounting / Accountant, Accounting / Chief Accountant, and Inventory / Administrator.


id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

access_stock_landed_cost_readonly_accountant,stock.landed.cost.readonly.accountant,stock_landed_costs.model_stock_landed_cost,account.group_account_manager,1,0,0,0

access_stock_landed_cost_readonly_chief_accountant,stock.landed.cost.readonly.chief_accountant,stock_landed_costs.model_stock_landed_cost,base_accounting_kit.group_account_accountant,1,0,0,0

access_stock_landed_cost_readonly_inventory_admin,stock.landed.cost.readonly.inventory.admin,stock_landed_costs.model_stock_landed_cost,stock.group_stock_manager,1,0,0,0



Next, if you need a specific group with full access to manage landed costs, you can create a new custom group (e.g., “Landed Cost Manager”) and assign it full permissions (1,1,1,1) on the same model.


<record id="group_landed_cost_manager" model="res.groups">

    <field name="name">Landed Cost Manager</field>

    <field name="category_id" ref="base.module_category_inventory"/>

</record>


access_stock_landed_cost_full_access,stock.landed.cost.full.access,stock_landed_costs.model_stock_landed_cost,my_module.group_landed_cost_manager,1,1,1,1


Finally, you should upgrade your module (not just restart the server) so Odoo properly reloads the updated ACLs. This approach ensures your existing groups have read-only access, while your new group retains full control over landed cost records.



If access rights alone don't work, add record rules in your security file:


<!-- Read-only rule for Accountants -->

<record id="stock_landed_cost_readonly_accountant_rule" model="ir.rule">

    <field name="name">Landed Cost - Read Only for Accountants</field>

    <field name="model_id" ref="stock_landed_costs.model_stock_landed_cost"/>

    <field name="domain_force">[(1, '=', 1)]</field>

    <field name="groups" eval="[(4, ref('account.group_accountant'))]"/>

    <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>


<!-- Repeat for other groups -->

<record id="stock_landed_cost_readonly_account_manager_rule" model="ir.rule">

    <field name="name">Landed Cost - Read Only for Chief Accountants</field>

    <field name="model_id" ref="stock_landed_costs.model_stock_landed_cost"/>

    <field name="domain_force">[(1, '=', 1)]</field>

    <field name="groups" eval="[(4, ref('account.group_account_manager'))]"/>

    <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>


<record id="stock_landed_cost_readonly_stock_manager_rule" model="ir.rule">

    <field name="name">Landed Cost - Read Only for Stock Managers</field>

    <field name="model_id" ref="stock_landed_costs.model_stock_landed_cost"/>

    <field name="domain_force">[(1, '=', 1)]</field>

    <field name="groups" eval="[(4, ref('stock.group_stock_manager'))]"/>

    <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>


Hope it helps

2
Avatar
Discard
Uday
Author

Thanks, that works!

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
Hiding the menu items for user groups Solved
group access
Avatar
Avatar
1
May 23
2878
Forbid user group to make any changes in products
access accessrights
Avatar
2
May 19
2541
odoo - access to user manager Solved
group access user_management
Avatar
Avatar
2
Sep 24
2154
How to prevent user from opening and closing any session in POS?
pos group accessrights
Avatar
0
Aug 24
1147
Struggling with ir.model.access.csv Solved
security group access
Avatar
Avatar
Avatar
2
Sep 21
12791
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