This question has been flagged
1 Reply
2227 Views

Hello,

How can I edit a rule from a module in xml ?

Update : 

I've tried in a xml file :

record id="stock.stock_production_lot_rule" model="ir.rule"

    field name="active" eval="False"

record

But i got the error "ID XML is missing"

WARNING test odoo_tools_convert : Skipping deletion for missing XML ID `'stock_production_lot_rule'`" 

Yet the ID matches the one in the rule metadata.



Avatar
Discard

Version? Community or Enterprise?

Author

Enterprise

i think this rule have noupdate=1 that's why you getting issue.

Best Answer

Hello John,


For editing an existing record rule,first you need to make the noupdate as false before making any changes in the original code,otherwise the new rule will not be reflected.
You can make it as below code : 


Find code in Comment : 


Then install the module.The rule will be modified.and Then make the noupdate as True again and upgrade the module and check.

Hope it will help you.


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

Avatar
Discard

for eg:

If this is the original code,

<record id="stock_production_lot_rule" model="ir.rule">
<field name="name">stock production rule name</field>
<field name="model_id" ref="model_stock_production_lot"/>
<field name="groups" eval="[(4, ref('user_group_name..fill..'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
<field name="domain_force">[('....fill...)]</field>
</record>

Then first do below one,

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

Then modify the rule,

<record id = "stock.stock_production_lot_rule" model = "ir.rule">
<field name = "name"> ....(updated name) </field>
<field ref = "stock.model_stock_production_lot" name = "model_id" />
<field name = "domain_force"> [(....fill..)] </field>
<field name = "groups" eval = " [(4, ref ('user_group_name..fill..'))] "/>
</record>