Skip to Content
Menu
This question has been flagged
2 Replies
1147 Views

Can any of you please see where I am going wrong here?


Advanced Properties
Related Field
Dependenciesx_studio_float_field_M5fIj,x_studio_project_value,x_studio_target_leads


for record in self:
record['x_studio_float_field_M5fIj'] = record.x_studio_project_value / record.x_studio_target_leads



I am getting no error but if I try to change the numbers in the project value field I get an error and as it stands the calculation field shows 0.00 which it should not be 


Traceback (most recent call last):
  File "/home/odoo/src/odoo/saas-15.2/odoo/http.py", line 643, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/odoo/src/odoo/saas-15.2/odoo/http.py", line 301, in _handle_exception
    raise exception.with_traceback(None) from new_cause
ValueError: : "unsupported operand type(s) for /: 'str' and 'str'" while evaluating
"for record in self:\n  record['x_studio_float_field_M5fIj'] = record.x_studio_project_value / record.x_studio_target_leads"



Avatar
Discard
Best Answer

Make the fields as integer or float before division. For example - 

for record in self: record['x_studio_float_field_M5fIj'] = int(record.x_studio_project_value) / int(record.x_studio_target_leads)



Avatar
Discard
Best Answer

Hello

By looking posted error, it seems you are tring to divide string values. please check  both fields type. As per your computation it should  be integer or float and currently both fields are string type.

record.x_studio_project_value and  record.x_studio_target_leads


Thanks & Regards,



CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat 380015
    

Avatar
Discard