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

I'm currently working in Odoo Studio, looking to create an automated action. Our system keeps track of patients who have their own individual set fees and their balance. The idea is that if their balance gets above their set fee, they are put on hold until they pay off their balance. 

I've started an automated action which is set to "On Update" for all clients and the result is "Execute Python Code". Currently I have code that says:

doubleAdjustedFee = record.x_studio_adjusted_fee * 2.0

if (doubleAdjustedFee <= record.x_studio_balance):

         record.x_studio_on_probation = True

------

Did I structure this correctly? I keep getting an error which says it is a void record set. The x_studio_adjusted_fee and x_studio_balance are the names of these fields in the database. I'm new to Odoo programming but not to programming in general.

Thanks in advance!


EDIT: Thank you to the person below--problem solved. (I don't have enough Karma to respond yet) Wasn't able to find a simple guide to making these automated actions so your quick response is appreciated.

Avatar
Discard
Best Answer

Try to replace changing of field by 'write':

doubleAdjustedFee = record.x_studio_adjusted_fee * 2.0
if (doubleAdjustedFee <= record.x_studio_balance):
record.write({"x_studio_on_probation": True})

Also I would advise to rely upon 'records' rather than 'record', since your 'on update' might happen for a few items simultaneously.:

for obj in records:
doubleAdjustedFee = obj.x_studio_adjusted_fee * 2.0
if (doubleAdjustedFee <= obj.x_studio_balance):
obj.write({"x_studio_on_probation": True})


Avatar
Discard
Related Posts Replies Views Activity
0
Jun 19
1867
0
Feb 19
3972
2
Oct 24
190
2
Mar 24
2337
0
Feb 23
642