Open zahidmansoor opened 2 months ago
The patch below causes this error. Kindly help me to fix it. frappe/frappe-bench/apps/erpnext/erpnext/patches/v15_0/pycache/add_disassembly_order_stock_entry_type.cpython-310.pyc
Modify the Patch:
You will need to modify the patch file to ensure that it does not attempt to set an invalid value. Navigate to the patch file located at /home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v15_0/add_disassembly_order_stock_entry_type.py and adjust the logic to use a valid "Purpose" value or skip the operation if "Disassemble" is not allowed.
Just replace the following code and save..
import frappe
from frappe import _
def execute():
try:
# Check if 'Disassemble' is a valid purpose before proceeding
valid_purposes = [
"Material Issue", "Material Receipt", "Material Transfer",
"Material Transfer for Manufacture", "Material Consumption for Manufacture",
"Manufacture", "Repack", "Send to Subcontractor"
]
# If 'Disassemble' is not valid, skip this operation
if "Disassemble" not in valid_purposes:
frappe.log_error(_("Skipping patch: 'Disassemble' is not a valid purpose"), "Patch Skipped")
return
# Proceed with creating the stock entry type if valid
frappe.get_doc({
"doctype": "Stock Entry Type",
"name": "Disassemble",
"purpose": "Disassemble"
}).insert(ignore_permissions=True)
except frappe.ValidationError as e:
frappe.log_error(message=str(e), title=_("Validation Error in Patch"))
# Optionally, handle the exception or re-raise it
raise
Then try these commands ... bench --site your-site-name execute erpnext.patches.v15_0.add_disassembly_order_stock_entry_type.execute bench update --patch
I have proceeded with your command but it does not allow me to do bench update because it gives an error that you have committed local changes
I have proceeded with your command but it does not allow me to do bench update because it gives an error that you have committed local changes
I am trying to do this in FrappeCloud, restoring a new site from backup. I am getting this same error :
Executing erpnext.patches.v15_0.add_disassembly_order_stock_entry_type #1 in (_d1beae7343f9ce26) .... frappe.exceptions.ValidationError: Purpose cannot be "Disassemble". It should be one of "", "Send to Warehouse", "Material Transfer"
I can't edit the Stock Entry Type - Purpose field, I get this error - You can't set 'Options' for field Purpose
Can you please help me @akashdubey22 ?
Information about bug
When I updated my erpnext to latest version, by doing bench update, I get the following error: Executing erpnext.patches.v15_0.add_disassembly_order_stock_entry_type #1 in shamojee.com (_edc58923b501049b) Queued rebuilding of search index for shamojee.com
Executing erpnext.patches.v15_0.add_disassembly_order_stock_entry_type #1 in shamojee.com (_edc58923b501049b) Queued rebuilding of search index for shamojee.com
Traceback with variables (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, mod_name = 'frappe.utils.bench_helper' alter_argv = True mod_spec = ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f6ebd12afe0>, origin='/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py') code = <code object at 0x7f6ebbb3c7c0, file "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 1>
main_globals = {'name': 'main', 'doc': None, 'package': 'frappe.utils', 'loader': <_frozen_importlib_external.SourceFileLoader object at 0x7f6ebd12afe0>, 'spec': ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f6ebd12afe0>, origin='/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py'), 'annotations': {}, 'builtins': <module 'builtins' (built-in)>, 'file': '/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py', 'cached': '/home/frappe/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc', 'importlib': <module 'importlib' from '/usr/lib/python3.10/importlib/init.py'>, 'json': <module 'json' from '/usr/lib/python3.10/json/init.py'>, 'os': <module 'os' from '/usr/lib/python3.10/os.py'>, 'traceback': <module 'traceback' from '/usr/lib/python3.10/traceback.py'>, 'warnings': <module 'warnings' from '/usr/lib/python3.10/warnings.py'>, 'Path': <cl...
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
code = <code object at 0x7f6ebbb3c7c0, file "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 1>
run_globals = {'name': 'main', 'doc': None, 'package': 'frappe.utils', 'loader': <_frozen_importlib_external.SourceFileLoader object at 0x7f6ebd12afe0>, 'spec': ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f6ebd12afe0>, origin='/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py'), 'annotations': {}, 'builtins': <module 'builtins' (built-in)>, 'file': '/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py', 'cached': '/home/frappe/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc', 'importlib': <module 'importlib' from '/usr/lib/python3.10/importlib/init.py'>, 'json': <module 'json' from '/usr/lib/python3.10/json/init.py'>, 'os': <module 'os' from '/usr/lib/python3.10/os.py'>, 'traceback': <module 'traceback' from '/usr/lib/python3.10/traceback.py'>, 'warnings': <module 'warnings' from '/usr/lib/python3.10/warnings.py'>, 'Path': <cl...
init_globals = None
mod_name = 'main'
mod_spec = ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f6ebd12afe0>, origin='/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py')
pkg_name = 'frappe.utils'
script_name = None
loader = <_frozen_importlib_external.SourceFileLoader object at 0x7f6ebd12afe0>
fname = '/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py'
cached = '/home/frappe/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc'
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in
main()
...skipped... 27 vars
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
click.Group(commands=commands)(prog_name="bench")
commands = {'frappe': , 'get-frappe-commands': , 'get-frappe-help': }
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1157, in call
return self.main(args, kwargs)
self =
args = ()
kwargs = {'prog_name': 'bench'}
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
self =
args = ['frappe', '--site', 'shamojee.com', 'migrate']
prog_name = 'bench'
complete_var = None
standalone_mode = True
windows_expand_args = True
extra = {}
ctx = <click.core.Context object at 0x7f6ebc2cbfa0>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
_process_result = <function MultiCommand.invoke.._process_result at 0x7f6ebbb56200>
args = ['migrate']
cmd_name = 'frappe'
cmd =
sub_ctx = <click.core.Context object at 0x7f6eba594850>
ctx = <click.core.Context object at 0x7f6ebc2cbfa0>
self =
class = <class 'click.core.MultiCommand'>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
_process_result = <function MultiCommand.invoke.._process_result at 0x7f6eba549900>
args = []
cmd_name = 'migrate'
cmd =
sub_ctx = <click.core.Context object at 0x7f6eba594c10>
ctx = <click.core.Context object at 0x7f6eba594850>
self =
class = <class 'click.core.MultiCommand'>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, ctx.params)
self =
ctx = <click.core.Context object at 0x7f6eba594c10>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback( args, kwargs)
_Contextself = <click.core.Context object at 0x7f6eba594c10>
_Context__callback = <function migrate at 0x7f6ebbb85ea0>
args = ()
kwargs = {'skip_failing': False, 'skip_search_index': False}
ctx = <click.core.Context object at 0x7f6eba594c10>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
args = ()
kwargs = {'skip_failing': False, 'skip_search_index': False}
f = <function migrate at 0x7f6ebbb85c60>
File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/init__.py", line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, kwargs)
ctx = <click.core.Context object at 0x7f6eba594c10>
args = ()
kwargs = {'skip_failing': False, 'skip_search_index': False}
profile = False
f = <function migrate at 0x7f6ebbb85bd0>
File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 616, in migrate
SiteMigration(
context = {'sites': ['shamojee.com'], 'force': False, 'verbose': False, 'profile': False}
skip_failing = False
skip_search_index = False
activate_by_import = <module 'traceback_with_variables.activate_by_import' from '/home/frappe/frappe-bench/env/lib/python3.10/site-packages/traceback_with_variables/activate_by_import.py'>
SiteMigration = <class 'frappe.migrate.SiteMigration'>
site = 'shamojee.com'
File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 186, in run
self.run_schema_updates()
self = <frappe.migrate.SiteMigration object at 0x7f6eba594b20>
site = 'shamojee.com'
filelock = <function filelock at 0x7f6eb8fb9f30>
File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 52, in wrapper
raise e
args = (<frappe.migrate.SiteMigration object at 0x7f6eba594b20>,)
kwargs = {}
method = <function SiteMigration.run_schema_updates at 0x7f6eb8fb9b40>
File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 44, in wrapper
ret = method(*args, **kwargs)
args = (<frappe.migrate.SiteMigration object at 0x7f6eba594b20>,)
kwargs = {}
method = <function SiteMigration.run_schema_updates at 0x7f6eb8fb9b40>
File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 121, in run_schema_updates
frappe.modules.patch_handler.run_all(
self = <frappe.migrate.SiteMigration object at 0x7f6eba594b20>
File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 76, in run_all
run_patch(patch)
patch_type = <PatchType.post_model_sync: 'post_model_sync'>
executed = {"execute:frappe.delete_doc_if_exists('Workspace', 'ERPNext Integrations Settings')", 'erpnext.patches.v12_0.rename_lost_reason_detail', 'frappe.patches.v14_0.different_encryption_key', 'erpnext.patches.v13_0.update_start_end_date_for_old_shift_assignment', 'erpnext.patches.v12_0.set_job_offer_applicant_email', 'frappe.patches.v15_0.copy_disable_prepared_report_to_prepared_report', 'erpnext.patches.v13_0.enable_provisional_accounting', 'erpnext.patches.v13_0.trim_sales_invoice_custom_field_length', 'erpnext.patches.v15_0.rename_purchase_receipt_amount_to_purchase_amount', 'erpnext.patches.v12_0.rename_pricing_rule_child_doctypes', 'erpnext.patches.v12_0.add_taxjar_integration_field', 'erpnext.patches.v13_0.setup_uae_vat_fields', 'frappe.patches.v13_0.increase_password_length', 'frappe.patches.v11_0.set_allow_self_approval_in_workflow', 'frappe.patches.v12_0.remove_feedback_rating', 'erpnext.patches.v12_0.set_italian_import_supplier_invoice_permissions', 'execute:frappe.utils.global_sea...
run_patch = <function run_all..run_patch at 0x7f6eb7f82050>
patches = ["execute:frappe.get_doc('Role', 'Guest').save() # remove desk access", 'frappe.core.doctype.role.patches.v13_set_default_desk_properties', 'frappe.patches.v14_0.update_workspace2 # 06.06.2023', 'frappe.patches.v14_0.drop_data_import_legacy', 'frappe.patches.v14_0.copy_mail_data #08.03.21', 'frappe.patches.v14_0.update_github_endpoints #08-11-2021', 'frappe.patches.v14_0.remove_db_aggregation', 'frappe.patches.v14_0.update_color_names_in_kanban_board_column', 'frappe.patches.v14_0.update_is_system_generated_flag', 'frappe.patches.v14_0.update_auto_account_deletion_duration', 'frappe.patches.v14_0.update_integration_request', 'frappe.patches.v14_0.set_document_expiry_default', 'frappe.patches.v14_0.delete_data_migration_tool', 'frappe.patches.v14_0.set_suspend_email_queue_default', 'frappe.patches.v14_0.different_encryption_key', 'frappe.patches.v14_0.update_multistep_webforms', "execute:frappe.delete_doc('Page', 'background_jobs', ignoremissing=True, force=True)", 'frappe.patches.v14...
patch = 'erpnext.patches.v15_0.add_disassembly_order_stock_entry_type #1'
skip_failing = False
File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 62, in run_patch
if not run_single(patchmodule=patch):
patch = 'erpnext.patches.v15_0.add_disassembly_order_stock_entry_type #1'
skip_failing = False
File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 152, in run_single
return execute_patch(patchmodule, method, methodargs)
patchmodule = 'erpnext.patches.v15_0.add_disassembly_order_stock_entry_type #1'
method = None
methodargs = None
force = False
conf =
File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 188, in execute_patch
_patch()
patchmodule = 'erpnext.patches.v15_0.add_disassembly_order_stock_entry_type #1'
method = None
methodargs = None
has_patch_file = True
patch = 'erpnext.patches.v15_0.add_disassembly_order_stock_entry_type.execute'
docstring = ''
_patch = <function execute at 0x7f6eb7ab3d90>
start_time = 940029.764886946
File "/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v15_0/add_disassembly_order_stock_entry_type.py", line 6, in execute
frappe.get_doc(
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 292, in insert
self._validate()
self =
ignore_permissions = True
ignore_links = None
ignore_if_duplicate = False
ignore_mandatory = None
set_name = None
set_child_names = True
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 576, in _validate
self._validate_selects()
self =
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 886, in _validate_selects
frappe.throw(
self =
df =
options = ['Material Issue', 'Material Receipt', 'Material Transfer', 'Material Transfer for Manufacture', 'Material Consumption for Manufacture', 'Manufacture', 'Repack', 'Send to Subcontractor']
value = 'Disassemble'
prefix = ''
label = 'Purpose'
comma_options = 'Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture", "Repack", "Send to Subcontractor'
File "/home/frappe/frappe-bench/apps/frappe/frappe/init.py", line 652, in throw
msgprint(
msg = ' Purpose cannot be "Disassemble". It should be one of "Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture", "Repack", "Send to Subcontractor"'
exc = <class 'frappe.exceptions.ValidationError'>
title = None
is_minimizable = False
wide = False
as_list = False
primary_action = None
File "/home/frappe/frappe-bench/apps/frappe/frappe/init.py", line 617, in msgprint
_raise_exception()
title = None
as_table = False
as_list = False
indicator = 'red'
alert = False
primary_action = None
is_minimizable = False
wide = False
realtime = False
sys = <module 'sys' (built-in)>
_raise_exception = <function msgprint.._raise_exception at 0x7f6eb7ab3520>
msg = ' Purpose cannot be "Disassemble". It should be one of "Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture", "Repack", "Send to Subcontractor"'
out = {'message': ' Purpose cannot be "Disassemble". It should be one of "Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture", "Repack", "Send to Subcontractor"', 'title': 'Message', 'indicator': 'red', 'raise_exception': 1, 'frappe_exc_id': 'f39b975f316ce355fc4fc8e63fde5e7f4dc4a43907d60474840779dc'}
raise_exception = <class 'frappe.exceptions.ValidationError'>
...skipped... 1 vars
File "/home/frappe/frappe-bench/apps/frappe/frappe/init.py", line 568, in _raise_exception
raise exc
exc = ValidationError(' Purpose cannot be "Disassemble". It should be one of "Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture", "Repack", "Send to Subcontractor"')
msg = ' Purpose cannot be "Disassemble". It should be one of "Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture", "Repack", "Send to Subcontractor"'
out = {'message': ' Purpose cannot be "Disassemble". It should be one of "Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture", "Repack", "Send to Subcontractor"', 'title': 'Message', 'indicator': 'red', 'raise_exception': 1, 'frappe_exc_id': 'f39b975f316ce355fc4fc8e63fde5e7f4dc4a43907d60474840779dc'}
raise_exception = <class 'frappe.exceptions.ValidationError'>
...skipped... 1 vars
frappe.exceptions.ValidationError: Purpose cannot be "Disassemble". It should be one of "Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture", "Repack", "Send to Subcontractor"
Module
other
Version
ERPNext: v15.34.2 (version-15)
Frappe Framework: v15.39.1 (version-15)
Frappe HR: v15.28.3 (version-15)
Payments: v0.0.1 (develop)
Installation method
manual install
Relevant log output / Stack trace / Full Error Message.