odooodoo-17odoo-studio

How to solve ValueError: forbidden opcode(s) in 'my code': STORE_ATTR in Odoo 17?


I am trying to create a field using studio and compute its value. Here is what I tried,

for rec in self:
    rec.x_studio_total_ic_weight = self.qty_production * self.x_studio_related_field_41o_1horg1c8a

In dependencies field, I added qty_production,product_id.

But I am getting an error while opening the form view,

ValueError: forbidden opcode(s) in 'for rec in self:\n    rec.x_studio_total_ic_weight = self.qty_production * self.x_studio_related_field_41o_1horg1c8a': STORE_ATTR

How can I resolve this?

enter image description here


Solution

  • Assignment that way is not possible. Change it to:

    for rec in self:
        rec["x_studio_total_ic_weight"] = rec.qty_production * rec.x_studio_related_field_41o_1horg1c8a
    

    You probably wanted to use rec instead of self, so i changed that too.