Hi,
I've placed a button on Sale -> Customer -> Edit Form. This button calls a function that uses to retrive addresses out of a brazilian database website and place them on fields like street, street2, city, etc.
The button and the code work fine, however whenever I press it the modified fields are automatically saved.
Example:
After pressing the button the address values will be loaded
But if I decide that I won't register this customer and press the DISCARD / CANCEL button
The customer is still displayed as if I had clicked on SAVE right after pressing my button, even though I didn't SAVE.
Button code:
<xpath expr="//div[@name='button_box']" position="inside">
<button name="consulta_cnpj"
type="object"
class="oe_edit_only"
icon="fa-search"
string="Consultar CNPJ"
attrs="{'invisible': [('company_type', '=', 'person')]}">
</button>
</xpath>
The relevant part of the function:
dic = json.loads(content)
self.zip = str(cep).zfill(8) if cep else ''
self.street = dic['logradouro'].title()
self.x_number = dic['numero'] + dic['complemento'].title()
self.x_neighborhood = dic['bairro'].title()
So basically I must modify my code to make address value appear on the respective fields without getting stored (just as if the user had typed them). How can I do this?
OBS1: I did not modify the CANCEL button
If we click any button by default SAVE action will call