تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
10164 أدوات العرض

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.

الصورة الرمزية
إهمال
أفضل إجابة

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})


الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
فبراير 25
810
0
يونيو 19
1867
0
فبراير 19
4735
2
أكتوبر 24
931
2
مارس 24
3909