Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1959 Widoki

I have custom module that have many ir.rule which has domain_dorce. And i'm also using this module as Many2one on other module, what I want is even though the user is restricted to see some records, can I remove the ir.rule on the Many2one of the other module.

Awatar
Odrzuć
Najlepsza odpowiedź

Hii Bilguudei Erdenekhuyag,

You have to overwrite all the record rules of which you want to give access.

Let's take one example to overwrite one record rule.

->In order to do this in the backend, first, we need to get the XML file of the Record rule. We can get this by simply searching the name of the Record Rule. After that in the new module inside the security folder, create a security .xml and paste the code in that security.xml file. Make sure you have called the security.xml in the manifest file.

Please find code in comment. 

I hope it will be useful to you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Awatar
Odrzuć

->The original code will be like this:

<record id = "sale_order_personal_rule" model = "ir.rule">
<field name = "name"> Personal Orders </field>
<field ref = "model_sale_order" name = "model_id" />
<field name = "domain_force" > ['|', ('user_id', '=', user.id), ('user_id', '=', False)] </field>
<field name = "groups" eval = "[(4, ref ('sales_team.group_sale_salesman'))] "/>
</record>

->This is the original code, but before making any changes we have to make the noupdate as false. In order to do that we can use the function tag as:

<function name = "write" model = "ir.model.data">
<function name = "search" model = "ir.model.data">
<value eval = "[('module', '=', ' sale '), (' name ',' = ',' sale_order_personal_rule ')] "/>
</function>
<value eval =" {' noupdate ': False} "/>
</function>

->Now we can modify the Record rule as we want.

<record id = "sale.sale_order_personal_rule" model = "ir.rule">
<field name = "name"> Personal Orders </field>
<field ref = "sale.model_sale_order" name = "model_id" />
<field name = "domain_force">[(1,'=',1)]</field>
<field name = "groups" eval = "[(4, ref ('sales_team.group_sale_salesman'))]" />
</record>

-> <field name = "domain_force">[(1,'=',1)]</field> , This is a special rule, that unconditionally gives access to all records.

->Now make the noupdate as True again.:

<function name = "write" model = "ir.model.data">
<function name = "search" model = "ir.model.data">
<value eval = "[('module', '=', ' sale '), (' name ',' = ',' sale_order_personal_rule ')] "/>
</function>
<value eval =" {' noupdate ': True} "/>
</function>

->So now onwards on upgrade of the module the rule will get updated if we had modified the record rule.

->You have to do this with all the rules which you want to give access.

Powiązane posty Odpowiedzi Widoki Czynność
2
lut 25
5991
1
gru 24
1516
1
sie 24
2068
1
lis 22
16085
1
sie 22
7481