ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Error When Cancelling Journal Entry


#1

I’ve come across the following error when I tried to cancel a journal entry

Traceback (most recent call last):
  File "/home/rockers/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 43, in cancel
    doc.cancel()
  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 853, in cancel
    self._cancel()
  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 843, in _cancel
    self.save()
  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 260, in save
    return self._save(*args, **kwargs)
  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 313, in _save
    self.run_post_save_methods()
  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 910, in run_post_save_methods
    self.run_method("on_cancel")
  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 772, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 1048, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 1031, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 766, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/rockers/frappe-bench/apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py", line 86, in on_cancel
    from erpnext.hr.doctype.salary_slip.salary_slip import unlink_ref_doc_from_salary_slip
  File "/home/rockers/frappe-bench/apps/erpnext/erpnext/hr/doctype/salary_slip/salary_slip.py", line 17, in <module>
    from erpnext.hr.doctype.payroll_period.payroll_period import get_period_factor, get_payroll_period
  File "/home/rockers/frappe-bench/apps/erpnext/erpnext/hr/doctype/payroll_period/payroll_period.py", line 8, in <module>
    from frappe.utils import date_diff, getdate, formatdate, cint, month_diff, flt
ImportError: cannot import name month_diff

    Traceback (most recent call last):
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/app.py", line 61, in application
	    response = frappe.handler.handle()
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
	    data = execute_cmd(cmd)
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
	    return frappe.call(method, **frappe.form_dict)
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/__init__.py", line 1026, in call
	    """Call a function and match arguments."""
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 43, in cancel
	    doc.cancel()
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 853, in cancel
	    self._cancel()
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 843, in _cancel
	    self.save()
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 260, in save
	    return self._save(*args, **kwargs)
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 313, in _save
	    self.run_post_save_methods()
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 910, in run_post_save_methods
	    self.run_method("on_cancel")
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 772, in run_method
	    out = Document.hook(fn)(self, *args, **kwargs)
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 1048, in composer
	    return composed(self, method, *args, **kwargs)
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 1031, in runner
	    add_to_return_value(self, fn(self, *args, **kwargs))
	  File "/home/rockers/frappe-bench/apps/frappe/frappe/model/document.py", line 766, in <lambda>
	    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
	  File "/home/rockers/frappe-bench/apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py", line 86, in on_cancel
	    from erpnext.hr.doctype.salary_slip.salary_slip import unlink_ref_doc_from_salary_slip
	  File "/home/rockers/frappe-bench/apps/erpnext/erpnext/hr/doctype/salary_slip/salary_slip.py", line 17, in <module>
	    from erpnext.hr.doctype.payroll_period.payroll_period import get_period_factor, get_payroll_period
	  File "/home/rockers/frappe-bench/apps/erpnext/erpnext/hr/doctype/payroll_period/payroll_period.py", line 8, in <module>
	    from frappe.utils import date_diff, getdate, formatdate, cint, month_diff, flt
	ImportError: cannot import name month_diff

I’ve done a bench update but it hasn’t fixed the error.


#2

This seems to have been resolved after a server reboot.