简体   繁体   English

如何编写 Odoo-14 记录规则

[英]How to write Odoo-14 Record Rules

Good day, I have written a record rule just as below美好的一天,我写了一个记录规则,如下所示

domain=['|',('type', '!=', 'private'),('is_prescription', '=', True)])

Am using it in a variable just as below我在变量中使用它,如下所示

`product_id = fields.Many2one('product.product', ondelete="cascade", string='Product', required=True, domain=['|',('type', '!=', 'private'),('is_prescription', '=', True)])`

To break it all down打破这一切

The ('|',('type', ',=', 'private'),('type', '=', False)) helps me to bypass the default rule for multi company products. ('|',('type', ',=', 'private'),('type', '=', False))帮助我绕过多公司产品的默认规则。

And the record rule ('is_prescription', '=', True) helps me to get a specific product.并且记录规则('is_prescription', '=', True)帮助我得到一个特定的产品。

But the rule domain=['|','|',('type', ',=', 'private'),('type', '=', False),('is_prescription', '=', True)] is not helping to get a specific product that is a prescription, what it does it get all the products.但是规则domain=['|','|',('type', ',=', 'private'),('type', '=', False),('is_prescription', '=', True)]无助于获得处方药的特定产品,它获得所有产品的作用。

What i want to achieve is to bypass the default rule then get a product that is Prescription no matter what company the product belongs too and the user is in.我想要实现的是绕过默认规则,然后获得处方产品,无论产品属于哪家公司并且用户在哪家公司。

Please help me, I am new to Odoo请帮助我,我是 Odoo 的新手

Put your prescription rule with " AND-condition " with other rule instead of " OR-condition "将您的处方规则与“ AND-condition ”一起使用其他规则而不是“ OR-condition

domain=[('is_prescription', '=', True),'|',('type', '!=', 'private'),('type', '=', False)]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM