Mayur Maheshwari(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-opw-577297-port-mma into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-577297-port-mma/+merge/132533

Hello,

Currently it is not possible to fill the attendance of some days before from
current date. User end up with warning.

Steps to reproduce:
-Suppose I have filled all my attendance till 17th August 2012
  except 14th August.
- If I try to create attendance of 14th, it raises warning

Code is forward port from 6.1

Thanks,
Mayur
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-577297-port-mma/+merge/132533
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-opw-577297-port-mma.
=== modified file 'hr_attendance/hr_attendance.py'
--- hr_attendance/hr_attendance.py	2012-10-21 19:59:25 +0000
+++ hr_attendance/hr_attendance.py	2012-11-01 12:13:22 +0000
@@ -66,7 +66,7 @@
     def _altern_si_so(self, cr, uid, ids, context=None):
         """ Alternance sign_in/sign_out check.
             Previous (if exists) must be of opposite action.
-            Next (if exists) must be of opposite action.
+            Next (if exists and on the same day) must be of opposite action.
         """
         for att in self.browse(cr, uid, ids, context=context):
             # search and browse for first previous and first next records
@@ -75,11 +75,15 @@
             prev_atts = self.browse(cr, uid, prev_att_ids, context=context)
             next_atts = self.browse(cr, uid, next_add_ids, context=context)
             # check for alternance, return False if at least one condition is not satisfied
-            if prev_atts and prev_atts[0].action == att.action: # previous exists and is same action
-                return False
-            if next_atts and next_atts[0].action == att.action: # next exists and is same action
-                return False
-            if (not prev_atts) and (not next_atts) and att.action != 'sign_in': # first attendance must be sign_in
+            if prev_atts and prev_atts[0].action == att.action:
+                # previous exists and is same action
+                return False
+            if next_atts and next_atts[0].action == att.action and next_atts[0].day == att.day:
+                # next exists and is same action on the same day;
+                # this allows to "fix attendances" by adding attendances on a former day
+             return False
+            if (not prev_atts) and (not next_atts) and att.action != 'sign_in':
+                # first attendance must be sign_in
                 return False
         return True
 

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to