Hi,
I have created Tax Deposit Doctype.
I want to insert multiple rows at Tax Deposit.
My code is given below
salary_slips = frappe.db.sql(“SELECT * FROM tabSalary Slip WHERE DATE_FORMAT(posting_date, ‘%Y-%m’)='”+datetime_object+“'”, as_dict=True)
for ss in salary_slips:
> td_entry = frappe.new_doc(“Tax Deposit”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 231, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 254, in _save
self.insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 220, in insert
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 793, in run_post_save_methods
self.run_method(“on_submit”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 667, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 890, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 873, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 661, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/doctype/tax_deposit/tax_deposit.py”, line 21, in on_submit
salary_slips = frappe.db.sql(“SELECT * FROM tabSalary Slip WHERE DATE_FORMAT(posting_date, ‘%Y-%m’)='”+datetime_object+“'”, as_dict=True)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 149, in sql
self._cursor.execute(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
RuntimeError: maximum recursion depth exceeded
Okay. Can u please explain me the difference between parent doctype and parent docname?
Also will this code work for making entries to child table in web forms?
For a child table, parent doctype is the Document Type of the parent, and docname is the name of the parent that is used to identify it
So for the child table Sales Invoice Item (List of items in a sales invoice), parent doctype will be Sales Invoice and parent docname will the name of the invoice for example SINV-0001