how to pass values from a one2many field to another field in different model of same form? form view image given below (ial)
up vote
0
down vote
favorite
ial
one2many field name: survey_request_ids
model of one2many field : hr_evaluation.evaluation
Field name of 'Interviewer' inside one2many : user_id
model of 'Interviewer' inside one2many : hr.evaluation.interview
I want to create a new field 'Interviewer' below 'Appraisal Deadline'
which will have values from the below field 'Interviewer' which is in a one2many.
I tried like these,
from openerp import models,fields,api
class hr_evaluation_interview(models.Model):
_inherit = 'hr.evaluation.interview'
@api.onchange('user_id')
def _onchange_user_id(self):
rec = self.env['hr_evaluation.evaluation'].search([('id','=',
self.evaluation_id.id)])
rec.update(
'interviewer_ids': [(4,self.user_id.id)]
)
class hr_evaluation_inherit(models.Model):
_inherit = 'hr_evaluation.evaluation'
_columns =
'interviewer_ids': fields.many2many('res.users',
string='Interviewer',readonly=True)
xml python-2.7 odoo-8
add a comment |
up vote
0
down vote
favorite
ial
one2many field name: survey_request_ids
model of one2many field : hr_evaluation.evaluation
Field name of 'Interviewer' inside one2many : user_id
model of 'Interviewer' inside one2many : hr.evaluation.interview
I want to create a new field 'Interviewer' below 'Appraisal Deadline'
which will have values from the below field 'Interviewer' which is in a one2many.
I tried like these,
from openerp import models,fields,api
class hr_evaluation_interview(models.Model):
_inherit = 'hr.evaluation.interview'
@api.onchange('user_id')
def _onchange_user_id(self):
rec = self.env['hr_evaluation.evaluation'].search([('id','=',
self.evaluation_id.id)])
rec.update(
'interviewer_ids': [(4,self.user_id.id)]
)
class hr_evaluation_inherit(models.Model):
_inherit = 'hr_evaluation.evaluation'
_columns =
'interviewer_ids': fields.many2many('res.users',
string='Interviewer',readonly=True)
xml python-2.7 odoo-8
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
ial
one2many field name: survey_request_ids
model of one2many field : hr_evaluation.evaluation
Field name of 'Interviewer' inside one2many : user_id
model of 'Interviewer' inside one2many : hr.evaluation.interview
I want to create a new field 'Interviewer' below 'Appraisal Deadline'
which will have values from the below field 'Interviewer' which is in a one2many.
I tried like these,
from openerp import models,fields,api
class hr_evaluation_interview(models.Model):
_inherit = 'hr.evaluation.interview'
@api.onchange('user_id')
def _onchange_user_id(self):
rec = self.env['hr_evaluation.evaluation'].search([('id','=',
self.evaluation_id.id)])
rec.update(
'interviewer_ids': [(4,self.user_id.id)]
)
class hr_evaluation_inherit(models.Model):
_inherit = 'hr_evaluation.evaluation'
_columns =
'interviewer_ids': fields.many2many('res.users',
string='Interviewer',readonly=True)
xml python-2.7 odoo-8
ial
one2many field name: survey_request_ids
model of one2many field : hr_evaluation.evaluation
Field name of 'Interviewer' inside one2many : user_id
model of 'Interviewer' inside one2many : hr.evaluation.interview
I want to create a new field 'Interviewer' below 'Appraisal Deadline'
which will have values from the below field 'Interviewer' which is in a one2many.
I tried like these,
from openerp import models,fields,api
class hr_evaluation_interview(models.Model):
_inherit = 'hr.evaluation.interview'
@api.onchange('user_id')
def _onchange_user_id(self):
rec = self.env['hr_evaluation.evaluation'].search([('id','=',
self.evaluation_id.id)])
rec.update(
'interviewer_ids': [(4,self.user_id.id)]
)
class hr_evaluation_inherit(models.Model):
_inherit = 'hr_evaluation.evaluation'
_columns =
'interviewer_ids': fields.many2many('res.users',
string='Interviewer',readonly=True)
xml python-2.7 odoo-8
xml python-2.7 odoo-8
edited Nov 14 at 6:41
asked Nov 11 at 15:41
Afthab
33
33
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You can use a computed many2many field. The compute method will loop through all the appraisal forms and create a recordset containing all the interviewers that appear in all the forms. Then populate the many2many field with that recordset.
It would look something like this:
def _compute_interviewer_ids(self):
for record in self:
interviewer_ids =
for appraisal_form in record.survey_request_ids:
interviewer_ids.append(appraisal_form.interviewer_id.id)
record.interviewer_ids = self.env['interviewer.model'].browse(interviewer_ids)
interviewer_ids = fields.Many2many('interviewer.model', compute='_compute_interviewer_ids', string='Interviewers')
Edit: here is an entire model and its submodel so you can see it in context. Tested in v12.
from odoo import models, fields, api
class ExampleModel(models.Model):
_name = 'example_module.example_model'
_description = 'Example Model'
def _compute_interviewer_ids(self):
for record in self:
interviewer_ids =
for appraisal_form in record.submodel_ids:
interviewer_ids.append(appraisal_form.partner_id.id)
record.interviewer_ids = self.env['res.partner'].browse(interviewer_ids)
name = fields.Char()
description = fields.Text()
submodel_ids = fields.One2many('example_module.example_sub_model', 'examplemodel_id', 'SubModel Records')
interviewer_ids = fields.Many2many('res.partner', compute='_compute_interviewer_ids', string='Interviewers')
class ExampleSubModel(models.Model):
_name = 'example_module.example_sub_model'
_description = 'Example Sub-model'
name = fields.Char()
examplemodel_id = fields.Many2one('example_module.example_model', 'Parent Record')
partner_id = fields.Many2one('res.partner', 'Partner')
This is not an onchange method, it's a compute method. I tested the code and it's working fine on my end. I will edit my post with the whole model and submodel for your reference
– djames
Nov 14 at 8:21
Thankyou. This worked in odoo8
– Afthab
Nov 14 at 9:26
Great, glad you got it working! Could you please accept my answer?
– djames
Nov 14 at 10:01
Accepted. Again thanks
– Afthab
Nov 16 at 5:55
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You can use a computed many2many field. The compute method will loop through all the appraisal forms and create a recordset containing all the interviewers that appear in all the forms. Then populate the many2many field with that recordset.
It would look something like this:
def _compute_interviewer_ids(self):
for record in self:
interviewer_ids =
for appraisal_form in record.survey_request_ids:
interviewer_ids.append(appraisal_form.interviewer_id.id)
record.interviewer_ids = self.env['interviewer.model'].browse(interviewer_ids)
interviewer_ids = fields.Many2many('interviewer.model', compute='_compute_interviewer_ids', string='Interviewers')
Edit: here is an entire model and its submodel so you can see it in context. Tested in v12.
from odoo import models, fields, api
class ExampleModel(models.Model):
_name = 'example_module.example_model'
_description = 'Example Model'
def _compute_interviewer_ids(self):
for record in self:
interviewer_ids =
for appraisal_form in record.submodel_ids:
interviewer_ids.append(appraisal_form.partner_id.id)
record.interviewer_ids = self.env['res.partner'].browse(interviewer_ids)
name = fields.Char()
description = fields.Text()
submodel_ids = fields.One2many('example_module.example_sub_model', 'examplemodel_id', 'SubModel Records')
interviewer_ids = fields.Many2many('res.partner', compute='_compute_interviewer_ids', string='Interviewers')
class ExampleSubModel(models.Model):
_name = 'example_module.example_sub_model'
_description = 'Example Sub-model'
name = fields.Char()
examplemodel_id = fields.Many2one('example_module.example_model', 'Parent Record')
partner_id = fields.Many2one('res.partner', 'Partner')
This is not an onchange method, it's a compute method. I tested the code and it's working fine on my end. I will edit my post with the whole model and submodel for your reference
– djames
Nov 14 at 8:21
Thankyou. This worked in odoo8
– Afthab
Nov 14 at 9:26
Great, glad you got it working! Could you please accept my answer?
– djames
Nov 14 at 10:01
Accepted. Again thanks
– Afthab
Nov 16 at 5:55
add a comment |
up vote
0
down vote
accepted
You can use a computed many2many field. The compute method will loop through all the appraisal forms and create a recordset containing all the interviewers that appear in all the forms. Then populate the many2many field with that recordset.
It would look something like this:
def _compute_interviewer_ids(self):
for record in self:
interviewer_ids =
for appraisal_form in record.survey_request_ids:
interviewer_ids.append(appraisal_form.interviewer_id.id)
record.interviewer_ids = self.env['interviewer.model'].browse(interviewer_ids)
interviewer_ids = fields.Many2many('interviewer.model', compute='_compute_interviewer_ids', string='Interviewers')
Edit: here is an entire model and its submodel so you can see it in context. Tested in v12.
from odoo import models, fields, api
class ExampleModel(models.Model):
_name = 'example_module.example_model'
_description = 'Example Model'
def _compute_interviewer_ids(self):
for record in self:
interviewer_ids =
for appraisal_form in record.submodel_ids:
interviewer_ids.append(appraisal_form.partner_id.id)
record.interviewer_ids = self.env['res.partner'].browse(interviewer_ids)
name = fields.Char()
description = fields.Text()
submodel_ids = fields.One2many('example_module.example_sub_model', 'examplemodel_id', 'SubModel Records')
interviewer_ids = fields.Many2many('res.partner', compute='_compute_interviewer_ids', string='Interviewers')
class ExampleSubModel(models.Model):
_name = 'example_module.example_sub_model'
_description = 'Example Sub-model'
name = fields.Char()
examplemodel_id = fields.Many2one('example_module.example_model', 'Parent Record')
partner_id = fields.Many2one('res.partner', 'Partner')
This is not an onchange method, it's a compute method. I tested the code and it's working fine on my end. I will edit my post with the whole model and submodel for your reference
– djames
Nov 14 at 8:21
Thankyou. This worked in odoo8
– Afthab
Nov 14 at 9:26
Great, glad you got it working! Could you please accept my answer?
– djames
Nov 14 at 10:01
Accepted. Again thanks
– Afthab
Nov 16 at 5:55
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You can use a computed many2many field. The compute method will loop through all the appraisal forms and create a recordset containing all the interviewers that appear in all the forms. Then populate the many2many field with that recordset.
It would look something like this:
def _compute_interviewer_ids(self):
for record in self:
interviewer_ids =
for appraisal_form in record.survey_request_ids:
interviewer_ids.append(appraisal_form.interviewer_id.id)
record.interviewer_ids = self.env['interviewer.model'].browse(interviewer_ids)
interviewer_ids = fields.Many2many('interviewer.model', compute='_compute_interviewer_ids', string='Interviewers')
Edit: here is an entire model and its submodel so you can see it in context. Tested in v12.
from odoo import models, fields, api
class ExampleModel(models.Model):
_name = 'example_module.example_model'
_description = 'Example Model'
def _compute_interviewer_ids(self):
for record in self:
interviewer_ids =
for appraisal_form in record.submodel_ids:
interviewer_ids.append(appraisal_form.partner_id.id)
record.interviewer_ids = self.env['res.partner'].browse(interviewer_ids)
name = fields.Char()
description = fields.Text()
submodel_ids = fields.One2many('example_module.example_sub_model', 'examplemodel_id', 'SubModel Records')
interviewer_ids = fields.Many2many('res.partner', compute='_compute_interviewer_ids', string='Interviewers')
class ExampleSubModel(models.Model):
_name = 'example_module.example_sub_model'
_description = 'Example Sub-model'
name = fields.Char()
examplemodel_id = fields.Many2one('example_module.example_model', 'Parent Record')
partner_id = fields.Many2one('res.partner', 'Partner')
You can use a computed many2many field. The compute method will loop through all the appraisal forms and create a recordset containing all the interviewers that appear in all the forms. Then populate the many2many field with that recordset.
It would look something like this:
def _compute_interviewer_ids(self):
for record in self:
interviewer_ids =
for appraisal_form in record.survey_request_ids:
interviewer_ids.append(appraisal_form.interviewer_id.id)
record.interviewer_ids = self.env['interviewer.model'].browse(interviewer_ids)
interviewer_ids = fields.Many2many('interviewer.model', compute='_compute_interviewer_ids', string='Interviewers')
Edit: here is an entire model and its submodel so you can see it in context. Tested in v12.
from odoo import models, fields, api
class ExampleModel(models.Model):
_name = 'example_module.example_model'
_description = 'Example Model'
def _compute_interviewer_ids(self):
for record in self:
interviewer_ids =
for appraisal_form in record.submodel_ids:
interviewer_ids.append(appraisal_form.partner_id.id)
record.interviewer_ids = self.env['res.partner'].browse(interviewer_ids)
name = fields.Char()
description = fields.Text()
submodel_ids = fields.One2many('example_module.example_sub_model', 'examplemodel_id', 'SubModel Records')
interviewer_ids = fields.Many2many('res.partner', compute='_compute_interviewer_ids', string='Interviewers')
class ExampleSubModel(models.Model):
_name = 'example_module.example_sub_model'
_description = 'Example Sub-model'
name = fields.Char()
examplemodel_id = fields.Many2one('example_module.example_model', 'Parent Record')
partner_id = fields.Many2one('res.partner', 'Partner')
edited Nov 14 at 8:24
answered Nov 13 at 15:37
djames
642
642
This is not an onchange method, it's a compute method. I tested the code and it's working fine on my end. I will edit my post with the whole model and submodel for your reference
– djames
Nov 14 at 8:21
Thankyou. This worked in odoo8
– Afthab
Nov 14 at 9:26
Great, glad you got it working! Could you please accept my answer?
– djames
Nov 14 at 10:01
Accepted. Again thanks
– Afthab
Nov 16 at 5:55
add a comment |
This is not an onchange method, it's a compute method. I tested the code and it's working fine on my end. I will edit my post with the whole model and submodel for your reference
– djames
Nov 14 at 8:21
Thankyou. This worked in odoo8
– Afthab
Nov 14 at 9:26
Great, glad you got it working! Could you please accept my answer?
– djames
Nov 14 at 10:01
Accepted. Again thanks
– Afthab
Nov 16 at 5:55
This is not an onchange method, it's a compute method. I tested the code and it's working fine on my end. I will edit my post with the whole model and submodel for your reference
– djames
Nov 14 at 8:21
This is not an onchange method, it's a compute method. I tested the code and it's working fine on my end. I will edit my post with the whole model and submodel for your reference
– djames
Nov 14 at 8:21
Thankyou. This worked in odoo8
– Afthab
Nov 14 at 9:26
Thankyou. This worked in odoo8
– Afthab
Nov 14 at 9:26
Great, glad you got it working! Could you please accept my answer?
– djames
Nov 14 at 10:01
Great, glad you got it working! Could you please accept my answer?
– djames
Nov 14 at 10:01
Accepted. Again thanks
– Afthab
Nov 16 at 5:55
Accepted. Again thanks
– Afthab
Nov 16 at 5:55
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250345%2fhow-to-pass-values-from-a-one2many-field-to-another-field-in-different-model-of%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown