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č

Unable to install these rules declared in add-on: error while validating constraint.

Naroči se

Get notified when there's activity on this post

This question has been flagged
addonsparsedomain_filterRules
1 Odgovori
3971 Prikazi
Avatar
Maxime MARAIS

Hi,

I just created an add-on to filter partner's information made available to users. To be able to see partners, their sale orders and invoice, a user must be added to a list declared as follow:

class Partner(models.Model):
_inherit = "res.partner"

access_user_ids = fields.Many2many(
'res.users',
'partner_users_access_rel',
column1='partner_id',
column2='user_id',
string='Allowed to access',
help='Only users listed here will have access to the partner, their sales orders and invoices',
)

To make it happen, rules are declared like so:

<odoo>

<data>
<!-- Grant access to partner to creator or user allowed to access partner -->
<record id="my_access_partner" model="ir.rule">
<field name="name">Partner restricted access</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="global" eval="True"/>
<field name="domain_force">
[('parent_id','=',False),'|','|',('create_uid','=',user.id),('user_id','=',user.id'),('access_user_ids','in',[user.id])]
</field>
</record>

<!-- Grant access to sale order creator, salesperson or user allowed to access partner -->
<record id="my_access_sale_order" model="ir.rule">
<field name="name">Sale order restricted access</field>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="domain_force">['|','|',('create_uid','=',user.id),('user_id','=',user.id),('partner_id.access_user_ids','in',[user.id])]</field>
</record>

<!-- Grant access to invoice creator, salesperson or user allowed to access partner or partner's parent (invoice address) -->
<record id="my_access_invoice" model="ir.rule">
<field name="name">Invoice restricted access</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="global" eval="True"/>
<field name="domain_force">['|','|','|',('create_uid','=',user.id),('user_id','=',user.id),('partner_id.access_user_ids','in',[user.id]),('partner_id.parent_id.access_user_ids','in',[user.id])]</field>
</record>
</data>

</odoo>

For some reason, I get the following error message :

ParseError: "Error while validating constraint

sale.order
None" while parsing /home/maxime/PycharmProjects/odoo-20200827/odoo/addons/exnihilo_access/security/exnihilo_access_security.xml:17, near
<record id="my_access_sale_order" model="ir.rule">
            <field name="name">Sale order restricted access</field>
            <field name="model_id" ref="sale.model_sale_order"/>
            <field name="domain_force">['|','|',('create_uid','=',user.id),('user_id','=',user.id),('partner_id.access_user_ids','in',[user.id])]</field>
        </record>

I though about an issue with the constraint domain, but I was able to create it from the web UI, copy-pasting the domain value. And it works as expected.

Thing is I would like these rules to be added when the add-on is installed but I can't find what can be wrong with this piece of XML. 

0
Avatar
Opusti
Avatar
Maxime MARAIS
Avtor Best Answer

Found my mistake: I did not declare dependencies to sale and account in manifest Now works seamlessly.

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
Filter_domain manager department odoo 15
departments domain_filter child Rules Manager
Avatar
Avatar
1
maj 25
2845
Odoo isn't seeing an add-on that I downloaded and placed in the addons folder Solved
addons
Avatar
Avatar
Avatar
Avatar
Avatar
5
okt. 25
2345
ADD ON FINANCIAL MODULE/FISCALE ACCOUNTING FOR ODOO 18 COMMUNITY
addons
Avatar
Avatar
Avatar
2
avg. 25
1708
How to call a server action depending on Activity State change
Rules
Avatar
Avatar
2
nov. 24
2391
Dynamic Domain for states
domain_filter
Avatar
Avatar
1
maj 24
3325
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