[MERGE] optionnal attendances visible

bzr revid: fp@tinyerp.com-20120927174758-zp58w2phycwm30l7
This commit is contained in:
Fabien Pinckaers 2012-09-27 19:47:58 +02:00
commit 816f50974a
12 changed files with 99 additions and 30 deletions

View File

@ -350,10 +350,8 @@
<field name="arch" type="xml">
<form string="Job" version="7.0">
<header>
<span groups="base.group_user">
<button name="job_recruitement" string="In Recruitement" states="open" type="object" class="oe_highlight"/>
<button name="job_open" string="Recruitment Done" states="recruit" type="object" class="oe_highlight"/>
</span>
<button name="job_recruitement" string="In Recruitement" states="open" type="object" class="oe_highlight" groups="base.group_user"/>
<button name="job_open" string="Recruitment Done" states="recruit" type="object" class="oe_highlight" groups="base.group_user"/>
<field name="state" widget="statusbar" statusbar_visible="recruit,open"/>
</header>
<sheet>

View File

@ -69,7 +69,7 @@
<field name="module_hr_timesheet_sheet" class="oe_inline"/>
<label for="module_hr_timesheet_sheet"/>
</div>
<div>
<div name="hr_attendance">
<field name="module_hr_attendance" on_change="onchange_hr_attendance(module_hr_attendance)" class="oe_inline"/>
<label for="module_hr_attendance"/>
</div>

View File

@ -22,5 +22,6 @@
import hr_attendance
import wizard
import report
import res_config
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -35,14 +35,14 @@ actions(Sign in/Sign out) performed by them.
'images': ['images/hr_attendances.jpeg'],
'depends': ['hr'],
'data': [
'security/ir_rule.xml',
'security/ir.model.access.csv',
'hr_attendance_view.xml',
'hr_attendance_report.xml',
'security/ir.model.access.csv',
'security/ir_rule.xml',
'wizard/hr_attendance_bymonth_view.xml',
'wizard/hr_attendance_byweek_view.xml',
'wizard/hr_attendance_error_view.xml',
'res_config_view.xml',
],
'demo': ['hr_attendance_demo.xml'],
'test': [

View File

@ -126,9 +126,18 @@ class hr_employee(osv.osv):
result[id] = res[0]
return result
def _attendance_access(self, cr, uid, ids, name, args, context=None):
# this function field use to hide attendance button to singin/singout from menu
group = self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'group_hr_attendance')
visible = False
if uid in [user.id for user in group.users]:
visible = True
return dict([(x, visible) for x in ids])
_columns = {
'state': fields.function(_state, type='selection', selection=[('absent', 'Absent'), ('present', 'Present')], string='Attendance'),
'last_sign': fields.function(_last_sign, type='datetime', string='Last Sign'),
'attendance_access': fields.function(_attendance_access, type='boolean'),
}
def _action_check(self, cr, uid, emp_id, dt=False, context=None):

View File

@ -76,9 +76,9 @@
<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_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"/>
<menuitem action="open_view_attendance" id="menu_open_view_attendance" parent="menu_hr_attendance" sequence="20" groups="base.group_hr_attendance"/>
<record id="edit_attendance_reason" model="ir.ui.view">
<field name="name">hr.action.reason.form</field>
@ -114,9 +114,8 @@
</record>
<menuitem
sequence="35" id="hr.menu_open_view_attendance_reason_new_config" parent="hr.menu_hr_configuration" name="Attendance"
groups="base.group_no_one"/>
<menuitem action="open_view_attendance_reason" id="menu_open_view_attendance_reason" parent="hr.menu_open_view_attendance_reason_new_config" groups="base.group_no_one"/>
sequence="35" id="hr.menu_open_view_attendance_reason_new_config" parent="hr.menu_hr_configuration" groups="base.group_hr_attendance" name="Attendance"/>
<menuitem action="open_view_attendance_reason" id="menu_open_view_attendance_reason" parent="hr.menu_open_view_attendance_reason_new_config" groups="base.group_hr_attendance"/>
<record id="hr_attendance_employee" model="ir.ui.view">
<field name="name">hr.employee.form1</field>
@ -124,8 +123,8 @@
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<field name="active" position="before">
<label for="state"/>
<div>
<label for="state" groups="base.group_hr_attendance"/>
<div groups="base.group_hr_attendance">
<field name="state" class="oe_inline"/> -
<button class="oe_link" name="attendance_action_change" states="present" string="Sign Out" type="object" context="{'type':'sign_out'}" groups="base.group_hr_user"/>
<button class="oe_link" name="attendance_action_change" states="absent" string="Sign In" type="object" context="{'type':'sign_in'}" groups="base.group_hr_user"/>

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
class hr_attendance_config_settings(osv.osv_memory):
_inherit = 'hr.config.settings'
_columns = {
'group_hr_attendance': fields.boolean('Track attendances',
implied_group='base.group_hr_attendance',
help="Allocates attendance group to all users."),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="hr_attendace_group" model="ir.ui.view">
<field name="name">hr.config.settings.inherit</field>
<field name="model">hr.config.settings</field>
<field name="inherit_id" ref="hr.view_human_resources_configuration"/>
<field name="arch" type="xml">
<data>
<xpath expr="//div[@name='hr_attendance']" position="after">
<div>
<field name="group_hr_attendance" class="oe_inline"/>
<label for="group_hr_attendance"/>
</div>
</xpath>
</data>
</field>
</record>
</data>
</openerp>

View File

@ -2,6 +2,12 @@
<openerp>
<data noupdate="True">
<record id="base.group_hr_attendance" model="res.groups">
<field name="name">Attendance</field>
<field name="category_id" ref="base.module_category_human_resources"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="property_rule_attendace_manager" model="ir.rule">
<field name="name">Manager Attendance</field>
<field model="ir.model" name="model_id" ref="model_hr_attendance"/>

View File

@ -57,9 +57,12 @@ openerp.hr_attendance = function (instance) {
var employee = new instance.web.DataSetSearch(self, 'hr.employee', self.session.user_context, [
['user_id', '=', self.session.uid]
]);
return employee.read_slice(['id', 'name', 'state', 'last_sign']).pipe(function (res) {
if (_.isEmpty(res))
return employee.read_slice(['id', 'name', 'state', 'last_sign', 'attendance_access']).pipe(function (res) {
if (_.isEmpty(res) )
return;
if (res[0].attendance_access == false){
return;
}
self.$el.show();
self.employee = res[0];
self.last_sign = instance.web.str_to_datetime(self.employee.last_sign);

View File

@ -64,9 +64,9 @@
<field name="company_id" groups="base.group_multi_company"/>
</group>
<group>
<field name="total_attendance" widget="float_time"/>
<field name="total_attendance" widget="float_time" groups="base.group_hr_attendance"/>
<field name="total_timesheet" widget="float_time"/>
<field name="total_difference" widget="float_time"/>
<field name="total_difference" widget="float_time" groups="base.group_hr_attendance"/>
<field name="user_id" invisible="1"/>
</group>
</group>
@ -84,7 +84,7 @@
</div>
</group>
<group colspan="4" col="3">
<field context="{'name':date_current,'user_id':user_id}" name="attendances_ids" nolabel="1">
<field context="{'name':date_current,'user_id':user_id}" name="attendances_ids" nolabel="1" groups="base.group_hr_attendance">
<tree string="Attendances" editable="bottom">
<field name="name"/>
<field name="action"/>
@ -92,14 +92,14 @@
</tree>
</field>
<group>
<div align="right" groups="base.group_hr_manager">
<button name="attendance_action_change" attrs="{'invisible': [('state_attendance', '=', 'present')]}" type="object" string="Sign In"/>
<button name="attendance_action_change" attrs="{'invisible': ['|', ('state_attendance','=',False), ('state_attendance', '=', 'absent')]}" type="object" string="Sign Out"/>
<div align="right" groups="base.group_hr_manager,base.group_hr_attendance">
<button name="attendance_action_change" attrs="{'invisible': [('state_attendance', '=', 'present')]}" type="object" string="Sign In" groups="base.group_hr_attendance"/>
<button name="attendance_action_change" attrs="{'invisible': ['|', ('state_attendance','=',False), ('state_attendance', '=', 'absent')]}" type="object" string="Sign Out" groups="base.group_hr_attendance"/>
</div>
</group>
</group>
<group col="4">
<field name="state_attendance"/>
<field name="state_attendance" groups="base.group_hr_attendance"/>
</group>
<field colspan="4" context="{'date':date_current,'user_id':user_id}" domain="[('name','=',date_current)]" name="timesheet_ids" nolabel="1">
<tree editable="top" string="Timesheet Lines">
@ -134,9 +134,9 @@
<field colspan="4" name="period_ids" nolabel="1">
<tree colors="red:total_difference&lt;0.1;blue:total_difference&gt;=0.1" string="Period">
<field name="name"/>
<field name="total_attendance" widget="float_time"/>
<field name="total_attendance" widget="float_time" groups="base.group_hr_attendance"/>
<field name="total_timesheet" widget="float_time"/>
<field name="total_difference" widget="float_time"/>
<field name="total_difference" widget="float_time" groups="base.group_hr_attendance"/>
</tree>
</field>
</page>
@ -318,9 +318,9 @@
<field name="date_from"/>
<field name="date_to"/>
<field name="department_id"/>
<field name="total_attendance" widget="float_time"/>
<field name="total_attendance" widget="float_time" groups="base.group_hr_attendance"/>
<field name="total_timesheet" widget="float_time"/>
<field name="total_difference" widget="float_time"/>
<field name="total_difference" widget="float_time" groups="base.group_hr_attendance"/>
<field name="state"/>
</tree>
</field>
@ -332,9 +332,9 @@
<field name="arch" type="xml">
<tree colors="blue:total_difference&lt;0.1;red:total_difference&gt;=0.1" string="Period">
<field name="name"/>
<field name="total_attendance" widget="float_time" sum="Total Attendances"/>
<field name="total_attendance" widget="float_time" sum="Total Attendances" groups="base.group_hr_attendance"/>
<field name="total_timesheet" widget="float_time" sum="Total Timesheet"/>
<field name="total_difference" widget="float_time" sum="Total Difference"/>
<field name="total_difference" widget="float_time" sum="Total Difference" groups="base.group_hr_attendance"/>
</tree>
</field>
</record>

View File

@ -97,7 +97,7 @@
<menuitem action="hr_timesheet.action_hr_timesheet_sign_in"
id="menu_hr_timesheet_sign_in"
parent="hr_attendance.menu_hr_attendance"
sequence="5" />
sequence="5" groups="base.group_hr_attendance" />
<menuitem id="menu_project_billing" name="Invoicing"
parent="base.menu_main_pm" sequence="5"/>