Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
addonsparsedomain_filterRules
1 Odpoveď
3975 Zobrazenia
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
Zrušiť
Avatar
Maxime MARAIS
Autor Best Answer

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

0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Filter_domain manager department odoo 15
departments domain_filter child Rules Manager
Avatar
Avatar
1
máj 25
2847
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
2353
ADD ON FINANCIAL MODULE/FISCALE ACCOUNTING FOR ODOO 18 COMMUNITY
addons
Avatar
Avatar
Avatar
2
aug 25
1713
How to call a server action depending on Activity State change
Rules
Avatar
Avatar
2
nov 24
2395
Dynamic Domain for states
domain_filter
Avatar
Avatar
1
máj 24
3327
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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