0
votes

I have a button, on popup form, with action method action_replace(). Inside action_replace() there is a logic to replace products in BOM. The model is product.template.

Whenever I click button, a new record is inserted in product_template table. Moreover, a field in my view, default_code, (from product_product table) got updated as well with empty string (since product_template_id linked to product id does not exist in product_product table).

What I have learned is that whenever a button is clicked, the default behaviour of the system is to save the data first and then to execute the button click function. Is there a way to avoid these records insertions?

1

1 Answers

0
votes

A button click does nothing per se. The code in the function attached to the button is the one that is inserting those records.

To have a different behaviour when clicking on the button you should override the action_replace() function.