Skip to content

Commit

Permalink
[IMP] hr_holidays: Display approve/refuse buttons on automated activity.
Browse files Browse the repository at this point in the history
On automated activity, display the approve/refuse buttons along with other ones to approve/refuse the leave

Related Task ID : 1919303
  • Loading branch information
kma-odoo committed Apr 25, 2019
1 parent 1d7bbd1 commit 31a825f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions addons/hr_holidays/models/hr_leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,20 @@ def activity_update(self):
if to_do:
to_do.activity_feedback(['hr_holidays.mail_act_leave_approval', 'hr_holidays.mail_act_leave_second_approval'])

@api.multi
def activity_custom_actions(self, activity):
self.ensure_one()
res = super(HolidaysRequest, self).activity_custom_actions(activity)
if self.state in ['draft', 'refuse', 'cancel', 'validate'] or not activity['automated']:
return res
if self.can_approve:
res.insert(0, {'text': 'Refuse', 'selector_class': 'o_activity_custom_action', 'icon': 'fa-ban', 'action': 'action_refuse', 'action_type': 'object'})
if self.state == 'confirm':
res.insert(0, {'text': 'Approve', 'selector_class': 'o_activity_custom_action', 'icon': 'fa-check', 'action': 'action_approve', 'action_type': 'object'})
else:
res.insert(0, {'text': 'Validate', 'selector_class': 'o_activity_custom_action', 'icon': 'fa-check', 'action': 'action_validate', 'action_type': 'object'})
return res

####################################################
# Messaging methods
####################################################
Expand Down
14 changes: 14 additions & 0 deletions addons/hr_holidays/models/hr_leave_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,20 @@ def activity_update(self):
if to_do:
to_do.activity_feedback(['hr_holidays.mail_act_leave_allocation_approval', 'hr_holidays.mail_act_leave_allocation_second_approval'])

@api.multi
def activity_custom_actions(self, activity):
self.ensure_one()
res = super(HolidaysAllocation, self).activity_custom_actions(activity)
if self.state in ['draft', 'refuse', 'cancel', 'validate'] or not activity['automated']:
return res
if self.can_approve:
res.insert(0, {'text': 'Refuse', 'selector_class': 'o_activity_custom_action', 'icon': 'fa-ban', 'action': 'action_refuse', 'action_type': 'object'})
if self.state == 'confirm':
res.insert(0, {'text': 'Approve', 'selector_class': 'o_activity_custom_action', 'icon': 'fa-check', 'action': 'action_approve', 'action_type': 'object'})
else:
res.insert(0, {'text': 'Validate', 'selector_class': 'o_activity_custom_action', 'icon': 'fa-check', 'action': 'action_validate', 'action_type': 'object'})
return res

####################################################
# Messaging methods
####################################################
Expand Down
3 changes: 3 additions & 0 deletions addons/hr_holidays/views/hr_leave_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@
<div class="col-2"><span class="text-muted">to</span></div>
<div class="col-8"><t t-esc="record.date_to.value"/></div>
</div>
<div class="row no-gutters">
<field name="activity_ids" widget="kanban_activity"/>
</div>
</div>
</t>
</templates>
Expand Down

0 comments on commit 31a825f

Please sign in to comment.