Odoo Help


How to call approve button action in a new menu item(more)?? I tried server action but python code is not working.

on 6/22/16, 2:02 AM 389 views

Python code for the Action To Approve All leaves:

Model: Leaves

button: Approve

Code : self.write(cr, uid, ids, {'state': 'validate'}, context= None)

Ajeng Shilvie
On 6/23/16, 5:40 AM

Hi i try this ..

You have to define new .py and .xml file ..

in .xml file input this code 

<?xml version="1.0" encoding="utf-8"?>



<record id="view_approve_leaves" model="ir.ui.view">

<field name="name">Approve Timesheet</field>

<field name="model">approve.leave</field>

<field name="arch" type="xml">

<form string="Approve">


<separator string="Are you sure you want to approve these Leave?"/>



<button name="approve" string="Approve" type="object" class="oe_highlight"/>


<button string="Cancel" class="oe_link" special="cancel" />





<act_window name="Approve"










in .py file input this code :

from openerp.osv import osv,fields

class approve_leave(osv.osv_memory):

_name = 'approve.leave'

_description = 'Approve Leaves'

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

active_ids = context.get('active_ids')

if active_ids :

self.pool.get('hr.holidays').signal_workflow(cr, uid, active_ids, 'validate' )

return True

You have to sent signal_workflow instead write the state.

Hope this help !

If in "More" the button approve doesn't show up, try to see the "Action" menu.

Ajeng Shilvie
on 6/23/16, 5:42 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 6/22/16, 2:02 AM
Seen: 389 times
Last updated: 6/23/16, 5:40 AM