Ajuda

0

Condition for <delete> tag in xml file

Avatar
Haresh Kansara

Hello Odooers,


I have one issue for deleting xml id using XML file. I know that we can delete using <delete> tag, but when that id is deleted and again when we upgrade module then it gives error that external id not found. Can anyone suggest me how to fix?

I tried with following syntax:

<delete model="ir.rule" search="[('id','=', ref('base.res_partner_rule_private_employee'))]"/>

<delete id="base.res_partner_rule_private_employee" model="ir.rule"/> 


I tried both above syntax, but every time when it's deleted first time and after that wheneve i upgrade my custom module then it give error for external id not found.


--

Regards
Haresh Kansara
Odoo Application Engineer

https://join.skype.com/invite/dl0S6rgZ7GBF  


Avatar
Descartar
1 Resposta
2

You can also try to call the method from the XML:

# XML
<function name="delete_rule" model="res.company"/>

#PY
@api.model
def delete_rule(self):
if self.env.ref('base.res_partner_rule_private_employee'):
self.env.ref('base.res_partner_rule_private_employee',
raise_if_not_found=False).unlink()


1 Comentário
Avatar
Descartar
Avatar
Haresh Kansara
-

Thanks