diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/hr_attendance/static/src/js/my_attendances.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/hr_attendance/static/src/js/my_attendances.js')
| -rw-r--r-- | addons/hr_attendance/static/src/js/my_attendances.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/addons/hr_attendance/static/src/js/my_attendances.js b/addons/hr_attendance/static/src/js/my_attendances.js new file mode 100644 index 00000000..91acb7f1 --- /dev/null +++ b/addons/hr_attendance/static/src/js/my_attendances.js @@ -0,0 +1,56 @@ +odoo.define('hr_attendance.my_attendances', function (require) { +"use strict"; + +var AbstractAction = require('web.AbstractAction'); +var core = require('web.core'); +var field_utils = require('web.field_utils'); + + +var MyAttendances = AbstractAction.extend({ + contentTemplate: 'HrAttendanceMyMainMenu', + events: { + "click .o_hr_attendance_sign_in_out_icon": _.debounce(function() { + this.update_attendance(); + }, 200, true), + }, + + willStart: function () { + var self = this; + + var def = this._rpc({ + model: 'hr.employee', + method: 'search_read', + args: [[['user_id', '=', this.getSession().uid]], ['attendance_state', 'name', 'hours_today']], + }) + .then(function (res) { + self.employee = res.length && res[0]; + if (res.length) { + self.hours_today = field_utils.format.float_time(self.employee.hours_today); + } + }); + + return Promise.all([def, this._super.apply(this, arguments)]); + }, + + update_attendance: function () { + var self = this; + this._rpc({ + model: 'hr.employee', + method: 'attendance_manual', + args: [[self.employee.id], 'hr_attendance.hr_attendance_action_my_attendances'], + }) + .then(function(result) { + if (result.action) { + self.do_action(result.action); + } else if (result.warning) { + self.do_warn(result.warning); + } + }); + }, +}); + +core.action_registry.add('hr_attendance_my_attendances', MyAttendances); + +return MyAttendances; + +}); |
