Bench migrate issue during the process of v13 upgrade from v12

During the process of command

bench switch-to-branch version-13 frappe erpnext --upgrade

We got errors when system start to execute migration.

Success: Done in 0.261s
Executing erpnext.patches.v13_0.set_pos_closing_as_failed in (_ddbd5adc132c5c7f)
Success: Done in 0.112s

Traceback (most recent call last):
  File "/usr/lib/python3.6/", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/", line 85, in _run_code
    exec(code, run_globals)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/utils/", line 101, in <module>
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/utils/", line 18, in main
  File "/home/adminuser/frappe-bench/env/lib/python3.6/site-packages/click/", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/adminuser/frappe-bench/env/lib/python3.6/site-packages/click/", line 782, in main
    rv = self.invoke(ctx)
  File "/home/adminuser/frappe-bench/env/lib/python3.6/site-packages/click/", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/adminuser/frappe-bench/env/lib/python3.6/site-packages/click/", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/adminuser/frappe-bench/env/lib/python3.6/site-packages/click/", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/adminuser/frappe-bench/env/lib/python3.6/site-packages/click/", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/adminuser/frappe-bench/env/lib/python3.6/site-packages/click/", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/commands/", line 27, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/commands/", line 301, in migrate
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/", line 73, in migrate
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/utils/", line 24, in sync_fixtures
    import_doc(frappe.get_app_path(app, "fixtures", fname))
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/core/doctype/data_import/", line 191, in import_doc
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/modules/", line 70, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/modules/", line 143, in import_doc
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/model/", line 267, in insert
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/model/", line 993, in run_post_save_methods
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/model/", line 858, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/model/", line 1147, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/model/", line 1130, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/model/", line 852, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/custom/doctype/custom_field/", line 76, in on_update
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/core/doctype/doctype/", line 690, in validate_fields_for_doctype
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/core/doctype/doctype/", line 1001, in validate_fields
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/core/doctype/doctype/", line 955, in validate_data_field_type
    frappe.msgprint(text_str + df_options_str, title="Invalid Data Field", raise_exception=True)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/", line 412, in msgprint
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/", line 368, in _raise_exception
    raise ValidationError(msg)
frappe.exceptions.ValidationError: <b>Legacy Customer ID</b> is an invalid Data field.<br><br>Only Options allowed for Data field are:<br><ul><li>Email</li><li>Name</li><li>Phone</ul>

Customized Filed legacy customer id was created on customer and issue both

Field Name doctype Data Type Option
legacy customer id Customer int
legacy customer id Issue data Customer

We don’t know how to resolve, please help.

Was bench update --patch tried and produced that error or was it bench migrate ?

enter console

bench --site <> console

enter following in console:

f = frappe.get_doc("Custom Field", "Issue-legacy_customer_id")
# Set the options to None, current option Customer is invalid
f.options = None

HI Revant_one

Thanks for the advise.
I followed with your command and did the upgrade from my clean snapshot again.
the issue still there.

Exact same error?

I don’t know what’s wrong then.

try this

1 Like

The wired thing is even i removed my field Legacy Customer ID away before upgrade, I still got the same error exactly.
Any possibility like cache or somewhere else remembered something?

Finally, I was able to upgrade to version-13 successfully by add one more action before real upgrade start, which is bench export-fixtures after modified options by using revant’s command.
My exported fixture json file is stored in my own app, somehow it is read by upgrade script cause the issue.

Thanks all.