Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
10180 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 2 25
827
0
thg 6 19
1867
0
thg 2 19
4745
2
thg 10 24
948
2
thg 3 24
3918