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

Odoo Evaluating Record Rules for Both Current and Target States

Subscribe

Get notified when there's activity on this post

This question has been flagged
v18V18
2270 Views
Avatar
alshehri.hass@gmail.com

Hi everyone,

I’ve come across what appears to be an inconsistency in how Odoo evaluates record rules, and it might be a bug. Specifically, when attempting to confirm a purchase order from "draft" to "purchase," it seems like Odoo checks permissions for both the current state and the target state at the same time. This results in an access error, even though the rules should allow the transition.

Example Rules:

Here are the two record rules applied to the user’s group:

{
    "id": 386,
    "name": "All Purchase Orders",
    "model_id": [759, "Purchase Order"],
    "groups": [79],
    "domain_force": "[('state', 'not in', ('purchase', 'cancel', 'done'))]",
    "perm_read": true,
    "perm_write": true,
    "perm_create": true,
    "perm_unlink": false
},
{
    "id": 387,
    "name": "Prevent Purchase Orders Cancel",
    "model_id": [759, "Purchase Order"],
    "groups": [79],
    "domain_force": "[('state', 'in', ('purchase', 'cancel', 'done'))]",
    "perm_read": true,
    "perm_write": false,
    "perm_create": false,
    "perm_unlink": false
}

Expected Behavior:

  • Rule 386 allows write access for purchase orders in "draft" state.
  • Rule 387 restricts write access only in the "purchase," "cancel," and "done" states.

Since the user is in the "draft" state, they should have permission to confirm the order, moving it to the "purchase" state.

Observed Behavior:

It seems Odoo requires write permissions for both the "draft" (current) and "purchase" (target) states simultaneously, resulting in an access error due to the restrictions in Rule 387. This doesn’t align with expected behavior, where only the current state’s permissions should apply during the action.

Question:

Is this simultaneous evaluation of current and target states intended in Odoo’s rule logic, or might this be a bug? Any insights or workarounds would be helpful!


Thanks in advance for any guidance.

0
Avatar
Discard
Ray Carnes (ray)

Have your ruled out that confirm doesn't need two write calls in the database where you are seeing this?

alshehri.hass@gmail.com
Author

I'm seeing this issue with sale orders as well and I could only see a single write operation in the `action_confirm`​ method: https://github.com/odoo/odoo/blob/b560ba3897c764220663b9ac19f556573a4c9e2a/addons/sale/models/sale_order.py#L1110

Ray Carnes (ray)

Each of these modules is potentially calling WRITE on Purchase Orders: account_budget, mrp_mps, mrp_subcontracting_dropshipping, mrp_subcontracting_purchase, partner_commission, project_purchase, project_purchase_stock, purchase, purchase_edi_ubl_bis3, purchase_intrastat, purchase_mrp, purchase_product_matrix, purchase_repair, purchase_requisition, purchase_requisition_stock, purchase_stock, sale_purchase, sale_purchase_inter_company_rules, sale_purchase_stock, sale_purchase_stock_inter_company_rules, stock_dropshipping.

I just tested and write is called 7 times during PO confirmation with all of the modules above loaded.

Ray Carnes (ray)

This list shows you what fields are being updated during each call:
OLD: {'state': 'draft', 'date_approve': False} - NEW: {'state': 'purchase', 'date_approve': datetime.datetime(2024, 11, 8, 15, 30, 37)}
OLD: {'group_id': procurement.group()} - NEW: {'group_id': procurement.group(68,)}
OLD: {'invoice_status': 'no'} - NEW: {'invoice_status': 'no'}
OLD: {'date_calendar_start': datetime.datetime(2024, 11, 8, 11, 50, 44)} - NEW: {'date_calendar_start': datetime.datetime(2024, 11, 8, 15, 30, 37)}
OLD: {'picking_ids': stock.picking()} - NEW: {'picking_ids': stock.picking(67,)}
OLD: {'effective_date': False} - NEW: {'effective_date': False}
OLD: {'receipt_status': False} - NEW: {'receipt_status': 'pending'}

alshehri.hass@gmail.com
Author

Thanks for looking into this. Are all of these write operations performed on the PO model? How are you getting this list of updated fields? Even if multiple write operations are being executed on the PO model, I’m not observing the PO order transitioning to a different state or getting stuck between states. Instead, the access error is raised, and the order remains in draft.

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
Where I can find Company Properties in Odoo 18? Solved
v18 V18
Avatar
Avatar
Avatar
Avatar
3
Mar 25
6431
IMPORTING AND EXPORTING DATA
v18 V18
Avatar
Avatar
1
Nov 24
2511
Where is the PDF Partner Ledger QWeb Report and View in Odoo Online?
v18
Avatar
Avatar
1
Dec 25
3259
Change Sign & Pay Button on Quotation E-mails
v18
Avatar
Avatar
Avatar
Avatar
3
Nov 25
572
Problem including JS asset in v18
v18
Avatar
Avatar
Avatar
3
Nov 25
8916
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