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?