Merge lp:~openerp-dev/openobject-addons/trunk-addons19-hr-pna into lp:openobject-addons

Proposed by Pinakin Nayi (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-addons19-hr-pna
Merge into: lp:openobject-addons
Diff against target: 114 lines (+24/-22)
2 files modified
hr_attendance/hr_attendance.py (+22/-20)
hr_timesheet/wizard/hr_timesheet_sign_in_out.py (+2/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-addons19-hr-pna
Reviewer Review Type Date Requested Status
DJ Patel (OpenERP) (community) Disapprove
Mayur Maheshwari(OpenERP) Pending
Review via email: mp+130957@code.launchpad.net

Description of the change

Hello Sir,

 I improved string in Hr => Tracking => Timesheets from his to is.

Thanks,
pna

To post a comment you must log in.
7836. By Pinakin Nayi (OpenERP)

[MERGE]with trunk

7837. By Pinakin Nayi (OpenERP)

[IMP]hr attendance sign in sign out problem

7838. By Pinakin Nayi (OpenERP)

[IMP]employee cannot sign out before sign in

Revision history for this message
DJ Patel (OpenERP) (mdi-openerp) wrote :

Hello Pinakin,

Sign in - Sign out must not allow overlaps with each other. Please fix the problem.

Thanks,
Divyesh

review: Needs Fixing
Revision history for this message
DJ Patel (OpenERP) (mdi-openerp) wrote :

Current trunk behaviour is right, We cannot allow Sign-in and Sign-out to overlaps with each other.

For more details see the following bug and its related mp:

Bug : https://bugs.launchpad.net/openobject-addons/+bug/885387

MP : https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-885387-mdi/+merge/86388

So, I am rejecting this merge proposal.

Thanks,
Divyesh

review: Disapprove

Unmerged revisions

7838. By Pinakin Nayi (OpenERP)

[IMP]employee cannot sign out before sign in

7837. By Pinakin Nayi (OpenERP)

[IMP]hr attendance sign in sign out problem

7836. By Pinakin Nayi (OpenERP)

[MERGE]with trunk

7835. By Pinakin Nayi (OpenERP)

[IMP]improve string

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_attendance/hr_attendance.py'
2--- hr_attendance/hr_attendance.py 2012-10-21 19:59:25 +0000
3+++ hr_attendance/hr_attendance.py 2012-10-31 11:29:22 +0000
4@@ -70,17 +70,18 @@
5 """
6 for att in self.browse(cr, uid, ids, context=context):
7 # search and browse for first previous and first next records
8- prev_att_ids = self.search(cr, uid, [('employee_id', '=', att.employee_id.id), ('name', '<', att.name), ('action', 'in', ('sign_in', 'sign_out'))], limit=1, order='name DESC')
9- next_add_ids = self.search(cr, uid, [('employee_id', '=', att.employee_id.id), ('name', '>', att.name), ('action', 'in', ('sign_in', 'sign_out'))], limit=1, order='name ASC')
10- prev_atts = self.browse(cr, uid, prev_att_ids, context=context)
11- next_atts = self.browse(cr, uid, next_add_ids, context=context)
12- # check for alternance, return False if at least one condition is not satisfied
13- if prev_atts and prev_atts[0].action == att.action: # previous exists and is same action
14- return False
15- if next_atts and next_atts[0].action == att.action: # next exists and is same action
16- return False
17- if (not prev_atts) and (not next_atts) and att.action != 'sign_in': # first attendance must be sign_in
18- return False
19+ emp_obj = self.pool.get('hr.employee')
20+ warning_sign = {'sign_in': _('Sign In'), 'sign_out': _('Sign Out'), 'action': _('Change Work')}
21+ emp = emp_obj.browse(cr, uid, att.employee_id.id, context=context)
22+ #if employee state is present than attendance action must be sign in
23+ if emp.state == 'present':
24+ if att.action == 'sign_out':
25+ if not emp_obj._action_check(cr, uid, att.employee_id.id, att.name, context):
26+ raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the HR Manager to correct attendances.')%(warning_sign[att.action],))
27+ return False
28+ if emp.state == 'absent':
29+ if att.action == 'sign_in':
30+ return False
31 return True
32
33 _constraints = [(_altern_si_so, 'Error ! Sign in (resp. Sign out) must follow Sign out (resp. Sign in)', ['action'])]
34@@ -100,15 +101,15 @@
35 result[id] = 'absent'
36 cr.execute('SELECT hr_attendance.action, hr_attendance.employee_id \
37 FROM ( \
38- SELECT MAX(name) AS name, employee_id \
39+ SELECT name AS name, employee_id \
40 FROM hr_attendance \
41 WHERE action in (\'sign_in\', \'sign_out\') \
42- GROUP BY employee_id \
43+ GROUP BY name,employee_id \
44 ) AS foo \
45 LEFT JOIN hr_attendance \
46 ON (hr_attendance.employee_id = foo.employee_id \
47 AND hr_attendance.name = foo.name) \
48- WHERE hr_attendance.employee_id IN %s',(tuple(ids),))
49+ WHERE hr_attendance.employee_id IN %s order by id',(tuple(ids),))
50 for res in cr.fetchall():
51 result[res[1]] = res[0] == 'sign_in' and 'present' or 'absent'
52 return result
53@@ -119,9 +120,9 @@
54 return result
55 for id in ids:
56 result[id] = False
57- cr.execute("""select max(name) as name
58+ cr.execute("""select name as name
59 from hr_attendance
60- where action in ('sign_in', 'sign_out') and employee_id = %s""",(id,))
61+ where action in ('sign_in', 'sign_out') and employee_id = %s order by id desc limit 1""",(id,))
62 for res in cr.fetchall():
63 result[id] = res[0]
64 return result
65@@ -141,7 +142,7 @@
66 }
67
68 def _action_check(self, cr, uid, emp_id, dt=False, context=None):
69- cr.execute('SELECT MAX(name) FROM hr_attendance WHERE employee_id=%s', (emp_id,))
70+ cr.execute('SELECT name FROM hr_attendance where employee_id=%s and action in (\'sign_in\',\'action\') order by id desc limit 1', (emp_id,))
71 res = cr.fetchone()
72 return not (res and (res[0]>=(dt or time.strftime('%Y-%m-%d %H:%M:%S'))))
73
74@@ -151,14 +152,15 @@
75 action_date = context.get('action_date', False)
76 action = context.get('action', False)
77 hr_attendance = self.pool.get('hr.attendance')
78- warning_sign = {'sign_in': _('Sign In'), 'sign_out': _('Sign Out')}
79+ warning_sign = {'sign_in': _('Sign In'), 'sign_out': _('Sign Out'), 'action': _('Change Work')}
80 for employee in self.browse(cr, uid, ids, context=context):
81 if not action:
82 if employee.state == 'present': action = 'sign_out'
83 if employee.state == 'absent': action = 'sign_in'
84
85- if not self._action_check(cr, uid, employee.id, action_date, context):
86- raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the HR Manager to correct attendances.')%(warning_sign[action],))
87+ if action != 'sign_in':
88+ if not self._action_check(cr, uid, employee.id, action_date, context):
89+ raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the HR Manager to correct attendances.')%(warning_sign[action],))
90
91 vals = {'action': action, 'employee_id': employee.id}
92 if action_date:
93
94=== modified file 'hr_timesheet/wizard/hr_timesheet_sign_in_out.py'
95--- hr_timesheet/wizard/hr_timesheet_sign_in_out.py 2012-10-24 20:14:24 +0000
96+++ hr_timesheet/wizard/hr_timesheet_sign_in_out.py 2012-10-31 11:29:22 +0000
97@@ -47,7 +47,7 @@
98
99 def _get_empid2(self, cr, uid, context=None):
100 res = self._get_empid(cr, uid, context=context)
101- cr.execute('select name,action from hr_attendance where employee_id=%s order by name desc limit 1', (res['emp_id'],))
102+ cr.execute('select name,action from hr_attendance where employee_id=%s order by id desc limit 1', (res['emp_id'],))
103
104 res['server_date'] = time.strftime('%Y-%m-%d %H:%M:%S')
105 date_start = cr.fetchone()
106@@ -136,7 +136,7 @@
107 obj_model = self.pool.get('ir.model.data')
108 emp_id = self.default_get(cr, uid, context)['emp_id']
109 # get the latest action (sign_in or out) for this employee
110- cr.execute('select action from hr_attendance where employee_id=%s and action in (\'sign_in\',\'sign_out\') order by name desc limit 1', (emp_id,))
111+ cr.execute('select action from hr_attendance where employee_id=%s and action in (\'sign_in\',\'sign_out\') order by id desc limit 1', (emp_id,))
112 res = (cr.fetchone() or ('sign_out',))[0]
113 in_out = (res == 'sign_out') and 'in' or 'out'
114 #TODO: invert sign_in et sign_out

Subscribers

People subscribed via source and target branches

to all changes: