[IMP]hr_recruitment: Improve state field as function field according to stage changes and added a group technical feature in state field
bzr revid: mma@tinyerp.com-20120418125626-k223leos3hw9zxvz
This commit is contained in:
parent
38948deaca
commit
a4ad0c8dcf
|
@ -69,11 +69,7 @@ class hr_recruitment_stage(osv.osv):
|
|||
'name': fields.char('Name', size=64, required=True, translate=True),
|
||||
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of stages."),
|
||||
'department_id':fields.many2one('hr.department', 'Specific to a Department', help="Stages of the recruitment process may be different per department. If this stage is common to all departments, keep tempy this field."),
|
||||
'state': fields.selection(AVAILABLE_STATES, 'State', size=16,
|
||||
help='The state is set to \'Draft\', when a case is created.\
|
||||
\nIf the case is in progress the state is set to \'Open\'.\
|
||||
\nWhen the case is over, the state is set to \'Done\'.\
|
||||
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
||||
'state': fields.selection(AVAILABLE_STATES, 'State', size=16),
|
||||
'requirements': fields.text('Requirements')
|
||||
}
|
||||
_defaults = {
|
||||
|
@ -137,6 +133,31 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
duration = float(ans.days)
|
||||
res[issue.id][field] = abs(float(duration))
|
||||
return res
|
||||
|
||||
def _get_state(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for applicant in self.browse(cr, uid, ids, context=context):
|
||||
if applicant.stage_id:
|
||||
res[applicant.id] = applicant.stage_id.state
|
||||
return res
|
||||
|
||||
def _get_stage(self, cr, uid, ids, context=None):
|
||||
applicant_obj = self.pool.get('hr.applicant')
|
||||
result = {}
|
||||
for stage in self.browse(cr, uid, ids, context=context):
|
||||
if stage.state:
|
||||
applicant_ids = applicant_obj.search(cr, uid, [('state', '=', stage.state)], context=context)
|
||||
for applicant in applicant_obj.browse(cr, uid, applicant_ids, context=context):
|
||||
result[applicant.id] = True
|
||||
return result.keys()
|
||||
|
||||
def _save_state(self, cr, uid, hr_applicant_id, field_name, field_value, arg, context=None):
|
||||
stage_ids = self.pool.get('hr.recruitment.stage').search(cr, uid, [('state', '=', field_value)], order='sequence', context=context)
|
||||
if stage_ids:
|
||||
return cr.execute("""update hr_applicant set state=%s, stage_id=%s where id=%s""", (field_value, stage_ids[0], hr_applicant_id))
|
||||
else:
|
||||
return cr.execute("""update hr_applicant set state=%s where id=%s""", (field_value, hr_applicant_id))
|
||||
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=128, required=True),
|
||||
|
@ -150,7 +171,14 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
'create_date': fields.datetime('Creation Date', readonly=True, select=True),
|
||||
'write_date': fields.datetime('Update Date', readonly=True),
|
||||
'stage_id': fields.many2one ('hr.recruitment.stage', 'Stage'),
|
||||
'state': fields.related('stage_id','state', type='char', selection=AVAILABLE_STATES, string="State", store=True, readonly=True),
|
||||
'state': fields.function(_get_state, fnct_inv=_save_state, type='selection', selection=AVAILABLE_STATES, string="State", readonly=True,
|
||||
store = {
|
||||
'hr.applicant': (lambda self, cr, uid, ids, c={}: ids, ['stage_id'], 10),
|
||||
'hr.recruitment.stage': (_get_stage, ['state'], 10)
|
||||
}, help='The state is set to \'Draft\', when a case is created.\
|
||||
\nIf the case is in progress the state is set to \'Open\'.\
|
||||
\nWhen the case is over, the state is set to \'Done\'.\
|
||||
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'user_id': fields.many2one('res.users', 'Responsible'),
|
||||
# Applicant Columns
|
||||
|
@ -188,7 +216,7 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
'active': lambda *a: 1,
|
||||
'user_id': lambda self, cr, uid, context: uid,
|
||||
'email_from': crm.crm_case. _get_default_email,
|
||||
'state': lambda *a: 'draft',
|
||||
'state': 'draft',
|
||||
'priority': lambda *a: '',
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
|
||||
'color': 0,
|
||||
|
|
|
@ -61,9 +61,9 @@
|
|||
<field name="availability" invisible="1"/>
|
||||
<field name="department_id" invisible="context.get('invisible_department', True)"/>
|
||||
<field name="user_id"/>
|
||||
<field name="state"/>
|
||||
<button name="case_open" string="In Progress" states="draft,pending" type="object" icon="gtk-go-forward"/>
|
||||
<button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
|
||||
<field name="state" groups="base.group_no_one"/>
|
||||
<button name="case_open" string="In Progress" states="draft,pending" type="object" icon="gtk-go-forward" groups="base.group_no_one"/>
|
||||
<button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause" groups="base.group_no_one"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -74,7 +74,7 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form layout="manual">
|
||||
<div class="oe_form_topbar">
|
||||
<div class="oe_form_topbar" groups="base.group_no_one">
|
||||
<button name="case_cancel" string="Refuse" states="draft,open,pending" type="object" icon="gtk-cancel"/>
|
||||
<button name="case_open" string="In Progress" states="draft,pending" type="object" icon="gtk-go-forward"/>
|
||||
<button name="case_pending" string="Pending" states="open" type="object" icon="gtk-media-pause"/>
|
||||
|
@ -145,15 +145,6 @@
|
|||
<field name="date_closed"/>
|
||||
<field name="date_open"/>
|
||||
</group>
|
||||
<separator colspan="4" string="Status" groups="base.group_no_one"/>
|
||||
<group col="8" colspan="4" groups="base.group_no_one">
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,open,done" statusbar_colors='{"pending":"blue"}'/>
|
||||
<button name="case_cancel" string="Refuse" states="draft,open,pending" type="object" icon="gtk-cancel" />
|
||||
<button name="case_open" string="In Progress" states="draft,pending" type="object" icon="gtk-go-forward" />
|
||||
<button name="case_pending" string="Pending" states="open" type="object" icon="gtk-media-pause" />
|
||||
<button name="%(action_hr_recruitment_hired_employee)d" string="Hire" states="open,pending" type="action" icon="terp-partner"/>
|
||||
<button name="case_reset" string="Reset to New" states="done,cancel" type="object" icon="gtk-convert"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field name="description" nolabel="1" colspan="4"/>
|
||||
|
@ -373,6 +364,7 @@
|
|||
<field name="sequence" invisible="1"/>
|
||||
<field name="name"/>
|
||||
<field name="department_id" groups="base.group_extended"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue