[WIP] hr_attendance graphview: moved graph declaration inside hr_attendance_view.xml, removed the useless day field on hr.attendance model, fixed the groupby so that se graphview allows to group by day, week, etc.
bzr revid: sle@openerp.com-20140423095409-wab11nwouwnz43og
This commit is contained in:
@@ -44,7 +44,6 @@ actions(Sign in/Sign out) performed by them.
|
||||
'wizard/hr_attendance_error_view.xml',
|
||||
'res_config_view.xml',
|
||||
'views/report_attendanceerrors.xml',
|
||||
'data/attendance_graphview.xml',
|
||||
],
|
||||
'demo': ['hr_attendance_demo.xml'],
|
||||
'test': [
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_hr_attendance_graph" model="ir.ui.view">
|
||||
<field name="name">hr.attendance.graph</field>
|
||||
<field name="model">hr.attendance</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Attendance" type="pivot">
|
||||
<field name="employee_id" type="row"/>
|
||||
<field name="name" type="col"/>
|
||||
<field name="worked_hours" type="measure"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="action_hr_attendance_graph" model="ir.actions.act_window">
|
||||
<field name="name">Attendance</field>
|
||||
<field name="res_model">hr.attendance</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph</field>
|
||||
<field name="view_id" ref="view_hr_attendance_graph"/>
|
||||
</record>
|
||||
|
||||
|
||||
<menuitem
|
||||
action="action_hr_attendance_graph"
|
||||
id="menu_hr_attendance_graph"
|
||||
parent="hr.menu_hr_reporting"
|
||||
sequence="3"
|
||||
/>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
import time
|
||||
from datetime import datetime
|
||||
import math
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
@@ -46,12 +45,6 @@ class hr_attendance(osv.osv):
|
||||
_name = "hr.attendance"
|
||||
_description = "Attendance"
|
||||
|
||||
def _day_compute(self, cr, uid, ids, fieldnames, args, context=None):
|
||||
res = dict.fromkeys(ids, '')
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
res[obj.id] = time.strftime('%Y-%m-%d', time.strptime(obj.name, '%Y-%m-%d %H:%M:%S'))
|
||||
return res
|
||||
|
||||
def _worked_hours_compute(self, cr, uid, ids, fieldnames, args, context=None):
|
||||
"""For each hr.attendance record of action sign-in: assign 0.
|
||||
For each hr.attendance record of action sign-out: assign number of hours since last sign-in.
|
||||
@@ -80,7 +73,6 @@ class hr_attendance(osv.osv):
|
||||
'action': fields.selection([('sign_in', 'Sign In'), ('sign_out', 'Sign Out'), ('action','Action')], 'Action', required=True),
|
||||
'action_desc': fields.many2one("hr.action.reason", "Action Reason", domain="[('action_type', '=', action)]", help='Specifies the reason for Signing In/Signing Out in case of extra hours.'),
|
||||
'employee_id': fields.many2one('hr.employee', "Employee", required=True, select=True),
|
||||
'day': fields.function(_day_compute, type='char', string='Day', store=True, select=1, size=32),
|
||||
'worked_hours': fields.function(_worked_hours_compute, type='float', string='Worked Hours', store=True),
|
||||
}
|
||||
_defaults = {
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
<field name="employee_id"/>
|
||||
<field name="name"/>
|
||||
<field name="action"/>
|
||||
<field name="day" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -53,17 +52,30 @@
|
||||
<field name="name" string="Attendance"/>
|
||||
<field name="action"/>
|
||||
<filter icon="terp-go-today" string="Today" name="today" domain="[('name','>=',current_date),('name','<=',current_date)]" />
|
||||
<filter string="Current Month" domain="[('name','>=', datetime.datetime.now().strftime('%Y-%m-01'))]" />
|
||||
<separator/>
|
||||
<filter icon="terp-stock_align_left_24" string="My Attendance" domain="[('employee_id.user_id.id', '=', uid)]" />
|
||||
<field name="employee_id"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter name="employee" string="Employee" icon="terp-personal" domain="[]" context="{'group_by':'employee_id'}"/>
|
||||
<filter string="Day" icon="terp-go-today" domain="[]" context="{'group_by':'day'}"/>
|
||||
<filter name="name" string="Date" icon="terp-personal" domain="[]" context="{'group_by':'name'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_hr_attendance_graph" model="ir.ui.view">
|
||||
<field name="name">hr.attendance.graph</field>
|
||||
<field name="model">hr.attendance</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Attendance" type="pivot">
|
||||
<field name="employee_id" type="row"/>
|
||||
<field name="name" type="col"/>
|
||||
<field name="worked_hours" type="measure"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="open_view_attendance" model="ir.actions.act_window">
|
||||
<field name="name">Attendances</field>
|
||||
<field name="res_model">hr.attendance</field>
|
||||
@@ -74,12 +86,27 @@
|
||||
<field name="help">The Time Tracking functionality aims to manage employee attendances from Sign in/Sign out actions. You can also link this feature to an attendance device using OpenERP's web service features.</field>
|
||||
</record>
|
||||
|
||||
<record id="action_hr_attendance_graph" model="ir.actions.act_window">
|
||||
<field name="name">Attendance</field>
|
||||
<field name="res_model">hr.attendance</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph</field>
|
||||
<field name="view_id" ref="view_hr_attendance_graph"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_hr_time_tracking" name="Time Tracking" parent="hr.menu_hr_root" sequence="5" groups="base.group_user,base.group_hr_user,base.group_hr_manager"/>
|
||||
|
||||
<menuitem id="menu_hr_attendance" name="Attendances" parent="hr.menu_hr_root" sequence="10" groups="base.group_hr_attendance"/>
|
||||
|
||||
<menuitem action="open_view_attendance" id="menu_open_view_attendance" parent="menu_hr_attendance" sequence="20" groups="base.group_hr_attendance"/>
|
||||
|
||||
<menuitem
|
||||
action="action_hr_attendance_graph"
|
||||
id="menu_hr_attendance_graph"
|
||||
parent="hr.menu_hr_reporting"
|
||||
sequence="3"
|
||||
/>
|
||||
|
||||
<record id="edit_attendance_reason" model="ir.ui.view">
|
||||
<field name="name">hr.action.reason.form</field>
|
||||
<field name="model">hr.action.reason</field>
|
||||
|
||||
Reference in New Issue
Block a user