[Bug] patch fails with 'DocType Custom Cart Block not found'
Contexte : migration de dokos v2.18.5 (ou v3.0.x) vers v3.x.x (actuellement v3.36.0)
Le patch erpnext.patches.v13_0.populate_e_commerce_settings
échoue.
Voir la trace ci-dessous :
Executing erpnext.patches.v13_0.create_website_items #30-09-2021 in www.somedomain.org (acme)
Creating Website Items : [=========================================] 103%Success: Done in 12.054s
Executing erpnext.patches.v13_0.populate_e_commerce_settings in www.somedomain.org (acme)
Queued rebuilding of search index for www.somedomain.org
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 0x7faaa36cece0>, origin='/home/acme/dokos-bench/apps/frappe/frappe/utils/bench_helper.py')
code = <code object <module> at 0x7faaa168fe10, file "/home/acme/dokos-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 0x7faaa36cece0>, '__spec__': ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7faaa36cece0>, origin='/home/acme/dokos-bench/apps/frappe/frappe/utils/bench_helper.py'), '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': '/home/acme/dokos-bench/apps/frappe/frappe/utils/bench_helper.py', '__cached__': '/home/acme/dokos-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'>, 'P...
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
code = <code object <module> at 0x7faaa168fe10, file "/home/acme/dokos-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 0x7faaa36cece0>, '__spec__': ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7faaa36cece0>, origin='/home/acme/dokos-bench/apps/frappe/frappe/utils/bench_helper.py'), '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': '/home/acme/dokos-bench/apps/frappe/frappe/utils/bench_helper.py', '__cached__': '/home/acme/dokos-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'>, 'P...
init_globals = None
mod_name = '__main__'
mod_spec = ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7faaa36cece0>, origin='/home/acme/dokos-bench/apps/frappe/frappe/utils/bench_helper.py')
pkg_name = 'frappe.utils'
script_name = None
loader = <_frozen_importlib_external.SourceFileLoader object at 0x7faaa36cece0>
fname = '/home/acme/dokos-bench/apps/frappe/frappe/utils/bench_helper.py'
cached = '/home/acme/dokos-bench/apps/frappe/frappe/utils/__pycache__/bench_helper.cpython-310.pyc'
File "/home/acme/dokos-bench/apps/frappe/frappe/utils/bench_helper.py", line 108, in <module>
main()
...skipped... 26 vars
File "/home/acme/dokos-bench/apps/frappe/frappe/utils/bench_helper.py", line 19, in main
click.Group(commands=commands)(prog_name="bench")
commands = {'frappe': <Group frappe>, 'get-frappe-commands': <Command get-frappe-commands>, 'get-frappe-help': <Command get-frappe-help>}
File "/home/acme/dokos-bench/env/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
self = <Group None>
args = ()
kwargs = {'prog_name': 'bench'}
File "/home/acme/dokos-bench/env/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
self = <Group None>
args = ['frappe', '--site', 'www.somedomain.org', 'migrate']
prog_name = 'bench'
complete_var = None
standalone_mode = True
windows_expand_args = True
extra = {}
ctx = <click.core.Context object at 0x7faaa22da440>
File "/home/acme/dokos-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.<locals>._process_result at 0x7faaa16ecf70>
args = ['migrate']
cmd_name = 'frappe'
cmd = <Group frappe>
sub_ctx = <click.core.Context object at 0x7faaa16e4760>
ctx = <click.core.Context object at 0x7faaa22da440>
self = <Group None>
__class__ = <class 'click.core.MultiCommand'>
File "/home/acme/dokos-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.<locals>._process_result at 0x7faaa1576b00>
args = []
cmd_name = 'migrate'
cmd = <Command migrate>
sub_ctx = <click.core.Context object at 0x7faaa16e4220>
ctx = <click.core.Context object at 0x7faaa16e4760>
self = <Group frappe>
__class__ = <class 'click.core.MultiCommand'>
File "/home/acme/dokos-bench/env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
self = <Command migrate>
ctx = <click.core.Context object at 0x7faaa16e4220>
File "/home/acme/dokos-bench/env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
_Context__self = <click.core.Context object at 0x7faaa16e4220>
_Context__callback = <function migrate at 0x7faaa170f250>
args = ()
kwargs = {'skip_failing': False, 'skip_search_index': False}
ctx = <click.core.Context object at 0x7faaa16e4220>
File "/home/acme/dokos-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 0x7faaa170f010>
File "/home/acme/dokos-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 0x7faaa16e4220>
args = ()
kwargs = {'skip_failing': False, 'skip_search_index': False}
profile = False
f = <function migrate at 0x7faaa170ef80>
File "/home/acme/dokos-bench/apps/frappe/frappe/commands/site.py", line 575, in migrate
SiteMigration(
context = {'sites': ['www.somedomain.org'], '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/acme/dokos-bench/env/lib/python3.10/site-packages/traceback_with_variables/activate_by_import.py'>
SiteMigration = <class 'frappe.migrate.SiteMigration'>
site = 'www.somedomain.org'
File "/home/acme/dokos-bench/apps/frappe/frappe/migrate.py", line 175, in run
self.run_schema_updates()
self = <frappe.migrate.SiteMigration object at 0x7faaa16e4100>
site = 'www.somedomain.org'
File "/home/acme/dokos-bench/apps/frappe/frappe/migrate.py", line 41, in wrapper
ret = method(*args, **kwargs)
args = (<frappe.migrate.SiteMigration object at 0x7faaa16e4100>,)
kwargs = {}
method = <function SiteMigration.run_schema_updates at 0x7faa8070c430>
File "/home/acme/dokos-bench/apps/frappe/frappe/migrate.py", line 110, in run_schema_updates
frappe.modules.patch_handler.run_all(
self = <frappe.migrate.SiteMigration object at 0x7faaa16e4100>
File "/home/acme/dokos-bench/apps/frappe/frappe/modules/patch_handler.py", line 76, in run_all
run_patch(patch)
patch_type = <PatchType.pre_model_sync: 'pre_model_sync'>
executed = {'erpnext.patches.v13_0.update_pos_closing_entry_in_merge_log', 'execute:frappe.delete_doc_if_exists("DocType", "Onboarding Slide")', 'frappe.patches.v10_0.remove_custom_field_for_disabled_domain', 'frappe.patches.v4_1.file_manager_fix', 'frappe.patches.v11_0.delete_duplicate_user_permissions', 'erpnext.patches.v12_0.move_due_advance_amount_to_pending_amount', 'erpnext.patches.v11_1.delete_bom_browser', 'execute:frappe.delete_doc("DocType", "Website Template")', "execute:frappe.reload_doc('desk', 'doctype', 'dashboard')", 'erpnext.patches.v11_0.add_default_email_template_for_leave', 'frappe.patches.v8_5.delete_email_group_member_with_invalid_emails', 'erpnext.patches.v11_0.rename_production_order_to_work_order', 'erpnext.patches.v11_0.rename_field_max_days_allowed', 'erpnext.patches.dokos.v1_0.move_gocardless_mandate_to_sepa_mandate', "execute:frappe.reload_doc('core', 'doctype', 'error_snapshot')", "execute:frappe.rename_doc('Country', 'Macedonia, Republic of', 'Macedonia', ignore_if_...
run_patch = <function run_all.<locals>.run_patch at 0x7faa80102200>
patches = ['frappe.patches.dokos.v3_0.force_reload_doctype_model', "execute:frappe.reload_doc('core', 'doctype', 'doctype_state', force=True) #2021-12-15", 'frappe.patches.v12_0.remove_deprecated_fields_from_doctype #2022-04-29', 'execute:frappe.utils.global_search.setup_global_search_table()', "execute:frappe.reload_doc('core', 'doctype', 'doctype_action', force=True)", "execute:frappe.reload_doc('core', 'doctype', 'doctype_link', force=True) #2020-10-17", "execute:frappe.reload_doc('core', 'doctype', 'doctype', force=True) #2017-09-22", "execute:frappe.reload_doc('core', 'doctype', 'docfield', force=True) #2018-02-20", "execute:frappe.reload_doc('desk', 'doctype', 'form_tour', force=True)", "execute:frappe.reload_doc('desk', 'doctype', 'form_tour_step', force=True)", 'frappe.patches.v11_0.drop_column_apply_user_permissions', "execute:frappe.reload_doc('core', 'doctype', 'custom_docperm')", "execute:frappe.reload_doc('core', 'doctype', 'docperm') #2018-05-29", "execute:frappe.reload_doc('core',...
patch = 'erpnext.patches.v13_0.populate_e_commerce_settings'
skip_failing = False
File "/home/acme/dokos-bench/apps/frappe/frappe/modules/patch_handler.py", line 62, in run_patch
if not run_single(patchmodule=patch):
patch = 'erpnext.patches.v13_0.populate_e_commerce_settings'
skip_failing = False
File "/home/acme/dokos-bench/apps/frappe/frappe/modules/patch_handler.py", line 151, in run_single
return execute_patch(patchmodule, method, methodargs)
patchmodule = 'erpnext.patches.v13_0.populate_e_commerce_settings'
method = None
methodargs = None
force = False
conf = <LocalProxy unbound>
File "/home/acme/dokos-bench/apps/frappe/frappe/modules/patch_handler.py", line 187, in execute_patch
_patch()
patchmodule = 'erpnext.patches.v13_0.populate_e_commerce_settings'
method = None
methodargs = None
has_patch_file = True
patch = 'erpnext.patches.v13_0.populate_e_commerce_settings.execute'
docstring = ''
_patch = <function execute at 0x7faa7e2f0550>
start_time = 1067312.118009474
File "/home/acme/dokos-bench/apps/erpnext/erpnext/patches/v13_0/populate_e_commerce_settings.py", line 58, in execute
map_into_e_commerce_settings("Products Settings", products_settings_fields)
products_settings_fields = ['hide_variants', 'products_per_page', 'enable_attribute_filters', 'enable_field_filters']
shopping_cart_settings_fields = ['enabled', 'show_attachments', 'show_price', 'show_stock_availability', 'enable_variants', 'show_contact_us_button', 'show_quantity_in_website', 'show_apply_coupon_code_in_website', 'allow_items_not_in_stock', 'company', 'price_list', 'default_customer_group', 'quotation_series', 'enable_checkout', 'payment_success_url', 'payment_gateway_account', 'save_quotations_as_draft']
map_into_e_commerce_settings = <function execute.<locals>.map_into_e_commerce_settings at 0x7faa7e49fb50>
settings = <ECommerceSettings: E Commerce Settings>
File "/home/acme/dokos-bench/apps/erpnext/erpnext/patches/v13_0/populate_e_commerce_settings.py", line 55, in map_into_e_commerce_settings
settings.save()
doctype = 'Products Settings'
fields = ['hide_variants', 'products_per_page', 'enable_attribute_filters', 'enable_field_filters']
singles = Table('tabSingles')
query = SELECT `field`,`value` FROM `tabSingles` WHERE `doctype`='Products Settings' AND `field` IN ('hide_variants','products_per_page','enable_attribute_filters','enable_field_filters')
data = [{'field': 'enable_attribute_filters', 'value': '0'}, {'field': 'enable_field_filters', 'value': '0'}, {'field': 'hide_variants', 'value': '0'}, {'field': 'products_per_page', 'value': '50'}]
mapper = {'enable_attribute_filters': '0', 'enable_field_filters': '0', 'hide_variants': '0', 'products_per_page': '50'}
key = 'products_per_page'
value = 50
settings = <ECommerceSettings: E Commerce Settings>
File "/home/acme/dokos-bench/apps/frappe/frappe/model/document.py", line 322, in save
return self._save(*args, **kwargs)
self = <ECommerceSettings: E Commerce Settings>
args = ()
kwargs = {}
File "/home/acme/dokos-bench/apps/frappe/frappe/model/document.py", line 373, in _save
self.update_children()
self = <ECommerceSettings: E Commerce Settings>
ignore_permissions = None
ignore_version = None
File "/home/acme/dokos-bench/apps/frappe/frappe/model/document.py", line 427, in update_children
self.update_child_table(df.fieldname, df)
self = <ECommerceSettings: E Commerce Settings>
df = <TableDocField: custom_cart_blocks parent=E Commerce Settings>
File "/home/acme/dokos-bench/apps/frappe/frappe/model/document.py", line 441, in update_child_table
or frappe.get_meta(df.options).is_virtual == 1
self = <ECommerceSettings: E Commerce Settings>
fieldname = 'custom_cart_blocks'
df = <TableDocField: custom_cart_blocks parent=E Commerce Settings>
rows = []
File "/home/acme/dokos-bench/apps/frappe/frappe/__init__.py", line 1237, in get_meta
return frappe.model.meta.get_meta(doctype, cached=cached)
doctype = 'Custom Cart Block'
cached = True
frappe = <module 'frappe' from '/home/acme/dokos-bench/apps/frappe/frappe/__init__.py'>
File "/home/acme/dokos-bench/apps/frappe/frappe/model/meta.py", line 63, in get_meta
meta = Meta(doctype)
doctype = 'Custom Cart Block'
cached = True
meta = None
File "/home/acme/dokos-bench/apps/frappe/frappe/model/meta.py", line 116, in __init__
super().__init__("DocType", doctype)
self = <Meta: Custom Cart Block>
doctype = 'Custom Cart Block'
__class__ = <class 'frappe.model.meta.Meta'>
File "/home/acme/dokos-bench/apps/frappe/frappe/model/document.py", line 109, in __init__
self.load_from_db()
self = <Meta: Custom Cart Block>
args = ('DocType', 'Custom Cart Block')
kwargs = {}
__class__ = <class 'frappe.model.document.Document'>
File "/home/acme/dokos-bench/apps/frappe/frappe/model/meta.py", line 122, in load_from_db
super().load_from_db()
self = <Meta: Custom Cart Block>
__class__ = <class 'frappe.model.meta.Meta'>
File "/home/acme/dokos-bench/apps/frappe/frappe/model/document.py", line 161, in load_from_db
frappe.throw(
self = <Meta: Custom Cart Block>
get_value_kwargs = {'for_update': None, 'as_dict': True, 'order_by': None}
d = None
__class__ = <class 'frappe.model.document.Document'>
File "/home/acme/dokos-bench/apps/frappe/frappe/__init__.py", line 517, in throw
msgprint(
msg = 'DocType Custom Cart Block not found'
exc = <class 'frappe.exceptions.DoesNotExistError'>
title = None
is_minimizable = False
wide = False
as_list = False
File "/home/acme/dokos-bench/apps/frappe/frappe/__init__.py", line 485, in msgprint
_raise_exception()
title = None
as_table = False
as_list = False
indicator = 'red'
alert = False
primary_action = None
is_minimizable = False
wide = False
sys = <module 'sys' (built-in)>
out = {'message': 'DocType Custom Cart Block not found', 'title': 'Message', 'indicator': 'red', 'raise_exception': 1}
_strip_html_tags = <functools._lru_cache_wrapper object at 0x7faa804b5590>
_raise_exception = <function msgprint.<locals>._raise_exception at 0x7faa7e600940>
msg = 'DocType Custom Cart Block not found'
raise_exception = <class 'frappe.exceptions.DoesNotExistError'>
strip_html_tags = <function strip_html_tags at 0x7faaa2714790>
...skipped... 1 vars
File "/home/acme/dokos-bench/apps/frappe/frappe/__init__.py", line 432, in _raise_exception
raise raise_exception(msg)
msg = 'DocType Custom Cart Block not found'
raise_exception = <class 'frappe.exceptions.DoesNotExistError'>
...skipped... 1 vars
frappe.exceptions.DoesNotExistError: DocType Custom Cart Block not found
**Solution de contournement trouvée : **
- lancer la commande de migration avec
bench --site www.somedomaine.org migrate --skip-failing
- le script échoue mais continue les autres patches
- relancer à nouveau la commande de migration
bench --site www.somedomaine.org migrate --skip-failing
- cette fois-ci le patch
erpnext.patches.v13_0.create_website_items
se termine correctement