Python code for the Action To Approve All leaves:
Model: Leaves
button: Approve
Code : self.write(cr, uid, ids, {'state': 'validate'}, context= None)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Python code for the Action To Approve All leaves:
Model: Leaves
button: Approve
Code : self.write(cr, uid, ids, {'state': 'validate'}, context= None)
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.
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 2 20
|
2576 | ||
|
1
thg 8 19
|
6806 | ||
|
2
thg 2 19
|
3283 | ||
|
1
thg 5 25
|
636 | ||
|
1
thg 11 19
|
3712 |