[IMP] hr_holidays : Improved the field defination, button is properly aligned with...
authorDivyesh Makwana (Open ERP) <mdi@tinyerp.com>
Mon, 26 Mar 2012 11:46:29 +0000 (17:16 +0530)
committerDivyesh Makwana (Open ERP) <mdi@tinyerp.com>
Mon, 26 Mar 2012 11:46:29 +0000 (17:16 +0530)
bzr revid: mdi@tinyerp.com-20120326114629-o5yrzqqa93qzuszt

addons/hr_holidays/hr_holidays.py
addons/hr_holidays/hr_holidays_view.xml

index 3bb7a8e..37d51bb 100644 (file)
@@ -118,8 +118,8 @@ class hr_holidays(osv.osv):
             \nThe state is \'Refused\', when holiday request is refused by manager.\
             \nThe state is \'Approved\', when holiday request is approved by manager.'),
         'user_id':fields.related('employee_id', 'user_id', type='many2one', relation='res.users', string='User', store=True),
-        'date_from': fields.datetime('Start Date', readonly=True, states={'draft':[('readonly',False)]}, select=True),
-        'date_to': fields.datetime('End Date', readonly=True, states={'draft':[('readonly',False)]}),
+        'date_from': fields.date('Start Date', readonly=True, states={'draft':[('readonly',False)]}, select=True),
+        'date_to': fields.date('End Date', readonly=True, states={'draft':[('readonly',False)]}),
         'holiday_status_id': fields.many2one("hr.holidays.status", "Leave Type", required=True,readonly=True, states={'draft':[('readonly',False)]}),
         'employee_id': fields.many2one('hr.employee', "Employee", select=True, invisible=False, readonly=True, states={'draft':[('readonly',False)]}, help='Leave Manager can let this field empty if this leave request/allocation is for every employee'),
         #'manager_id': fields.many2one('hr.employee', 'Leave Manager', invisible=False, readonly=True, help='This area is automatically filled by the user who validate the leave'),
@@ -186,11 +186,11 @@ class hr_holidays(osv.osv):
     def _get_number_of_days(self, date_from, date_to):
         """Returns a float equals to the timedelta between two dates given as string."""
 
-        DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
+        DATETIME_FORMAT = "%Y-%m-%d"
         from_dt = datetime.datetime.strptime(date_from, DATETIME_FORMAT)
         to_dt = datetime.datetime.strptime(date_to, DATETIME_FORMAT)
         timedelta = to_dt - from_dt
-        diff_day = timedelta.days + float(timedelta.seconds) / 86400
+        diff_day = timedelta.days
         return diff_day
 
     def unlink(self, cr, uid, ids, context=None):
@@ -413,8 +413,8 @@ class hr_employee(osv.osv):
 
     def _get_leave_status(self, cr, uid, ids, name, args, context=None):
         holidays_id = self.pool.get('hr.holidays').search(cr, uid, 
-           [('employee_id', 'in', ids), ('date_from','<=',time.strftime('%Y-%m-%d %H:%M:%S')), 
-            ('date_to','>=',time.strftime('%Y-%m-%d %H:%M:%S')),('type','=','remove'),('state','not in',('cancel','refuse'))],
+           [('employee_id', 'in', ids), ('date_from','<=',time.strftime('%Y-%m-%d')), 
+            ('date_to','>=',time.strftime('%Y-%m-%d')),('type','=','remove'),('state','not in',('cancel','refuse'))],
            context=context)
         result = {}
         for id in ids:
index c01bfe9..f74ca86 100644 (file)
@@ -51,6 +51,7 @@
             <field name="type">calendar</field>
             <field name="arch" type="xml">
                 <calendar string="Leave Request" color="user_id" date_start="date_from" date_stop="date_to">
+                    <field name="user_id"/>
                     <field name="holiday_status_id"/>
                 </calendar>
             </field>
@@ -86,9 +87,8 @@
                             <field name="manager_id2" attrs="{'invisible':[('double_validation', '!=', True)]}"/>
                             <separator string="Reasons" colspan="4"/>
                             <field name="notes" nolabel="1" colspan="4"/>
-                            <newline/>
-                            <field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate" statusbar_colors='{"confirm":"blue","validate1":"blue","refuse":"red"}' colspan="2"/>
-                            <group colspan="2" col="6">
+                            <group colspan="4" col="8">
+                                <field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate" statusbar_colors='{"confirm":"blue","validate1":"blue","refuse":"red"}'/>
                                 <button string="Refuse" name="refuse" states="confirm,validate1" type="workflow" icon="gtk-no" groups="base.group_hr_user,base.group_hr_manager"/>
                                 <button string="Confirm" name="confirm" states="draft" type="workflow" icon="gtk-yes"/>
                                 <button string="Approve" name="validate" states="confirm" type="workflow" icon="gtk-apply" groups="base.group_hr_user"/>
                         <field name="manager_id2" attrs="{'invisible':[('double_validation', '!=', True)]}"/>
                         <separator string="Reasons" colspan="4"/>
                         <field name="notes" nolabel="1" colspan="4"/>
-                        <newline/>
-                        <field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate" statusbar_colors='{"confirm":"blue","validate1":"blue","refuse":"red"}' colspan="2"/>
-                        <group colspan="2" col="6">
+                        <group colspan="4" col="8">
+                            <field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate" statusbar_colors='{"confirm":"blue","validate1":"blue","refuse":"red"}'/>
                             <button string="Refuse" name="refuse" states="confirm,validate1" type="workflow" icon="gtk-no" groups="base.group_hr_user"/>
                             <button string="Confirm" name="confirm" states="draft" type="workflow" icon="gtk-yes"/>
                             <button string="Approve" name="validate" states="confirm" type="workflow" icon="gtk-apply" groups="base.group_hr_user"/>
             <field name="res_model">hr.holidays</field>
             <field name="view_type">form</field>
             <field name="view_id" ref="edit_holiday_new"/>
-            <field name="context">{"search_default_department_id": department_id, "search_default_my_leaves": 1}</field>
+            <field name="context">{"search_default_department_id": department_id}</field>
             <field name="domain">[('type','=','remove')]</field>
             <field name="search_view_id" ref="view_hr_holidays_filter"/>
             <field name="help">Leave requests can be recorded by employees and validated by their managers. Once a leave request is validated, it appears automatically in the agenda of the employee. You can define several allowance types (paid holidays, sickness, etc.) and manage allowances per type.</field>