How can I execute a python function when in a One2many I click on the delete button and I still haven't saved the parent form.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hi Jainesh, your solution did not work for me, even if I save the parent form, it doesn't work when I delete either, it doesn't enter the unlink method, I'm in Odoo15 enterprise
Hello Pavel,
You just need to follow below steps to achieve this.
Please Find code in comment.
I hope this will help you.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
Code :-
Step 1: Pass the custom flag in context.
<field name="o2m_field" context="{'is_from_o2m_field': True}">
<tree>...</tree>
</field>
Step 2: Inherit the relational model of our o2m_field and extend the unlink method like below.
def unlink(self):
if context.get("is_from_o2m_field"):
# write your custom code to call the desired function.
pass
return super().unlink()
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up