Error when trying to Submit or Cancel Sales Invoice [V8]

Hi,

The following error occurs when trying to Submit or Cancel Sales Invoices:

Traceback (most recent call last):
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 19, in savedocs
    doc.submit()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 741, in submit
    self._submit()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 730, in _submit
    self.save()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 231, in save
    return self._save(*args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 264, in _save
    self.run_before_save_methods()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 775, in run_before_save_methods
    self.run_method("validate")
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 667, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 892, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 875, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 661, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 89, in validate
    self.set_status()
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/controllers/status_updater.py", line 122, in set_status
    if frappe.safe_eval(s[1][5:], None, { "self": self.as_dict(), "getdate": getdate, "nowdate": nowdate }):
AttributeError: 'module' object has no attribute 'safe_eval'

Traceback (most recent call last):
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/app.py", line 56, in application
    response = frappe.handler.handle()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 42, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 907, in call
    return fn(*args, **newargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 19, in savedocs
    doc.submit()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 741, in submit
    self._submit()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 730, in _submit
    self.save()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 231, in save
    return self._save(*args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 264, in _save
    self.run_before_save_methods()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 775, in run_before_save_methods
    self.run_method("validate")
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 667, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 892, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 875, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 661, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 89, in validate
    self.set_status()
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/controllers/status_updater.py", line 122, in set_status
    if frappe.safe_eval(s[1][5:], None, { "self": self.as_dict(), "getdate": getdate, "nowdate": nowdate }):
AttributeError: 'module' object has no attribute 'safe_eval'

“erpnext”: “8.0.14”
“frappe”: “8.0.7”

Please advise

Kind regards,

@wale,

frappe.safe_eval method is available in frappe version 8.0.8 version and so you will need to pull the frappe app in order fix the issue.

Thanks, Makarand

hi @makarand_b

thanks for your suggestion but bench update only seems to pull frappe 8.0.7

Any ideas?

Kind regards,

@wale,

currently, the master branch is on 8.0.19 please check the git remote URL using git remote -v

hi @makarand_b

below is the result after running the command in the frappe folder:

upstream        https://github.com/frappe/frappe.git (fetch)
upstream        https://github.com/frappe/frappe.git (push)

hi @makarand_b

Any suggestions please?

Kind regards,

@wale,

try to run the git pull --rebase upstream your_branch in both frappe and erpnext app then run the bench migrate command

hi @makarand_b

what’s supposed to be the value for ‘your_branch’ ?

you can get the branch name by running git branch command

hi @makarand_b

I got the following output from both app folders

From https://github.com/frappe/frappe
 * branch            master     -> FETCH_HEAD
Current branch master is up to date.

I then ran the bench migrate from frappe-bench but there doesn’t seem to be any change. Also, I noticed only one site seemed to migrate when running the command

@wale,

can you check if the safe_eval method exist in the frappe/__init__.py the file also if your site is hosted using supervisor then please try to restart the supervisor using sudo supervisorctl restart

hi @makarand_b

The file doesn’t seem to be available in the frappe folder. Below is the output after running ls -a

.                frappe           ISSUE_TEMPLATE.md  setup.py
..               frappe.egg-info  license.txt        socketio.js
attributions.md  .git             MANIFEST.in        test_sites
ci               .gitignore       README.md          .travis.yml
CONTRIBUTING.md  hooks.md         requirements.txt

I’ve had to run sudo supervisorctl restart several times as the error below keeps happening after every bench update:

INFO:bench.utils:sudo supervisorctl restart frappe:
unix:///var/run/supervisor.sock no such file

There’s however still no change

@wale

check the apps/frappe/frappe/__init__.py file

hi @makarand_b

please find content of file below:

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
"""
globals attached to frappe module
+ some utility functions that should probably be moved
"""
from __future__ import unicode_literals

from werkzeug.local import Local, release_local
import os, sys, importlib, inspect, json

# public
from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template

__version__ = '8.0.19'
__title__ = "Frappe Framework"

local = Local()

frappe app seems to be on version 8.0.19, please try to delete the __init__.pyc file then restart supervisorctl.

hi @makarand_b

did you mean the __init__.py file?

hi @makarand_b

I’ve deleted the __init__.pyc but running sudo supervisorctl restart gives the error I mentioned above. I then ran sudo service supervisor restart

There however doesn’t seem to be any change still

Any further suggestions on how to resolve this will be greatly appreciated

Thanks

Hi @makarand_b

restarting the server seems to have taken care of the issue. The version number is bumped to 8.0.19 but there’s a new issue. When I try to Cancel and Amend an existing Sales Invoice, I get the error below:

“Due Date cannot be before Posting Date”

Please advise

Thanks

@wale Can you please create a separate issue in github for due date issue?