Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
10504 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
1
févr. 25
1073
0
juin 19
1867
0
févr. 19
4921
2
oct. 24
1125
2
mars 24
4324