Skip to Content
Menu
This question has been flagged
2 Replies
11587 Views

how to assign or modify value of many2one field from another object 

Avatar
Discard
Best Answer

Hello,

You Can Call write Method For Assign Or Modify Value OF M2O From Another Object.

Example:

@api.multi

     def write(self, values):

         your_obj = self.env['object.object].search([(as per your Condition)])

         your_obj.write({

                        'your_field_from_another_object': 'your_field_from_current_object.id'

                        })

Avatar
Discard
Best Answer

Hi,

you can write the value of that field.

eg:

@api.multi
def function_in_current_model(self):
 record = self.env['model.of.the.record.you.want.to.change.the.field.value'].browse(record_id)
 record.write('many2one_filed_name': id)

Thank you.

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 22
14645
3
Aug 22
10749
2
Aug 22
3045
0
Jul 22
835
2
Oct 21
1432