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.
Этот вопрос был отмечен
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()
Не оставайтесь в стороне – присоединяйтесь к обсуждению!
Создайте аккаунт сегодня, чтобы получить доступ к эксклюзивным функциям и стать частью нашего замечательного сообщества!
Регистрация