Odoo Help

2

0
1 Answer
1
Ayyappan India
2/5/14, 7:24 AM

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})
13 Comments
Ayyappan India
2/5/14, 7:26 AM

No changes has to be done in hr_applicant class

Ayyappan India
2/5/14, 8:17 AM

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

Ayyappan India
2/5/14, 8:27 AM

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

Ayyappan India
2/5/14, 8:29 AM

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

Ayyappan India
2/5/14, 8:32 AM

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

Ayyappan India
2/5/14, 8:36 AM

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

Remya India
2/6/14, 1:07 AM

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.

Ayyappan India
2/6/14, 1:29 AM

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?

Ayyappan India
2/6/14, 1:51 AM

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 ?

Ayyappan India
2/6/14, 2:16 AM

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?

Ayyappan India
2/6/14, 2:29 AM

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})

Ayyappan India
2/6/14, 2:30 AM

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

Ayyappan India
2/6/14, 2:48 AM

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.

Ask a Question
Writer
5822
Remya
Keep Informed
0 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now