Skip to Content
Menu
This question has been flagged
1 Reply
1982 Views

I have added a computational field through the odoo studio feature. It triggers (works) for the new records, but does not work for the old (previously created) records. Here is my code,

for record in self:
    record ['x_studio_debug'] = "test"

Avatar
Discard
Best Answer

I had the same and solved it by creating an action that run through all the old records and made the update.

-



Avatar
Discard
Author

Kindly can you explain further? where did you create the action ? can you explain the action code too...

Go to debug mode.

Go to Setting -> Technical -> Server actions.

Create a server action. Select the correct model and Action to do = Execute Puthon code.

Then enter your code, and save. And then you press: Set contextual action.

When you the go into a record you want to update, or in list view you select the records you want to update, you find your server action in the Action on the top of the list.

Be aware that the python code have a different syntax than in your field. My code looked like this:

record ['x_studio_sum_weight'] = record.quantity * record.x_studio_field_LXlvk

You should find good instruction videos on You Tube on how to create server actions.

Author

It Works !!!! Thanks, your answer was really helpful. Thanks again Lars !!!! :)