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.
Câu hỏi này đã bị gắn cờ
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()
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký