Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Odoo Evaluating Record Rules for Both Current and Target States

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
v18V18
2269 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
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
Autor

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
Autor

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!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Where I can find Company Properties in Odoo 18? Rezolvat
v18 V18
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
mar. 25
6431
IMPORTING AND EXPORTING DATA
v18 V18
Imagine profil
Imagine profil
1
nov. 24
2509
Where is the PDF Partner Ledger QWeb Report and View in Odoo Online?
v18
Imagine profil
Imagine profil
1
dec. 25
3259
Change Sign & Pay Button on Quotation E-mails
v18
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
nov. 25
571
Problem including JS asset in v18
v18
Imagine profil
Imagine profil
Imagine profil
3
nov. 25
8910
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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