[IMP] hr,hr_holidays,hr_timesheet: Improvements

bzr revid: mra@mra-laptop-20100814063132-313jljabcsou013l
This commit is contained in:
PSI(OpenERP) 2010-08-14 12:01:32 +05:30 committed by Mustufa Rangwala
parent 09e8f481b8
commit 68e6021214
6 changed files with 75 additions and 23 deletions

View File

@ -35,8 +35,6 @@ class hr_employee_category(osv.osv):
}
def _check_recursion(self, cr, uid, ids, context=None):
if context is None:
context = {}
level = 100
while len(ids):
cr.execute('select distinct parent_id from hr_employee_category where id IN %s', (tuple(ids), ))
@ -65,8 +63,6 @@ hr_employee_marital_status()
class hr_job(osv.osv):
def _no_of_employee(self, cr, uid, ids, name, args, context=None):
if context is None:
context = {}
res = {}
for emp in self.browse(cr, uid, ids):
res[emp.id] = len(emp.employee_ids or [])
@ -136,8 +132,6 @@ class hr_employee(osv.osv):
}
def _get_photo(self, cr, uid, context=None):
if context is None:
context = {}
return open(os.path.join(
tools.config['addons_path'], 'hr/image', 'photo.png'),
'rb') .read().encode('base64')
@ -157,8 +151,15 @@ class hr_employee(osv.osv):
level -= 1
return True
def _check_department_id(self, cr, uid, ids, context=None):
for emp in self.browse(cr, uid, ids, context=context):
if emp.department_id.manager_id and emp.id == emp.department_id.manager_id.id:
return False
return True
_constraints = [
(_check_recursion, 'Error ! You cannot create recursive Hierarchy of Employees.', ['parent_id'])
(_check_recursion, 'Error ! You cannot create recursive Hierarchy of Employees.', ['parent_id']),
(_check_department_id, 'Error ! You cannot select a department for which the employee is the manager.', ['department_id']),
]
hr_employee()
@ -168,9 +169,7 @@ class hr_department(osv.osv):
_inherit = 'hr.department'
_columns = {
'manager_id': fields.many2one('hr.employee', 'Manager'),
# 'member_ids': fields.many2many('hr.employee', 'hr_department_user_rel', 'department_id', 'user_id', 'Members'),
'member_ids': fields.one2many('hr.employee', 'department_id', 'Members'),
# finding problem to implement one2many field as "hr_departmen_user_rel" is used in another module query
}
hr_department()

View File

@ -19,41 +19,37 @@
<field name="name">Technical department</field>
<field name="parent_id" ref="dep_management"/>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="employee1"/>
<field name="manager_id" ref="employee3"/>
</record>
<record id="dep_it" model="hr.department">
<field name="name">IT</field>
<field name="parent_id" ref="dep_technical"/>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="employee1"/>
</record>
<record id="dep_marketing" model="hr.department">
<field name="name">Marketing</field>
<field name="parent_id" ref="dep_management"/>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="employee1"/>
<field name="manager_id" ref="employee2"/>
</record>
<record id="dep_sales" model="hr.department">
<field name="name">Sales</field>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="employee1"/>
<field name="parent_id" ref="dep_management"/>
</record>
<record id="dep_sales_europe" model="hr.department">
<field name="name">Sales Europe</field>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="employee1"/>
<field name="parent_id" ref="dep_sales"/>
</record>
<record id="dep_sales_america" model="hr.department">
<field name="name">Sales America</field>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="employee1"/>
<field name="parent_id" ref="dep_sales"/>
</record>
@ -110,7 +106,7 @@
</record>
<record id="employee3" model="hr.employee">
<field name="department_id" ref="hr.dep_technical"/>
<field name="department_id" ref="dep_sales"/>
</record>
</data>

View File

@ -1,7 +1,7 @@
-
In order to test the hr_holiday module in OpenERP, I will Allocate leaves for Employee and manage leaves and leaves requests.
-
I create new user "user1" to who makes leave request.
I create new user "user1" who will make leave request.
-
!record {model: res.users, id: res_users_user0}:
company_id: base.main_company

View File

@ -96,8 +96,8 @@
<button name="action_print_survey" string="Print Interview" type="object" icon="gtk-print" attrs="{'readonly':[('survey','=',False)]}"/>
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" icon="gtk-execute" context="{'survey_id': survey, 'response_id': [response], 'response_no':0 ,'active' : response, 'object' : 'hr.applicant', 'cur_id' :active_id}" attrs="{'readonly':[('survey','=',False)]}" groups="base.group_extended"/>
<newline/>
<field name="date_action"/>
<field name="title_action"/>
<field name="date_action"/>
<field name="title_action"/>
</group>
<notebook colspan="4">
<page string="Job Info">
@ -106,7 +106,7 @@
<field name="partner_id" on_change="onchange_partner_id(partner_id, email_from)" />
<button string="Create Partner"
name="%(action_hr_recruitment_partner_create)d"
icon="terp-mail-replied" type="action"/>
icon="terp-mail-replied" type="action" attrs="{'readonly':[('partner_id','!=',False)]}"/>
<newline/>
<field name="partner_address_id" on_change="onchange_partner_address_id(partner_address_id, email_from)" colspan="3"/>
<field name="email_from" colspan="3"/>

View File

@ -22,8 +22,8 @@
<field name="journal_id" ref="analytic_journal"/>
</record>
<record id="working_hours" model="hr.analytic.timesheet">
<field name="name">Working Hours For OpenERP SA</field>
<record id="working_hours_requirements" model="hr.analytic.timesheet">
<field name="name">Requirements analysis and specification</field>
<field name="user_id" ref="base.user_root"/>
<field eval="time.strftime('%Y-%m-%d')" name="date"/>
<field eval="0.00" name="unit_amount"/>
@ -35,5 +35,58 @@
<field name="journal_id" ref="analytic_journal"/>
</record>
<record id="working_hours_design" model="hr.analytic.timesheet">
<field name="name">Design and specification</field>
<field name="user_id" ref="base.user_root"/>
<field eval="time.strftime('%Y-%m-%d')" name="date"/>
<field eval="0.00" name="unit_amount"/>
<field name="product_id" ref="product_consultant"/>
<field name="product_uom_id" ref="product.uom_hour"/>
<field name="account_id" model="account.analytic.account" search="[('code','=','1')]"></field>
<field eval="0.00" name="amount"/>
<field name="general_account_id" model="account.account" ref="account.a_expense"/>
<field name="journal_id" ref="analytic_journal"/>
</record>
<record id="working_hours_coding" model="hr.analytic.timesheet">
<field name="name">Coding and module testing</field>
<field name="user_id" ref="base.user_root"/>
<field eval="time.strftime('%Y-%m-%d')" name="date"/>
<field eval="0.00" name="unit_amount"/>
<field name="product_id" ref="product_consultant"/>
<field name="product_uom_id" ref="product.uom_hour"/>
<field name="account_id" model="account.analytic.account" search="[('code','=','1')]"></field>
<field eval="0.00" name="amount"/>
<field name="general_account_id" model="account.account" ref="account.a_expense"/>
<field name="journal_id" ref="analytic_journal"/>
</record>
<record id="working_hours_testing" model="hr.analytic.timesheet">
<field name="name">Integration and system testing</field>
<field name="user_id" ref="base.user_root"/>
<field eval="time.strftime('%Y-%m-%d')" name="date"/>
<field eval="0.00" name="unit_amount"/>
<field name="product_id" ref="product_consultant"/>
<field name="product_uom_id" ref="product.uom_hour"/>
<field name="account_id" model="account.analytic.account" search="[('code','=','1')]"></field>
<field eval="0.00" name="amount"/>
<field name="general_account_id" model="account.account" ref="account.a_expense"/>
<field name="journal_id" ref="analytic_journal"/>
</record>
<record id="working_hours_maintenance" model="hr.analytic.timesheet">
<field name="name">Delivery and maintenance</field>
<field name="user_id" ref="base.user_root"/>
<field eval="time.strftime('%Y-%m-%d')" name="date"/>
<field eval="0.00" name="unit_amount"/>
<field name="product_id" ref="product_consultant"/>
<field name="product_uom_id" ref="product.uom_hour"/>
<field name="account_id" model="account.analytic.account" search="[('code','=','1')]"></field>
<field eval="0.00" name="amount"/>
<field name="general_account_id" model="account.account" ref="account.a_expense"/>
<field name="journal_id" ref="analytic_journal"/>
</record>
</data>
</openerp>

View File

@ -49,6 +49,10 @@
<field name="arch" type="xml">
<search string="Timesheet">
<group col='8' colspan='4'>
<filter icon="terp-personal+"
domain="[('user_id','=',uid)]"
string="My Working Hours" name="my" default="1"/>
<separator orientation="vertical"/>
<filter icon="terp-go-today" domain="[('date', '=', time.strftime('%%Y-%%m-%%d'))]" string="Today"/>
<separator orientation="vertical"/>
<field name="user_id"/>
@ -70,7 +74,7 @@
<field name="view_mode">tree,form</field>
<field name="domain">[('user_id','=',uid)]</field>
<field name="filter" eval="True"/>
<field name="context">{"search_default_user_id":uid}</field>
<field name="context">{"search_default_user_id":uid, "search_default_my": 1}</field>
<field name="search_view_id" ref="hr_timesheet_line_search"/>
</record>