Open elperrofarelo opened 3 years ago
This error is also a problem when archiving an asset (v14). Have you found a way to override this record rule in code? I could do it manually in Settings > Technical > Record Rules but would prefer to do it in the module I am writing.
I couldn't find a way to change the two asset-related rules with the incorrect domain, but I did find a way to archive them and recreate them (see below).
NOTE: due to a known issue in Odoo, you cannot add <!-- comments -->
to the file below or else the commands in the file won't work. Weird!
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<function name="write" model="ir.rule">
<function name="search" model="ir.rule">
<value eval="[('name', '=', 'Account Asset Category multi-company')]"/>
</function>
<value eval="{'active': False}"/>
</function>
<function name="write" model="ir.rule">
<function name="search" model="ir.rule">
<value eval="[('name', '=', 'Account Asset multi-company')]"/>
</function>
<value eval="{'active': False}"/>
</function>
<record id="account_asset_category_multi_company_rule" model="ir.rule">
<field name="name">Account Asset Category multi-company</field>
<field ref="model_account_asset_category" name="model_id"/>
<field eval="True" name="global"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
</record>
<record id="account_asset_asset_multi_company_rule" model="ir.rule">
<field name="name">Account Asset multi-company</field>
<field ref="model_account_asset_asset" name="model_id"/>
<field eval="True" name="global"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
</record>
</data>
</odoo>
Following error pops up in multi company environment while creating a asset category: ('The requested operation ("create" on "Asset category" (account.asset.category)) was rejected because of the following rules:\n- Account Asset Category multi-company\n\nNote: this might be a multi-company issue.\n\n(Records: computers (id=6), User: xxxx (id=9))', None) Problem: Wrong domain_force definition of: account_asset_category_multi_company_rule and account_asset_asset_multi_company_rule IST:['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
SHOULD BE: ['|',('company_id','=',False),('company_id','in',company_ids)]