This question has been flagged

hello guys, i want to know if there bugs by odoo in bank statement, so i want to import bank statement data with date 2021-01-31 (today date is 2021-09-08) but i get this error

RecursionError: maximum recursion depth exceeded while calling a Python object

when i check further log it said this error:
File "/usr/lib/python3/dist-packages/odoo/addons/account/models/account_bank_statement.py", line 152, in _compute_ending_balance
    statement.balance_end_real = statement.previous_statement_id.balance_end_real + total_entry_encoding

even after i create a bank statement then change the date it will also show this error

anyone know what is it? thank you

Avatar
Discard
Best Answer

Yes, there is a problem in algorithm. When you create a statement with date earlier than several existing statements, is required to recompute starting and ending balances of these statements. And here we gets the RecursionError if there is a large enough statements amount to recompute.

When i tried to import into Odoo a large amount of statements, i got the same issue. And the only workaround i found was to sort data before import for avoiding this recomputing.

In your case, seems, you can export statements, newer than one to create, to xlsx, delete them from the system, create your statement and then import exported statements back and reconcile them with payments again.
---

upd: Python recursion check is based on interpreter stack length, and when Odoo trying to recompute large statements amount, it just exceed this limit,  which  is 1000 by default. So you can try to increase  python recursion limit setting in your code using `sys.setrecursionlimit(some_limit_value)` that will be enough to perform all statements recomputing.

Avatar
Discard
Author

thanks for replying me.. but how can i delete it, when i delete it on the system it also throws the same error..

Records should be deleted from last to first. In this case there is nothing to recompute.
Also If you have a problem with RecursionError, it means you have a lot statements to delete. It will be better to do this from shell.

Or you can try to increase python recursion limit.

Author

yes yes, yesterday i just delete the datas with sql query but still got the error and i think the second solution might solve the problem, is the thing that i need to do is import module sys from python and directly edit sys.setrecursionlimit from python file in models directory in module odoo?? did you have any reference? thanks..

To modify Odoo data with raw SQL request it is bad idea. You should use model methods to change model data.

To change interpreter stack limit you should in any your odoo module, in any python file (for example "__init__.py")) insert 2 strings:
```
from sys import setrecursionlimit
setrecursionlimit(some_value_more_than_1000)
```

Author

alright, it works! but i want to know is there a consequence if we extend the limit of recursion in odoo? thanks a lot man, really appreciate it

If your new limit will be more than your system can handle, you can get C's StackOverflowException.

Author

do you have any reference for me to calculate things between max limit recursion and my system capabilities?

I haven't, sorry.
I just can to recomend set this parameter at lowest value allowing to solve your problem. It should be far away from system limits.

Author

it's okay.. thanks again anyway mate, i will pray for your success for helping me