typjournal_entries = frappe.get_all(
"Journal Entry",
filters={
"docstatus": 0,
"voucher_type": "Depreciation Entry",
},
fields=["name"]
)
for i, je in enumerate(journal_entries, start=1):
try:
je_doc = frappe.get_doc("Journal Entry", je["name"])
je_doc.submit()
frappe.db.commit()
if i % 50 == 0:
frappe.logger().info(f"[Auto Depreciation] Processed {i} Journal Entries")
except Exception as e:
frappe.db.rollback()
frappe.logger().error(f"[Auto Depreciation] Error submitting JE {je['name']}: {frappe.get_traceback()}")
e or paste code here
This code brings the flg error. Some Journal Entries are Submitted and some are not . Please assist.
tTraceback with variables (most recent call last):
File "apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py", line 142, in execute
frappe.get_doc("Server Script", script_name).execute_scheduled_method()
self = <ScheduledJobType: depreciation_automatically_daily>
script_name = 'depreciation_automatically'
File "apps/frappe/frappe/core/doctype/server_script/server_script.py", line 185, in execute_scheduled_method
safe_exec(self.script, script_filename=self.name)
self = <ServerScript: depreciation_automatically>
File "apps/frappe/frappe/utils/safe_exec.py", line 114, in safe_exec
exec(
script = 'journal_entries = frappe.get_all(\r\n "Journal Entry",\r\n filters={\r\n "docstatus": 0,\r\n "voucher_type": "Depreciation Entry",\r\n },\r\n fields=["name"]\r\n)\r\n\r\nfor i, je in enumerate(journal_entries, start=1):\r\n try:\r\n je_doc = frappe.get_doc("Journal Entry", je["name"])\r\n je_doc.submit()\r\n frappe.db.commit()\r\n\r\n if i % 50 == 0:\r\n frappe.logger().info(f"[Auto Depreciation] Processed {i} Journal Entries")\r\n\r\n except Exception as e:\r\n frappe.db.rollback()\r\n frappe.logger().error(f"[Auto Depreciation] Error submitting JE {je[\'name\']}: {frappe.get_traceback()}")\r\n'
_globals = None
_locals = None
restrict_commit_rollback = False
script_filename = 'depreciation_automatically'
exec_globals = {'json': {'loads': <function loads at 0x7f4d4e1abba0>, 'dumps': <function dumps at 0x7f4d4e1ab420>}, 'as_json': <function as_json at 0x7f4d4cc7d800>, 'dict': <class 'dict'>, 'log': <function log at 0x7f4d4d51a660>, '_dict': <class 'frappe.types.frappedict._dict'>, 'args': {}, 'frappe': {'call': <function call_whitelisted_function at 0x7f4d4a2db420>, 'flags': {}, 'format': <function format_value at 0x7f4d4cc7d9e0>, 'format_value': <function format_value at 0x7f4d4cc7d9e0>, 'date_format': 'dd-mm-yyyy', 'time_format': 'HH:mm:ss', 'format_date': <function global_date_format at 0x7f4d4d4e77e0>, 'form_dict': {}, 'bold': <function bold at 0x7f4d4cc7e160>, 'copy_doc': <function copy_doc at 0x7f4d4cc7d300>, 'errprint': <function errprint at 0x7f4d4d51a520>, 'qb': <class 'frappe.query_builder.builder.MariaDB'>, 'get_meta': <function get_meta at 0x7f4d4d2ec220>, 'new_doc': <function new_doc at 0x7f4d4d51b740>, 'get_doc': <function get_doc at 0x7f4d4d2ec040>, 'get_mapped_doc': <function get_mapped...
filename = '<serverscript>: depreciation_automatically'
File "<serverscript>: depreciation_automatically", line 21, in <module>
json = {'loads': <function loads at 0x7f4d4e1abba0>, 'dumps': <function dumps at 0x7f4d4e1ab420>}
as_json = <function as_json at 0x7f4d4cc7d800>
dict = <class 'dict'>
log = <function log at 0x7f4d4d51a660>
_dict = <class 'frappe.types.frappedict._dict'>
args = {}
frappe = {'call': <function call_whitelisted_function at 0x7f4d4a2db420>, 'flags': {}, 'format': <function format_value at 0x7f4d4cc7d9e0>, 'format_value': <function format_value at 0x7f4d4cc7d9e0>, 'date_format': 'dd-mm-yyyy', 'time_format': 'HH:mm:ss', 'format_date': <function global_date_format at 0x7f4d4d4e77e0>, 'form_dict': {}, 'bold': <function bold at 0x7f4d4cc7e160>, 'copy_doc': <function copy_doc at 0x7f4d4cc7d300>, 'errprint': <function errprint at 0x7f4d4d51a520>, 'qb': <class 'frappe.query_builder.builder.MariaDB'>, 'get_meta': <function get_meta at 0x7f4d4d2ec220>, 'new_doc': <function new_doc at 0x7f4d4d51b740>, 'get_doc': <function get_doc at 0x7f4d4d2ec040>, 'get_mapped_doc': <function get_mapped_doc at 0x7f4d4a4379c0>, 'get_last_doc': <function get_last_doc at 0x7f4d4d2ec0e0>, 'get_cached_doc': <function get_cached_doc at 0x7f4d4d51b880>, 'get_list': <function get_list at 0x7f4d4cc7d620>, 'get_all': <function get_all at 0x7f4d4cc7d6c0>, 'get_system_settings': <function get_sys...
FrappeClient = <class 'frappe.frappeclient.FrappeClient'>
style = {'border_color': '#d1d8dd'}
get_toc = <function get_toc at 0x7f4d4a2d82c0>
get_next_link = <function get_next_link at 0x7f4d4a2d8360>
_ = <function _ at 0x7f4d4e1f07c0>
scrub = <function scrub at 0x7f4d4cc7c2c0>
guess_mimetype = <function guess_type at 0x7f4d4dcc4ae0>
html2text = <function html2text at 0x7f4d4b65cfe0>
dev_server = 0
run_script = <function run_script at 0x7f4d4a2db4c0>
is_job_queued = <function is_job_queued at 0x7f4d4a2db2e0>
get_visible_columns = <function get_visible_columns at 0x7f4d4a2da8e0>
__builtins__ = {'__build_class__': <built-in function __build_class__>, 'None': None, 'False': False, 'True': True, 'abs': <built-in function abs>, 'bool': <class 'bool'>, 'bytes': <class 'bytes'>, 'callable': <built-in function callable>, 'chr': <built-in function chr>, 'complex': <class 'complex'>, 'divmod': <built-in function divmod>, 'float': <class 'float'>, 'hash': <built-in function hash>, 'hex': <built-in function hex>, 'id': <built-in function id>, 'int': <class 'int'>, 'isinstance': <built-in function isinstance>, 'issubclass': <built-in function issubclass>, 'len': <built-in function len>, 'oct': <built-in function oct>, 'ord': <built-in function ord>, 'pow': <built-in function pow>, 'range': <class 'range'>, 'repr': <built-in function repr>, 'round': <built-in function round>, 'slice': <class 'slice'>, 'sorted': <built-in function sorted>, 'str': <class 'str'>, 'tuple': <class 'tuple'>, 'zip': <class 'zip'>, 'ArithmeticError': <class 'ArithmeticError'>, 'AssertionError': <class 'Assertion...
_write_ = <function _write at 0x7f4d4a2dbd80>
_getitem_ = <function _getitem at 0x7f4d4a2dbb00>
_getattr_ = <function _getattr_for_safe_exec at 0x7f4d4a2dbba0>
_print_ = <class 'frappe.utils.safe_exec.FrappePrintCollector'>
_getiter_ = <built-in function iter>
_iter_unpack_sequence_ = <function guarded_iter_unpack_sequence at 0x7f4d4ae427a0>
abs = <built-in function abs>
all = <built-in function all>
any = <built-in function any>
bool = <class 'bool'>
enumerate = <class 'enumerate'>
isinstance = <built-in function isinstance>
issubclass = <built-in function issubclass>
list = <class 'list'>
max = <built-in function max>
min = <built-in function min>
range = <class 'range'>
set = <class 'set'>
sorted = <built-in function sorted>
sum = <built-in function sum>
tuple = <class 'tuple'>
journal_entries = [{'name': 'ACC-JV-2025-46875'}, {'name': 'ACC-JV-2025-46874'}, {'name': 'ACC-JV-2025-46873'}, {'name': 'ACC-JV-2025-46872'}, {'name': 'ACC-JV-2025-46871'}, {'name': 'ACC-JV-2025-46870'}, {'name': 'ACC-JV-2025-46869'}, {'name': 'ACC-JV-2025-46868'}, {'name': 'ACC-JV-2025-46867'}, {'name': 'ACC-JV-2025-46866'}, {'name': 'ACC-JV-2025-46865'}, {'name': 'ACC-JV-2025-46864'}, {'name': 'ACC-JV-2025-46863'}, {'name': 'ACC-JV-2025-46862'}, {'name': 'ACC-JV-2025-46861'}, {'name': 'ACC-JV-2025-46860'}, {'name': 'ACC-JV-2025-46859'}, {'name': 'ACC-JV-2025-46858'}, {'name': 'ACC-JV-2025-46857'}, {'name': 'ACC-JV-2025-46856'}, {'name': 'ACC-JV-2025-46855'}, {'name': 'ACC-JV-2025-46854'}, {'name': 'ACC-JV-2025-46853'}, {'name': 'ACC-JV-2025-46852'}, {'name': 'ACC-JV-2025-46851'}, {'name': 'ACC-JV-2025-46850'}, {'name': 'ACC-JV-2025-46849'}, {'name': 'ACC-JV-2025-46848'}, {'name': 'ACC-JV-2025-46847'}, {'name': 'ACC-JV-2025-46846'}, {'name': 'ACC-JV-2025-46845'}, {'name': 'ACC-JV-2025-46844'}, {'name'...
i = 1
je = {'name': 'ACC-JV-2025-46875'}
je_doc = <JournalEntry: ACC-JV-2025-46875 docstatus=1>
File "apps/frappe/frappe/utils/safe_exec.py", line 54, in default_function
raise AttributeError(f"module has no attribute '{key}'")
args = ()
kwargs = {}
key = ********
builtins.AttributeError: module has no attribute 'logger'ype or paste code here
type or paste code here