Show Thanks for your subscription! 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 objectwhen 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_encodingeven after i create a bank statement then change the date it will also show this error anyone know what is it? thank you 1AnswerYes, 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. View Discussion Improve Article Save Article When you execute a recursive function in Python on a large input ( > 10^4), you might encounter a “maximum recursion depth exceeded error”. This is a common error when executing algorithms such as DFS, factorial, etc. on large inputs. This is also common in competitive programming on multiple platforms when you are trying to run a recursive
algorithm on various test cases. Python3def fact(n): if(n == 0): return 1 return n * fact(n - 1) if __name__ == '__main__': f = int(input('Enter the number: \n')) print(fact(f)) Output : Using the setrecursionlimit() method, we can increase the recursion limit and the program can be executed without errors even on large inputs.
Python3import sys sys.setrecursionlimit(10**6) def fact(n): if(n == 0): return 1 return n * fact(n - 1) if __name__ == '__main__': f = int(input('Enter the number: \n')) print(fact(f)) Output : How do you overcome maximum recursion depth in Python?Conclusion. The recursion depth limit in Python is by default 1000 . You can change it using sys. setrecursionlimit() function.
How do I fix RecursionError in Python?A Python RecursionError exception is raised when the execution of your program exceeds the recursion limit of the Python interpreter. Two ways to address this exception are increasing the Python recursion limit or refactoring your code using iteration instead of recursion.
How can you prevent maximum recursion depth exceeded?Try increasing the recursion limit ( sys. setrecursionlimit ) or re-writing your code without recursion. Return the current value of the recursion limit, the maximum depth of the Python interpreter stack. This limit prevents infinite recursion from causing an overflow of the C stack and crashing Python.
|