Odoo Help

Welcome!

This community 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.

0

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

By
Amit
on 6/22/16, 2:02 AM 300 views

Python code for the Action To Approve All leaves:

Model: Leaves

button: Approve

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


0
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"?>

<openerp>

<data>

<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">

<group>

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

</group>

<footer>

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

or

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

</footer>

</form>

</field>

</record>

<act_window name="Approve"

res_model="approve.leave"

src_model="hr.holidays"

view_mode="form"

            view_id="view_approve_leaves"

target="new"

key2="client_action_multi"

id="action_view_approve_leaves"/>

</data>

</openerp>


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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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