Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
10211 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
úno 25
856
0
čvn 19
1867
0
úno 19
4777
2
říj 24
973
2
bře 24
3968