pmcleite February 2016

Object button don't call method in python

i'm trying to call a function in python with following buttons:

<form string="Settings" class="oe_form_configuration">
     <header>
         <button string="Apply" type="object" name="execute" class="oe_highlight"/>
         <button string="Cancel" type="object" name="cancel" class="oe_link"/>
    </header>
     ...
</form>

But, they will never be called. After some time, I saw that is just called the method of update, that is, def write(...).

Can someone help me understand the problem?

EDIT: Actually, I remove all logic from methods:

def execute(self, cr, uid, ids, context=None):
    pass

def cancel(self, cr, uid, ids, context=None):
    pass

Best regards

Answers


Alessandro Ruffolo February 2016

Instead of using old v7 API, try v8:

@api.one
def execute(self):
    pass

@api.one
def cancel(self):
    pass

(or multi instead of one. Here's the difference)

Post Status

Asked in February 2016
Viewed 3,828 times
Voted 4
Answered 1 times

Search




Leave an answer