How can I stop Odoo custom button from auto save?

Viewed 3263

I have created a button inside my view which triggers a method inside the module. However on clicking the button the temporary edited fields are saved and not reverted when clicking the 'Discard' button.

Here is the code for my view:

<form>
  <sheet>
    <group>
    <field name="name" />
    </group>
    <button name="my_button" string="My Button" type="object" class="oe_edit_only" />
  </sheet>
</form>

Once I click my_button the field name is saved in the database and the button Discard has no effect any more.

enter image description here

How can I prevent Odoo from saving the temporary data when clicking my custom button?

(I'm working with Odoo10 but I guess it's the same for older versions of Odoo)

2 Answers
Related