Mayur Maheshwari(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-state_sync_with_kanban-hr_applicant-mma
into lp:~openerp-dev/openobject-addons/trunk-state_sync_with_kanban.
Requested reviews:
OpenERP R&D Team (openerp-dev)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-state_sync_with_kanban-hr_applicant-mma/+merge/102513
Hello
I have done following things:
1) Removed fields.related and added fields.function on state field
2) If we change the state from stage it should update the state for all
applicant.
3) If we change the state of the applicant using any button. It should also
update the stage of the applicant and move the kanban view of applicant
accordingly
4) Added a technical feature group on state field
Thanks,
mma
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-state_sync_with_kanban-hr_applicant-mma/+merge/102513
Your team OpenERP R&D Team is requested to review the proposed merge of
lp:~openerp-dev/openobject-addons/trunk-state_sync_with_kanban-hr_applicant-mma
into lp:~openerp-dev/openobject-addons/trunk-state_sync_with_kanban.
=== modified file 'hr_recruitment/hr_recruitment.py'
--- hr_recruitment/hr_recruitment.py 2012-04-18 07:57:30 +0000
+++ hr_recruitment/hr_recruitment.py 2012-04-18 13:14:44 +0000
@@ -69,11 +69,7 @@
'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, help="This state is related to this stage"),
'requirements': fields.text('Requirements')
}
_defaults = {
@@ -137,6 +133,31 @@
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 @@
'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 @@
'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,
=== modified file 'hr_recruitment/hr_recruitment_view.xml'
--- hr_recruitment/hr_recruitment_view.xml 2012-04-18 08:46:08 +0000
+++ hr_recruitment/hr_recruitment_view.xml 2012-04-18 13:14:44 +0000
@@ -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>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp