feat: handle exceptions

(cherry picked from commit 353ad5f6ff)
This commit is contained in:
Saqib Ansari
2021-10-10 11:47:48 +05:30
committed by mergify-bot
parent 7e44c30404
commit 2ce36d1edc

View File

@@ -39,8 +39,11 @@ def execute():
frappe.log_error(json.dumps(purchase_invoices + sales_invoices, indent=2), title="Patch Log") frappe.log_error(json.dumps(purchase_invoices + sales_invoices, indent=2), title="Patch Log")
acc_frozen_upto = frappe.db.get_value('Accounts Settings', None, 'acc_frozen_upto') acc_frozen_upto = frappe.db.get_value('Accounts Settings', None, 'acc_frozen_upto')
if acc_frozen_upto:
frappe.db.set_value('Accounts Settings', None, 'acc_frozen_upto', None) frappe.db.set_value('Accounts Settings', None, 'acc_frozen_upto', None)
for invoice in purchase_invoices + sales_invoices: for invoice in purchase_invoices + sales_invoices:
try:
doc = frappe.get_doc(invoice.type, invoice.name) doc = frappe.get_doc(invoice.type, invoice.name)
doc.docstatus = 2 doc.docstatus = 2
doc.make_gl_entries() doc.make_gl_entries()
@@ -49,4 +52,8 @@ def execute():
advance.db_set('exchange_gain_loss', 0, False) advance.db_set('exchange_gain_loss', 0, False)
doc.docstatus = 1 doc.docstatus = 1
doc.make_gl_entries() doc.make_gl_entries()
except Exception:
print(f'Failed to correct gl entries of {invoice.name}')
if acc_frozen_upto:
frappe.db.set_value('Accounts Settings', None, 'acc_frozen_upto', acc_frozen_upto) frappe.db.set_value('Accounts Settings', None, 'acc_frozen_upto', acc_frozen_upto)