App not working after upgrade to V9

App was Working perfectly up until version 8. After upgrade its giving a TypeError of Unicode and float
here is the traceback:

Traceback (most recent call last):
File “/home/taher/frappe-bench/apps/frappe/frappe/desk/form/”, line 19, in savedocs
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 778, in submit
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 767, in _submit
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 256, in save
return self._save(*args, **kwargs)
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 307, in _save
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 830, in run_post_save_methods
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 702, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 924, in composer
return composed(self, method, *args, **kwargs)
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 909, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File “/home/taher/frappe-bench/apps/mop/mop/customization/”, line 16, in on_submit
charges = row.amount * mop.extra_charges_rate / 100.0
TypeError: unsupported operand type(s) for /: ‘unicode’ and ‘float’

Did type Casting change in v9?
its a simple app that calculates extra charges based on a custom field and creates a JE for it.

Can anybody help out please?

Thanks in advance

Try changing the offending line to something like:
charges = flt(row.amount) * flt(mop.extra_charges_rate) / 100.0

I recommend that devs always explicitly cast variables that numeric to avoid/catch these kinds of errors.

Thanks @tundebabzy
it worked on my local but when i pushed it to live , same issue persists.
i have no idea why? is the server retaining the error or something…

i am stuck :sweat:

I saw that the pyc file in local was updated but not in live server.
my local pyc file of the change got updated

on the server not updated…

maybe that is the issue?- … i’m not sure at all
any help is appreciated

Restart your server

1 Like

yes that got it to work ,
it was the compile issue.

Thanks a Ton for all the support and recommendations :+1:

1 Like