ImportError: cannot import name update_item_projected_qty

Hi,
when running bench update we get the following:

File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/patches/v7_0/update_item_projected.py", line 5, in execute
    from erpnext.stock.doctype.bin.bin import update_item_projected_qty
ImportError: cannot import name update_item_projected_qty

bench version
erpnext 10.1.42
frappe 10.1.39

bench setup requirements
Updating Python libraries…
INFO:bench.utils:./env/bin/pip install --upgrade pip==9.0.3
Requirement already up-to-date: pip==9.0.3 in ./env/lib/python2.7/site-packages
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.
INFO:bench.utils:./env/bin/pip install -q -r /home/erpnext/bench-repo/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/s3_backup/requirements.txt
Updating node packages…
INFO:bench.utils:npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
npm WARN frappe@ No description

The usual advice is to run ‘bench update’ again

“npm WARN notsup SKIPPING OPTIONAL DEPENDENCY”

the above warning can be ignored (apparently)

Thank you for your response.

We tried bench update with and without --reset but still get ImportError, it seems there is a problem when executing:

erpnext.patches.v7_0.update_item_projected

We could try to skip the patch, but as @rmehta stated here, it is NOT RECOMMENDED:

Well the import fails since this method update_item_projected_qty is not present in https://github.com/frappe/erpnext/blob/develop/erpnext/stock/doctype/bin/bin.py

That method was added with this 14 April 2016 commit https://github.com/frappe/erpnext/commit/15a7f215b95e04324f350605611968e61d8b5ca2#diff-35f2c2198d994f5a9c014a0bbe300640

The question is what became of that method since then, which commit removed it etc and why?

Then will it be solved in an upcoming version? Should we raise a github issue for this?

Yes probably report it on github.

I can’t grok why that method is missing, whether or why you are an isolated case?

I have no current environment of my own handy right now to troubleshoot…

An update - on 13 Feb 2018 update_item_projected_qty was removed with this commit

https://github.com/frappe/erpnext/commit/5a91989665373069323a67892fa9602beb9bf694#diff-fe904ba948bb4784a58ed710d238db8e

on this basis

https://github.com/frappe/erpnext/pull/12889

FTW I found the commit only by manual inspection; I tried but could not find it via the command line with for example this:

frappe@ubuntu:~/frappe-bench/apps/erpnext$ git log -S update_item_projected_qty ./erpnext/stock/doctype/bin/bin.py

as advised here https://stackoverflow.com/questions/4404444/how-do-i-git-blame-a-deleted-line

edit: a working example https://stackoverflow.com/questions/1528513/git-find-deleted-code

1 Like

I have pushed a fix to hotfix branch to remove the patch. It will be released to master soon. But as of now, you can comment out the patch from patches.txt and go ahead.

2 Likes