overriding write() method in odoo 8 results in RuntimeError: maximum recursion depth exceeded
The problem is that by writing self.flaeche = 37
you are changing the record, which means implicitly calling the write()
method on the model. When you call write()
from write()
you obviously end up with recursion.
You can do something similar to this instead:
@api.multi
def write(self, vals):
vals['flaeche'] = 37
return super(lager, self).write(vals)
This way there are no additional writes - you just change the values for a write that was about to happen anyway.
If you want to allow people to explicitly overwrite the value of 37
you can do this:
@api.multi
def write(self, vals):
if 'flaeche' not in vals:
vals['flaeche'] = 37
return super(lager, self).write(vals)
In your lager.write
method, the self.flaeche=37
statement triggers a call to field.__set__()
which calls record.write()
- record
being here the current lager
instance, hence your infinite recursion.
I don't know zilch about odoo, but hopefully there must be a way to set a field without triggering a call to write
- else, well, bad luck.