AttributeError: 'PurchaseInvoice' object has no attribute 'update_stock'

Hi,

I am getting error AttributeError: ‘PurchaseInvoice’ object has no attribute ‘update_stock’ while upgrading from v6 to v7. Kindly help. Please find the details below.

INFO:bench.utils:updating bench
Already up-to-date.
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
From GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript

Executing erpnext.patches.v6_4.fix_expense_included_in_valuation in site1.local
PINV-00001
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 162, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 16, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 209, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 30, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 83, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v6_4/fix_expense_included_in_valuation.py”, line 52, in execute
purchase_invoice.make_gl_entries()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py”, line 309, in make_gl_entries
gl_entries = self.get_gl_entries()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py”, line 340, in get_gl_entries
self.make_item_gl_entries(gl_entries)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py”, line 379, in make_item_gl_entries
if self.update_stock and self.auto_accounting_for_stock and item.item_code in stock_items:
AttributeError: ‘PurchaseInvoice’ object has no attribute ‘update_stock’

go to frappe-bench location from terminal and execute following commands one by one

  1. bench --site site1.local console

import frappe
frappe.reload_doctype("accounts", "doctype", "purchase_invoice")
exit

3.bench --site site1.local migrate

saurabh,

Thank you for your reply. I tried your solution, but I got TypeError.

TypeError Traceback (most recent call last)
/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.pyc in ()
----> 1 frappe.reload_doctype(“accounts”, “doctype”, “purchase_invoice”)

TypeError: reload_doctype() takes at most 2 arguments (3 given)

@rajesh.keladimath sorry its my bad.

use. frappe.reload_doc(“accounts”, “doctype”, “purchase_invoice”)

@saurabh6790,

Thank you. That fixed the issue. But now, I getting “mysql_exceptions.OperationalError: (1054, “Unknown column ‘disabled’ in ‘field list’”)”.

@rajesh.keladimath once again try with bench update, if still issue persist then please check application branches.

@saurabh6790,

I tried bench update again, but still the error persists. I tried switching between the branches, but no luck (switch-to-master and switch-to-develop). Please, help me to fix the issue. My site is down from past 2 days.

Executing erpnext.patches.v6_4.fix_expense_included_in_valuation in site1.local (1bd3e0294d)
PINV-00001
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 162, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 16, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 209, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 30, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 83, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v6_4/fix_expense_included_in_valuation.py”, line 52, in execute
purchase_invoice.make_gl_entries()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py”, line 315, in make_gl_entries
update_outstanding=update_outstanding, merge_entries=False)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py”, line 19, in make_gl_entries
save_entries(gl_map, adv_adj, update_outstanding)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py”, line 86, in save_entries
make_entry(entry, adv_adj, update_outstanding)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py”, line 94, in make_entry
gle.insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 203, in insert
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 754, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 655, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 883, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 866, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 649, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py”, line 24, in validate
self.validate_party()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py”, line 111, in validate_party
validate_party_frozen_disabled(self.party_type, self.party)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/party.py”, line 343, in validate_party_frozen_disabled
party = frappe.db.get_value(party_type, party_name, [“is_frozen”, “disabled”], as_dict=True)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 410, in get_value
ret = self.get_values(doctype, filters, fieldname, ignore, as_dict, debug, cache=cache)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 451, in get_values
out = self._get_values_from_table(fields, filters, doctype, as_dict, debug, order_by, update)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 563, in _get_values_from_table
conditions, order_by), values, as_dict=as_dict, debug=debug, update=update)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 137, in sql
self._cursor.execute(query, values)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1054, “Unknown column ‘disabled’ in ‘field list’”)

@rajesh.keladimath
Switch to develop branch then execute bench --site site1.local migrate

@saurabh6790,

I tried above solution, but still facing the same issue. I even tried restoring site from backups, but no luck. Can this be fixed by fresh installation of erpnext and restoring the database?

did you problem solved ?. i also face same issue