Here is my problem :
I'm in model1 :
class model1(osv.osv):
_name = 'model1'
_columns = {
'name': fields.many2one('res.partner',
u'Person',
domain=[('my_boolean', '=', False)],
required=True,
select=True),
'type' = fields.selection([('1', 'One'),
('2', 'Two'),
u'Select',
required=True),
}
@api.onchange('type')
def onchange_type_model1(self)
self.name.model3_id = 2
And I want to modify in this onchange the value of the id of model3_id in res.partner:
-res.partner in this module:
class res_partner(osv.osv):
_inherit = 'res.partner'
_columns = {
'model1_partner_ids': fields.one2many('model1',
'name',
u'asker from model1',
select=True),
}
-res.partner in the module with model3:
class res_partner:
_inherit = res.partner
_columns = {
'model3_id': fields.many2one('model3',
u'Model3'
track_visibility='onchange',
select=True),
}
model3 is not important here, I have 10 id of model3 objects and I need to be able to affect, for example, the id " 2 " to 'model3_id' in res.partner when "type" is modified in model1.
I tried this : odoo - get value from many2one field by doing this:
@api.onchange('type')
def onchange_type_demand(self, cr, uid, ids, context=None):
for name in self.browse(cr, uid, ids, context=context):
if name.model3_id:
name.model3_id = 2
But it give me an error saying that record.env doesn't exist. I tried to find answer to this error but none matched with my code.
I looked to dozens of topics, tried all the morning to fix it, but whatever I do, it won't works. (The first thing I did -appear in first class I wrote- didn't gave me any error but changed nothing in the database.)
Thanks for reading and for any help you could provide.
EDIT: I think the only real question here is "How to give an ID as a value for a many2one?" But I'm not sure that this is the only problem here so I let all the text.