diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 7068c72a8a6..e5e53f25110 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -108,6 +108,8 @@ class DocType(SellingController): self.update_time_log_batch(self.doc.name) self.convert_to_recurring() + def before_cancel(self): + self.update_time_log_batch(None) def on_cancel(self): if cint(self.doc.is_pos) == 1: @@ -122,8 +124,7 @@ class DocType(SellingController): sales_com_obj.check_stop_sales_order(self) self.check_next_docstatus() sales_com_obj.update_prevdoc_detail(0, self) - - self.update_time_log_batch(None) + self.make_gl_entries(is_cancel=1) def on_update_after_submit(self): diff --git a/accounts/doctype/sales_invoice/test_sales_invoice.py b/accounts/doctype/sales_invoice/test_sales_invoice.py index 90599783374..fb290d27e3a 100644 --- a/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -33,10 +33,10 @@ class TestSalesInvoice(unittest.TestCase): tlb = webnotes.bean("Time Log Batch", "_T-Time Log Batch-00001") tlb.submit() - w = webnotes.bean(webnotes.copy_doclist(test_records[0])) - w.doclist[1].time_log_batch = "_T-Time Log Batch-00001" - w.insert() - w.submit() + si = webnotes.bean(webnotes.copy_doclist(test_records[0])) + si.doclist[1].time_log_batch = "_T-Time Log Batch-00001" + si.insert() + si.submit() self.assertEquals(webnotes.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001", "status"), "Billed") @@ -44,7 +44,7 @@ class TestSalesInvoice(unittest.TestCase): self.assertEquals(webnotes.conn.get_value("Time Log", "_T-Time Log-00001", "status"), "Billed") - w.cancel() + si.cancel() self.assertEquals(webnotes.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001", "status"), "Submitted") diff --git a/patches/patch_list.py b/patches/patch_list.py index 0870cee40e4..d1110da323a 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -203,4 +203,5 @@ patch_list = [ "execute:(not webnotes.conn.exists('UOM', 'Hour')) and webnotes.doc({'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Hour'}).insert()", "patches.february_2013.p09_remove_cancelled_warehouses", "patches.march_2013.update_po_prevdoc_doctype", + "patches.february_2013.p09_timesheets", ] \ No newline at end of file