Bench update error of custom field multi-occurrences

  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/erp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 110, in <module>
    main()
  File "/home/erp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/erp/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/erp/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/erp/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/erp/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/erp/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/erp/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/erp/frappe-bench/env/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/erp/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 31, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/erp/frappe-bench/apps/frappe/frappe/commands/site.py", line 433, in migrate
    migrate(context.verbose, skip_failing=skip_failing, skip_search_index=skip_search_index)
  File "/home/erp/frappe-bench/apps/frappe/frappe/migrate.py", line 77, in migrate
    sync_customizations()
  File "/home/erp/frappe-bench/apps/frappe/frappe/modules/utils.py", line 112, in sync_customizations
    sync_customizations_for_doctype(data, folder)
  File "/home/erp/frappe-bench/apps/frappe/frappe/modules/utils.py", line 171, in sync_customizations_for_doctype
    validate_fields_for_doctype(doctype)
  File "/home/erp/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 907, in validate_fields_for_doctype
    validate_fields(meta)
  File "/home/erp/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 1304, in validate_fields
    check_unique_fieldname(meta.get("name"), d.fieldname)
  File "/home/erp/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 948, in check_unique_fieldname
    frappe.throw(
  File "/home/erp/frappe-bench/apps/frappe/frappe/__init__.py", line 504, in throw
    msgprint(
  File "/home/erp/frappe-bench/apps/frappe/frappe/__init__.py", line 479, in msgprint
    _raise_exception()
  File "/home/erp/frappe-bench/apps/frappe/frappe/__init__.py", line 434, in _raise_exception
    raise raise_exception(msg)
frappe.core.doctype.doctype.doctype.UniqueFieldnameError: Employee: Fieldname employment_type appears multiple times in rows 10, 39

Hi Team, I am trying to run a bench update but the process runs into the above error. I have tried to run:

frappe.delete_doc("Custom Field", "employment_type")
frappe.db.commit()

in the console but I still can’t seem to get passed the error. Does anyone have pointers on how to go about it?

Backup, uninstall the custom app…update…reinstall the custom app…bench migrate/patch

2 Likes

This solution worked and turned out to be a custom app issue. Thanks @trentmu