How to push custom fields to standard doctypes in custom App?

Hi,

I would like to know if it is possible to push custom fields to Standard doctypes of erpnext from a custom app.

I am trying to prepare an app where there are certain custom fields in the Address doctype would be added if a person installs the app.

I know making new docs is possible but is it possible to push the custom fields through the app and how, it seems that this kind of thing is not explicitly explained in the help files.

1 Like
  • hooks.py add:

fixtures = ["Custom Field"]

  • do bench frappe --export_fixtures

The Custom FIelds will become a part of your app.

1 Like

I am sorry to bother you again but could you be more descriptive in the explanation since I am not a seasoned developer and hence I can’t seem to find a way to add the custom fields.

I have added the line fixtures = ["doctype: 'Address'"] in my hooks.py

When I run the command bench frappe --export_fixtures I am getting the following error:

`Exporting doctype: 'Address'
Traceback (most recent call last):
  File "/home/aditya/frappe-bench/env/bin/frappe", line 9, in <module>
    load_entry_point('frappe==4.4.4', 'console_scripts', 'frappe')()
  File "/home/aditya/frappe-bench/apps/frappe/frappe/cli.py", line 53, in main
    return run(fn, parsed_args)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/cli.py", line 83, in run
    out = globals().get(fn)(**args)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/cli.py", line 67, in new_fn
    return fn(*args, **new_kwargs)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/cli.py", line 669, in export_fixtures
    export_fixtures()
  File "/home/aditya/frappe-bench/apps/frappe/frappe/utils/fixtures.py", line 31, in export_fixtures
    export_csv(fixture, frappe.get_app_path(app, "fixtures", frappe.scrub(fixture) + ".csv"))
  File "/home/aditya/frappe-bench/apps/frappe/frappe/core/page/data_import_tool/data_import_tool.py", line 40, in export_csv
    get_template(doctype=doctype, all_doctypes="Yes", with_data="Yes")
  File "/home/aditya/frappe-bench/apps/frappe/frappe/core/page/data_import_tool/exporter.py", line 24, in get_template
    for df in frappe.get_meta(doctype).get_table_fields():
  File "/home/aditya/frappe-bench/apps/frappe/frappe/__init__.py", line 356, in get_meta
    return frappe.model.meta.get_meta(doctype, cached=cached)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/meta.py", line 18, in get_meta
    return frappe.cache().get_value("meta:" + doctype, lambda: Meta(doctype))
  File "/home/aditya/frappe-bench/apps/frappe/frappe/memc.py", line 21, in get_value
    val = builder()
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/meta.py", line 18, in <lambda>
    return frappe.cache().get_value("meta:" + doctype, lambda: Meta(doctype))
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/meta.py", line 49, in __init__
    super(Meta, self).__init__("DocType", doctype)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/document.py", line 66, in __init__
    self.load_from_db()
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/meta.py", line 54, in load_from_db
    super(Meta, self).load_from_db()
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/document.py", line 96, in load_from_db
    frappe.throw(_("{0} {1} not found").format(_(self.doctype), self.name), frappe.DoesNotExistError)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/__init__.py", line 202, in throw
    msgprint(msg, raise_exception=exc)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/__init__.py", line 199, in msgprint
    _raise_exception()
  File "/home/aditya/frappe-bench/apps/frappe/frappe/__init__.py", line 183, in _raise_exception
    raise raise_exception, msg
frappe.exceptions.DoesNotExistError: DocType doctype: 'Address' not found`

will add custom fields to your app so that when you install the app, custom fields will be setup

My bad

I was trying with the custom field names and other thing, read too much into your post.

Thanks for the help.