diff --git a/addons/hr_attendance/__openerp__.py b/addons/hr_attendance/__openerp__.py
index 1c4f38342ca..0947f208be6 100644
--- a/addons/hr_attendance/__openerp__.py
+++ b/addons/hr_attendance/__openerp__.py
@@ -56,8 +56,8 @@ actions(Sign in/Sign out) performed by them.
'certificate': '0063495605613',
#web
- "js": ["static/src/js/sign_in_out.js"],
- "css":[],
- 'qweb' : ["static/src/xml/sign_in_out.xml"],
+ "js": ["static/src/js/attendance.js"],
+ "css":["static/src/css/attendance.css"],
+ 'qweb' : ["static/src/xml/attendance.xml"],
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/hr_attendance/hr_attendance_view.xml b/addons/hr_attendance/hr_attendance_view.xml
index b29ea0202c3..258177bfd5e 100644
--- a/addons/hr_attendance/hr_attendance_view.xml
+++ b/addons/hr_attendance/hr_attendance_view.xml
@@ -130,8 +130,8 @@
-
-
+
+
diff --git a/addons/hr_attendance/static/src/css/attendance.css b/addons/hr_attendance/static/src/css/attendance.css
new file mode 100644
index 00000000000..5300129b54b
--- /dev/null
+++ b/addons/hr_attendance/static/src/css/attendance.css
@@ -0,0 +1,4 @@
+.oe_attendance_button {
+ cursor: 'pointer';
+}
+
diff --git a/addons/hr_attendance/static/src/js/attendance.js b/addons/hr_attendance/static/src/js/attendance.js
new file mode 100644
index 00000000000..c1a4ef341a6
--- /dev/null
+++ b/addons/hr_attendance/static/src/js/attendance.js
@@ -0,0 +1,57 @@
+openerp.hr_attendance = function(instance) {
+ var QWeb = instance.web.qweb;
+ instance.hr_attendance.AttendanceNotifier = instance.web.Widget.extend({
+ template: 'AttendanceNotifier',
+
+ init: function(attendance_status){
+ console.log('nnnnnn',this)
+ this.attendance_status = attendance_status;
+ },
+ renderElement: function() {
+ console.log('render',this)
+ if (this.attendance_status == 'present'){
+ action_type = 'sign_out';
+ }
+ else{
+ action_type = 'sign_in';
+ }
+ this.$element = $(QWeb.render(this.template, {'action':action_type}));
+ console.log('element',this.$element)
+ this.$element.click(this.on_attendance);
+ },
+
+
+
+ on_attendance: function(event) {
+ var self = this;
+ console.log('eventtt',event)
+ action = new instance.web.DataSetSearch(this, 'ir.actions.act_window', {}, [['res_model', '=', 'hr.sign.in.out']]);
+ action.read_slice().done(function(action) {
+ action = action[0];
+ action.context = JSON.parse(action.context);
+ var action_manager = new instance.web.ActionManager(self);
+ action_manager.do_action(action, function(){
+ window.location.reload();
+ });
+ });
+ },
+ });
+
+
+ instance.web.UserMenu.include({
+ do_update: function() {
+ var self = this;
+ this._super();
+ this.update_promise.then(function() {
+ self.employee = new instance.web.DataSetSearch(self, 'hr.employee', self.session.user_context, [['user_id','=', self.session.uid]]);
+ self.employee.read_slice(['state']).done(self.do_update_attendance_status);
+ });
+ },
+ do_update_attendance_status: function(employee) {
+ if(_.isEmpty(employee)) return;
+ attendance_status = employee[0]['state']
+ self.attendance = new instance.hr_attendance.AttendanceNotifier(attendance_status);
+ self.attendance.appendTo(instance.webclient.$element.find('.oe_systray'))
+ },
+ });
+}
diff --git a/addons/hr_attendance/static/src/js/sign_in_out.js b/addons/hr_attendance/static/src/js/sign_in_out.js
deleted file mode 100644
index b1262fa01d2..00000000000
--- a/addons/hr_attendance/static/src/js/sign_in_out.js
+++ /dev/null
@@ -1,108 +0,0 @@
-openerp.hr_attendance = function(openerp) {
-
- openerp.hr.Attrs_Button = openerp.web.form.WidgetButton.extend({
- init: function(view, node) {
- this._super(view, node);
- },
- on_click: function() {
- var self=this;
- this._super();
- var state = this.node.attrs.states
- if (this.string === 'Sign Out'){
- openerp.webclient.user_menu.hr_sign_out.replace(openerp.webclient.$element.find('.oe_systray').children())
- }
- if (this.string === "Sign In"){
- openerp.webclient.user_menu.hr_sign_in.replace(openerp.webclient.$element.find('.oe_systray').children());
- }
- }
- });
- openerp.web.form.tags.add('att_button', 'openerp.hr.Attrs_Button');
-
- openerp.hr_attendance.SignIn = openerp.web.Widget.extend({
- template: 'SignInNotifier',
- init : function(parent, event){
- this._super(parent)
- this.event = event
- },
- start: function() {
- this.$element.on('click', this.event);
- },
- });
-
- openerp.hr_attendance.SignOut = openerp.web.Widget.extend({
- template: 'SignOutNotifier',
-
- init : function(parent, event){
- this._super(parent)
- this.event = event
- },
-
- start: function() {
- this.$element.on('click', this.event);
- },
-
- });
-
- openerp.hr_attendance.SignInOut = openerp.web.Widget.extend({
- template: "SignInOutNotifier",
- init: function() {
- this._super.apply(this, arguments);
- this.dataset = new openerp.web.DataSetSearch(
- this,
- 'hr.employee',
- this.session.user_context,
- [['user_id','=', this.session.uid]]);
- },
-
- start: function() {
- var self = this;
- //console.log('stttarrrttttt',this.dataset)
- return this.dataset.read_slice(['state']).done(this.do_sign_in_out);
- },
-
- do_sign_in_out: function(user) {
- if(_.isEmpty(user)) return;
- this.$element.html("");
- if(user[0]['state'] === 'present') {
- this.sign_out = new openerp.hr_attendance.SignOut(this, this.on_sign_in_out);
- this.sign_out.appendTo(this.$element);
- } else {
- this.sign_in = new openerp.hr_attendance.SignIn(this, this.on_sign_in_out);
- this.sign_in.appendTo(this.$element);
- }
- },
-
- on_sign_in_out: function(evt) {
- var self = this;
- new openerp.web.DataSetSearch(
- this,
- 'ir.actions.act_window',
- {},
- [['res_model', '=', 'hr.sign.in.out']])
- .read_slice().done(function(action) {
- console.log('action',action);
- action = action[0];
- action.context = JSON.parse(action.context);
- var action_manager = new openerp.web.ActionManager(self);
- action_manager.do_action(action, function() {
- self.dataset.read_slice(['state']).done(self.do_sign_in_out);
- });
- });
- },
- });
-
-
- openerp.web.UserMenu.include({
- do_update: function() {
- var self = this;
- this._super();
- this.update_promise.then(function() {
- self.hr_sign_in_out = new openerp.hr_attendance.SignInOut(self);
- var event = self.hr_sign_in_out.on_sign_in_out
- self.hr_sign_in = new openerp.hr_attendance.SignIn(self, event)
- self.hr_sign_out = new openerp.hr_attendance.SignOut(self, event )
- self.hr_sign_in_out.appendTo(openerp.webclient.$element.find('.oe_systray'))
- });
- }
- });
-}
diff --git a/addons/hr_attendance/static/src/xml/attendance.xml b/addons/hr_attendance/static/src/xml/attendance.xml
new file mode 100644
index 00000000000..104a30530b8
--- /dev/null
+++ b/addons/hr_attendance/static/src/xml/attendance.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/hr_attendance/static/src/xml/sign_in_out.xml b/addons/hr_attendance/static/src/xml/sign_in_out.xml
deleted file mode 100644
index e28b93dfa6c..00000000000
--- a/addons/hr_attendance/static/src/xml/sign_in_out.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py
index 15e8783d660..55edb1406e8 100644
--- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py
+++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py
@@ -69,7 +69,6 @@ class hr_sign_in_out(osv.osv_memory):
_columns = {
'name': fields.char('Employees name', size=32, required=True, readonly=True),
'state': fields.char('Current state', size=32, required=True, readonly=True),
- 'date': fields.datetime('Date'),
'emp_id': fields.many2one('hr.employee', 'Empoyee ID', readonly=True),
}
diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml b/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml
index de57ede7d77..8d4b9ff0123 100644
--- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml
+++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml
@@ -10,15 +10,14 @@
-
-
-
+
+
@@ -65,7 +64,7 @@
-
+
@@ -85,7 +84,7 @@
-
+
diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
index 21d47fae848..c577e33f9c6 100644
--- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
+++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
@@ -91,8 +91,8 @@
-
-
+
+