Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
1953 มุมมอง

Hi Everyone, 

I am trying to create a computed field in Studio that is linked to two conditions, but I'm struggling to make it work. 


I've used the below : 

for record in self :

if record.x_studio_contract_par_sun ==False:

  record['x_studio_commission_sun'] = 0

if record.x_studio_contract_par_sun ==True:

  record['x_studio_commission_sun'] = record.x_studio_tarif_location * 0.10


Do you have any idea what I am doing wrong ? 
I've seen maybe it should be linked to a control_var, but can't find info anywhere. 


Thanks a lot for the help !

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hey Melanie Turleque,


I hope you are doing well.


Use the below code to compute the field.


for record in self:

record[‘x_studio_commission_sun’] = 0

  if record[‘x_studio_contract_par_sun’] and record[‘x_studio_tarif_location’]:

    record[‘x_studio_commission_sun’] = record[‘x_studio_tarif_location’] * 0.10


Note:- Check Indentation of the code after pasting the code.

Add x_studio_contract_par_sun and x_studio_tarif_location in the dependencies.


Hope this will help you.

Thanks & Regards,
Email:   odoo@aktivsoftware.com      

Skype: kalpeshmaheshwari

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Your code looks mostly correct. Make sure to use the correct field names and check if the conditions are being evaluated as expected. Also, ensure the computed field is correctly set up in Studio. If issues persist, consider using a control_var for better control. Double-check your field names and conditions for accuracy.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thank you for the help ! very much appreciated. It works ! Brilliant.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You should be able to replace 

if record.x_studio_contract_par_sun ==True: 

with

else:
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 24
2624
1
ก.พ. 25
1473
How to compute a bool field in Studio? แก้ไขแล้ว
1
พ.ค. 21
4559
2
ส.ค. 22
5335
1
ต.ค. 20
2091