This question has been flagged
1 Reply
5763 Views

I am working on Recruitment module. I have five stages. When a candidate reach the last stage, the candidates some details should be saved into another table. Is it possible? I know all the datas are available in recruitment table. But i want some datas in another table. Please help anyone.

Avatar
Discard

can you help me to get started, am a beginner, this is ma first project inopen erp..where can i find administration-modules-import modules, provideme screen shots...buddy

When you reach the last stage, use "create"(ORM) function and write the values in another table.

I need your tables details,and what are the fields will be updated in new table.

Author

In hr.applicant i have added x_project(many2one),x_project_start_date,x_project_end date(both are date field) etc. Create a new table ie,x_project.details add all these fields as char. When the candidate reach last stage. All its datas that we want to save in x_project.details, wants to save automatically.

without any action like click a button, you have to save the record in another table?

We have to write the values from hr.applicant to x_project.details. right?

Best Answer

New Table:

_columns = {
'hr_applicant_id': fields.many2one('hr.applicant', 'Hr Applicant Ref'),
'x_project_start_date': fields.date('Start Date', required=True, select=True),
'x_project_end date': fields.date('End Date', required=True, select=True),
}

hr_applicant:

active_id = context.get('active_id') 
applicant_obj = self.pool.get('hr.applicant') 
project_obj = self.pool.get('x_project.details') 
applicant_record = self.browse(cr, uid, ids, active_id, context=context) 
x_project_sr = project_obj .search(cr, uid, [('hr_applicant_id', '=', applicant_record .id)])
if not x_project_sr:
    project_obj.create(cr, uid, {'hr_applicant_id': applicant_record .id,'x_project_start_date':applicant_record.x_project_start_date, 'x_project_end_date':applicant_record.x_project_end_date})
else:
    project_obj.write(cr, uid, x_project_sr[0], {'x_project_start_date':applicant_record.x_project_start_date, 'x_project_end_date':applicant_record.x_project_end_date})
Avatar
Discard

No changes has to be done in hr_applicant class

Do you want "x_project.details" object reference in "hr.applicant" object?

In hr_applicant class: _columns = {'x_project':many2one('x_project.details', 'Project Ref'),}

In x_project.details class: _columns = {'x_project':char('Ref', size=64),}

In x_project.details details form you want to add "x_project" field. what value will be stored in that field?

We have to save the id of the "x_project.details" object?

Author

Hi Ayyappan, thanks for your answer. Its working. But one issue is i dont want to overwrite record. Each time a new record should be created in the x_project.details table.

One hr_applicant form will be linked with one x_project.details or one hr_applicant form will be linked with multiple x_project.details?

whenever you updating the hr_applicant form that should be created in x_project.details form or only one time x_project.details form will be created from hr_applicant ?

Hr_applicant form value : id =1, start_date = 23/12/2013, end_date = 24/12/2013 while saving the record one x_project.details will be created. right? but in case you edit the hr_applicant same form like : id =1, start_date = 23/12/2013, end_date = 25/12/2013, while saving again this form it will create a new x_project.details form or update the value?

active_id = context.get('active_id') applicant_obj = self.pool.get('hr.applicant') project_obj = self.pool.get('x_project.details') applicant_record = self.browse(cr, uid, ids, active_id, context=context) project_obj.create(cr, uid, {'hr_applicant_id': applicant_record .id,'x_project_start_date':applicant_record.x_project_start_date, 'x_project_end_date':applicant_record.x_project_end_date})

use above one. It will create more than one x_project.details record whenever you save the hr_applicant form.

It will work, just check with button functionality. Keep a button in the hr_applicant form and click the button which will call the function you have write above.