Get taks of projects and childs when clicking on a project
HR
	Add department structure
HR_Timesheet
	Timesheets of my department menu

bzr revid: fp@tinyerp.com-f75e046f17c24b31b7e141428c108630e907440d
This commit is contained in:
Fabien Pinckaers 2007-06-19 17:01:25 +00:00
parent b807b1728b
commit e3bf7892b5
8 changed files with 334 additions and 2 deletions

View File

@ -1,3 +1,34 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import hr
import hr_department
import report
import wizard

View File

@ -16,7 +16,12 @@
"depends" : ["base"],
"init_xml" : [],
"demo_xml" : ["hr_demo.xml", "hr_bel_holidays_2005.xml"],
"update_xml" : ["hr_view.xml", "hr_report.xml", "hr_wizard.xml"],
"update_xml" : [
"hr_view.xml",
"hr_report.xml",
"hr_wizard.xml",
"hr_department_view.xml"
],
"active": False,
"installable": True
}

View File

@ -0,0 +1,76 @@
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from osv import fields,osv
import tools
#class res_users(osv.osv):
# _inherit = "res.users"
# def _compute_manager_ids(self, cr, uid, ids, name, args, context):
# res = {}
# for id in ids:
# cr.execute("""SELECT
# distinct manager_id
# from
# hr_department
# where
# id in (select department_id from hr_department_user_rel where user_id=%d)""", (id,))
# res[id] = map(lambda x: x[0], cr.fetchall() or []) + [id]
# return res
#
# _columns = {
# 'manager_ids': fields.function(_compute_manager_ids, method=True, string='Members', type="many2many", relation="res.users"),
# }
#res_users()
class hr_department(osv.osv):
_name = "hr.department"
_columns = {
'name': fields.char('Department Name', size=64, required=True),
'company_id': fields.many2one('res.company', 'Company', select=True, required=True),
'parent_id': fields.many2one('hr.department', 'Parent Department', select=True),
'child_ids': fields.one2many('hr.department', 'parent_id', 'Childs Departments'),
'note': fields.text('Note'),
'manager_id': fields.many2one('res.users', 'Manager', required=True),
'member_ids': fields.many2many('res.users', 'hr_department_user_rel', 'department_id', 'user_id', 'Members'),
}
def _check_recursion(self, cr, uid, ids):
level = 100
while len(ids):
cr.execute('select distinct parent_id from hr_department where id in ('+','.join(map(str,ids))+')')
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False
level -= 1
return True
_constraints = [
(_check_recursion, 'Error! You can not create recursive departments.', ['parent_id'])
]
hr_department()

View File

@ -0,0 +1,64 @@
<?xml version="1.0"?>
<terp>
<data>
<!--
======================
department
======================
-->
<record model="ir.ui.view" id="view_department_form">
<field name="name">hr.department.form</field>
<field name="model">hr.department</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="department">
<notebook>
<page string="Department">
<field name="name" colspan="4" select="1"/>
<field name="company_id" select="1"/>
<field name="parent_id" select="2"/>
<field name="manager_id" select="1" colspan="4"/>
<field name="member_ids" colspan="4"/>
</page><page string="Notes">
<field name="note" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_department_tree">
<field name="name">hr.department.tree</field>
<field name="model">hr.department</field>
<field name="type">tree</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree string="Companies">
<field name="name"/>
<field name="company_id"/>
<field name="manager_id"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="open_module_tree_department_tree">
<field name="name">Departments</field>
<field name="res_model">hr.department</field>
<field name="view_type">tree</field>
<field name="domain">[('parent_id','=',False)]</field>
</record>
<menuitem name="Human Resources/Configuration/Departments"
action="open_module_tree_department_tree"
id="menu_department_tree"/>
<record model="ir.actions.act_window" id="open_module_tree_department">
<field name="name">Departments</field>
<field name="res_model">hr.department</field>
<field name="view_type">form</field>
</record>
<menuitem name="Human Resources/Configuration/Departments/Define departments"
action="open_module_tree_department"
id="menu_department_def"/>
</data>
</terp>

View File

@ -160,6 +160,40 @@
id="menu_act_hr_timesheet_sheet_form_my_confirm"
action="act_hr_timesheet_sheet_form_my_confirm" />
<wizard string="My department's timesheet"
model="hr.employee"
name="hr_timesheet_sheet.department.open"
id="act_hr_timesheet_sheet_form_department_current"/>
<menuitem name="Human Resources/Timesheets/My department's timesheets"
id="menu_act_hr_timesheet_sheet_form_department_current"
action="act_hr_timesheet_sheet_form_department_current"
icon="STOCK_JUSTIFY_FILL"
type="wizard"/>
<wizard string="My department's timesheet"
model="hr.employee"
name="hr_timesheet_sheet.department.validate.open"
id="act_hr_timesheet_sheet_form_department_validate"/>
<menuitem name="Human Resources/Timesheets/My department's timesheets/Timesheets to validate"
id="menu_act_hr_timesheet_sheet_form_department_validate"
action="act_hr_timesheet_sheet_form_department_validate"
icon="STOCK_JUSTIFY_FILL"
type="wizard"/>
<wizard string="My department's timesheet"
model="hr.employee"
name="hr_timesheet_sheet.department.confirm.open"
id="act_hr_timesheet_sheet_form_department_confirm"/>
<menuitem name="Human Resources/Timesheets/My department's timesheets/Timesheets to confirm"
id="menu_act_hr_timesheet_sheet_form_department_confirm"
action="act_hr_timesheet_sheet_form_department_confirm"
icon="STOCK_JUSTIFY_FILL"
type="wizard"/>
<wizard string="My current timesheet"
model="hr.employee"
name="hr_timesheet_sheet.current.open"
@ -167,6 +201,7 @@
<menuitem name="Human Resources/Timesheets/My timesheets/My current timesheet"
id="menu_act_hr_timesheet_sheet_form_my_current"
action="act_hr_timesheet_sheet_form_my_current"
icon="STOCK_NEW"
type="wizard"/>
<record model="ir.actions.act_window" id="act_hr_timesheet_sheet_form_all_confirm">

View File

@ -28,3 +28,4 @@
##############################################################################
import wizard_timesheet_current
import wizard_timesheet_department

View File

@ -0,0 +1,120 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: sign_in_out.py 2871 2006-04-25 14:08:22Z ged $
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import netsvc
import time
import pooler
from osv import osv
class wiz_timesheet_open(wizard.interface):
def _open_timesheet(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
dep_ids = pool.get('hr.department').search(cr, uid, [('manager_id','=',uid)])
user_ids = {}
for dep in pool.get('hr.department').browse(cr, uid, dep_ids, context):
for user in dep.member_ids:
user_ids[user.id] = 1
value = {
'domain': "[('user_id', 'in', "+str(user_ids.keys())+")]",
'name': 'Timesheets',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'hr_timesheet_sheet.sheet',
'view_id': False,
'type': 'ir.actions.act_window'
}
return value
states = {
'init' : {
'actions' : [],
'result' : {'type':'action', 'action':_open_timesheet, 'state':'end'}
}
}
wiz_timesheet_open('hr_timesheet_sheet.department.open')
class wiz_timesheet_confirm_open(wizard.interface):
def _open_timesheet(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
dep_ids = pool.get('hr.department').search(cr, uid, [('manager_id','=',uid)])
user_ids = {}
for dep in pool.get('hr.department').browse(cr, uid, dep_ids, context):
for user in dep.member_ids:
user_ids[user.id] = 1
value = {
'domain': "[('user_id', 'in', "+str(user_ids.keys())+"),('state','=','draft')]",
'name': 'Timesheets',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'hr_timesheet_sheet.sheet',
'view_id': False,
'type': 'ir.actions.act_window'
}
return value
states = {
'init' : {
'actions' : [],
'result' : {'type':'action', 'action':_open_timesheet, 'state':'end'}
}
}
wiz_timesheet_confirm_open('hr_timesheet_sheet.department.confirm.open')
class wiz_timesheet_validate_open(wizard.interface):
def _open_timesheet(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
dep_ids = pool.get('hr.department').search(cr, uid, [('manager_id','=',uid)])
user_ids = {}
for dep in pool.get('hr.department').browse(cr, uid, dep_ids, context):
for user in dep.member_ids:
user_ids[user.id] = 1
value = {
'domain': "[('user_id', 'in', "+str(user_ids.keys())+"),('state','=','confirm')]",
'name': 'Timesheets',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'hr_timesheet_sheet.sheet',
'view_id': False,
'type': 'ir.actions.act_window'
}
return value
states = {
'init' : {
'actions' : [],
'result' : {'type':'action', 'action':_open_timesheet, 'state':'end'}
}
}
wiz_timesheet_validate_open('hr_timesheet_sheet.department.validate.open')
# vim:noexpandtab:tw=0

View File

@ -359,7 +359,7 @@
<field name="name">Project's tasks</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('project_id', '=', active_id)]</field>
<field name="domain">[('project_id', 'child_of', active_id)]</field>
</record>
<record model="ir.values" id="ir_project_task_open">
<field name="key2" eval=" 'tree_but_open'" />