Search code examples
ormodoocomputed-field

In Odoo, what would happen if the method of computed field is assigning a value to other fields?


Let say we have a model with three fields with the following definition:

class myModel(models.Model):
    _name = 'my.model'
    field_a = fields.Char('Field A')
    field_b = fields.Char('Field B')
    field_c = fields.Char('Field C', compute='compute_field_c', store=True)

    @api.depends('field_b')
    def compute_field_c(self):
        for rec in self:
             rec.field_c = (rec.field_b or '') + ' something else'
             re.field_a = 'test to see if this works properly'

field_c is computed from field_b and field_a is just a normal char field. I wonder what would happen if inside the compute method we also assign a value to field_a. I know it is not a good practice but I recently maintain some modules with this kind of architecture, the program seems to work normally but I wonder if there will some issues in a long run.


Solution

  • Apart from the obvious typo

    re.field_a
    

    I don't see any other problems with it.