[IMP] HR : Employee,Department search view added. coach_id added in employee. Full name display in department object.
bzr revid: vir@tinyerp.com-20100217052553-sefa7ohcui06vnst
This commit is contained in:
@@ -85,6 +85,7 @@ class hr_employee(osv.osv):
|
||||
'category_id' : fields.many2one('hr.employee.category', 'Category'),
|
||||
'child_ids': fields.one2many('hr.employee', 'parent_id','Subordinates'),
|
||||
'resource_id': fields.many2one('resource.resource','Resource',ondelete='cascade'),
|
||||
'coach_id':fields.many2one('res.users','Coach'),
|
||||
}
|
||||
_defaults = {
|
||||
'active' : lambda *a: True,
|
||||
|
||||
@@ -23,9 +23,27 @@ from osv import fields,osv
|
||||
import tools
|
||||
|
||||
class hr_department(osv.osv):
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
if not len(ids):
|
||||
return []
|
||||
reads = self.read(cr, uid, ids, ['name','parent_id'], context)
|
||||
res = []
|
||||
for record in reads:
|
||||
name = record['name']
|
||||
if record['parent_id']:
|
||||
name = record['parent_id'][1]+' / '+name
|
||||
res.append((record['id'], name))
|
||||
return res
|
||||
|
||||
def _dept_name_get_fnc(self, cr, uid, ids, prop, unknow_none, context):
|
||||
res = self.name_get(cr, uid, ids, context)
|
||||
return dict(res)
|
||||
|
||||
_name = "hr.department"
|
||||
_columns = {
|
||||
'name': fields.char('Department Name', size=64, required=True),
|
||||
'complete_name': fields.function(_dept_name_get_fnc, method=True, type="char", string='Name'),
|
||||
'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', 'Child Departments'),
|
||||
@@ -148,4 +166,11 @@ class res_users(osv.osv):
|
||||
}
|
||||
res_users()
|
||||
|
||||
class department(osv.osv):
|
||||
_inherit = 'res.users'
|
||||
_description = "Users"
|
||||
_columns = {
|
||||
'context_department_id': fields.many2one('hr.department', 'Departments'),
|
||||
}
|
||||
department()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -37,17 +37,31 @@
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Companies">
|
||||
<field name="name"/>
|
||||
<field name="complete_name"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="manager_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_department_filter" model="ir.ui.view">
|
||||
<field name="name">Departments</field>
|
||||
<field name="model">hr.department</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Departments">
|
||||
<group col='4' colspan='4'>
|
||||
<field name="name"/>
|
||||
<field name="manager_id" widget="selection"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
<record id="open_module_tree_department_tree" model="ir.actions.act_window">
|
||||
<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>
|
||||
<field name="search_view_id" ref="view_department_filter"/>
|
||||
</record>
|
||||
<menuitem action="open_module_tree_department_tree" id="menu_department_tree" parent="base.menu_users"/>
|
||||
|
||||
@@ -55,10 +69,35 @@
|
||||
<field name="name">Departments</field>
|
||||
<field name="res_model">hr.department</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="search_view_id" ref="view_department_filter"/>
|
||||
</record>
|
||||
|
||||
<menuitem action="open_module_tree_department" id="menu_department_def" parent="hr.menu_department_tree"/>
|
||||
<menuitem action="open_module_tree_department" id="menu_hr_department_tree" parent="menu_hr_human_resources"/>
|
||||
|
||||
<record model="ir.ui.view" id="view_department_form_simple_modif_inherited1">
|
||||
<field name="name">view.department.form.hr.inherited1</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<page string="Current Activity" position="inside">
|
||||
<field name="context_department_id" widget="selection" />
|
||||
</page>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_department_form_simple_modif_inherited2" model="ir.ui.view">
|
||||
<field name="name">view.department.form.hr.inherited2</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.view_users_form"/>
|
||||
<field eval="18" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="password" position="after">
|
||||
<field name="context_department_id" completion="1" widget="selection"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
+22
-5
@@ -64,7 +64,7 @@
|
||||
<group col="4" colspan="2">
|
||||
<separator string="Job Information" colspan="4"/>
|
||||
<field name="parent_id" select="1" colspan="4"/>
|
||||
|
||||
<field name="coach_id" select="1" colspan="4"/>
|
||||
<field name="category_id" colspan="4" widget="selection"/>
|
||||
</group>
|
||||
</page>
|
||||
@@ -91,6 +91,20 @@
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_employee_filter" model="ir.ui.view">
|
||||
<field name="name">Employees</field>
|
||||
<field name="model">hr.employee</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Employees">
|
||||
<group col='5' colspan='4'>
|
||||
<filter icon="terp-sale" string="My" domain="[('user_id','=',uid)]"/>
|
||||
<field name="name"/>
|
||||
<field name="parent_id" widget="selection"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
<record id="open_view_employee_tree" model="ir.actions.act_window">
|
||||
<field name="name">Employees Structure</field>
|
||||
<field name="res_model">hr.employee</field>
|
||||
@@ -98,6 +112,7 @@
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_employee_tree"/>
|
||||
<field name="domain">[('parent_id','=',False)]</field>
|
||||
<field name="search_view_id" ref="view_employee_filter"/>
|
||||
</record>
|
||||
|
||||
<record id="open_view_employee_list" model="ir.actions.act_window">
|
||||
@@ -106,6 +121,7 @@
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" eval="False"/>
|
||||
<field name="search_view_id" ref="view_employee_filter"/>
|
||||
</record>
|
||||
<!-- <menuitem
|
||||
id="menu_open_view_employee_list"
|
||||
@@ -124,6 +140,7 @@
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[]</field>
|
||||
<field name="search_view_id" ref="view_employee_filter"/>
|
||||
</record>
|
||||
<!--<menuitem
|
||||
action="open_view_employee_list_my"
|
||||
@@ -159,11 +176,11 @@
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
action="action_hr_marital_status"
|
||||
id="hr_menu_marital_status"
|
||||
<menuitem
|
||||
action="action_hr_marital_status"
|
||||
id="hr_menu_marital_status"
|
||||
parent="hr.menu_view_employee_category_configuration_form" sequence="3"/>
|
||||
|
||||
|
||||
<!--
|
||||
=======================
|
||||
Employee architecture
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="hr.view_employee_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="parent_id" position="after">
|
||||
<field name="coach_id" position="after">
|
||||
<field name="state"/>
|
||||
<button name="attendance_action_change" states="absent" string="Sign In" type="object" icon="gtk-go-back" context="{'type':'sign_in'}"/>
|
||||
<button name="attendance_action_change" states="present" string="Sign Out" type="object" icon="gtk-go-forward" context="{'type':'sign_out'}"/>
|
||||
|
||||
@@ -68,7 +68,7 @@ class hr_expense_expense(osv.osv):
|
||||
'amount': fields.function(_amount, method=True, string='Total Amount'),
|
||||
'invoice_id': fields.many2one('account.invoice', 'Invoice'),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', required=True),
|
||||
|
||||
'department_id':fields.many2one('hr.department','Department'),
|
||||
'state': fields.selection([
|
||||
('draft', 'Draft'),
|
||||
('confirm', 'Waiting confirmation'),
|
||||
@@ -215,12 +215,12 @@ class hr_expense_line(osv.osv):
|
||||
if product_id:
|
||||
product=self.pool.get('product.product').browse(cr,uid,product_id, context=context)
|
||||
v['name']=product.name
|
||||
|
||||
|
||||
# Compute based on pricetype of employee company
|
||||
pricetype_id = self.pool.get('hr.employee').browse(cr,uid,employee_id).user_id.company_id.property_valuation_price_type.id
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,pricetype_id)
|
||||
amount_unit=product.price_get(pricetype.field, context)[product.id]
|
||||
|
||||
|
||||
v['unit_amount']=amount_unit
|
||||
if not uom_id:
|
||||
v['uom_id']=product.uom_id.id
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<tree string="Expenses">
|
||||
<field name="date"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<field name="amount"/>
|
||||
@@ -45,6 +46,7 @@
|
||||
<tree string="Expenses" editable="top">
|
||||
<field name="date"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<field name="amount"/>
|
||||
@@ -66,6 +68,7 @@
|
||||
<field name="date" select="1"/>
|
||||
<field name="amount"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="department_id"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Expense Sheet">
|
||||
|
||||
Reference in New Issue
Block a user