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/save.py”, line 19, in savedocs
doc.submit()
File “/home/taher/frappe-bench/apps/frappe/frappe/model/document.py”, line 778, in submit
self._submit()
File “/home/taher/frappe-bench/apps/frappe/frappe/model/document.py”, line 767, in _submit
self.save()
File “/home/taher/frappe-bench/apps/frappe/frappe/model/document.py”, line 256, in save
return self._save(*args, **kwargs)
File “/home/taher/frappe-bench/apps/frappe/frappe/model/document.py”, line 307, in _save
self.run_post_save_methods()
File “/home/taher/frappe-bench/apps/frappe/frappe/model/document.py”, line 830, in run_post_save_methods
self.run_method(“on_submit”)
File “/home/taher/frappe-bench/apps/frappe/frappe/model/document.py”, line 702, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/taher/frappe-bench/apps/frappe/frappe/model/document.py”, line 924, in composer
return composed(self, method, *args, **kwargs)
File “/home/taher/frappe-bench/apps/frappe/frappe/model/document.py”, line 909, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File “/home/taher/frappe-bench/apps/mop/mop/customization/custom_salesinvoice.py”, 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.
image
my local pyc file of the change got updated

image
on the server not updated…

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

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