2015-05-29 12:16 GMT+02:00 Simon Klemenc <[email protected]>:
> Thats what i wanted to achieve...
> However what i tried was to define a one2many function field, but i cant
> get values to be updated there neither...
> Does it have to be a _real_ one2many field?
>
yes
> Can't i trigger updates on one2many function fields?
>
Not that I know of. If what you want to do is update a specific field on
the M2O (let's say a Char field),
you could add a Function(Char) field which would present the M2O field, and
define a setter
that will update it :
class MyModel:
my_m2o = fields.M2O(...)
my_m2o_name = fields.Function(fields.Char(...),
'on_change_with_my_m2o_name', 'set_my_m2o_name')
@fields.depends('my_m2o')
def on_change_with_my_m2o_name(self, name=None):
return self.my_m2o.name
@classmethod
def set_my_m2o_name(cls, instances, name, value):
cls.write([x.my_m2o for x in instances], {'name': value})
Jean Cavallo
*Coopengo*