Skip to content

Commit

Permalink
fix: incorrect link when std field has problem (backport #19744) (#19763
Browse files Browse the repository at this point in the history
)

* fix: clear cache on every update in notifications

This feels like duplicate but ensures that it gets cleared in every
case. E.g. Some class might have overridden validate or ignore_validate
might be set in which case cache doesn't get cleared.

(cherry picked from commit 479e0c1)

* fix: point to custom field link instead

(cherry picked from commit be7fd7a)

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush committed Jan 25, 2023
1 parent 3d93176 commit 4593bb9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions frappe/desk/form/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from frappe.modules import get_module_path, load_doctype_module, scrub
from frappe.translate import extract_messages_from_code, make_dict_from_messages
from frappe.utils import get_html_format
from frappe.utils.data import get_link_to_form

ASSET_KEYS = (
"__js",
Expand Down Expand Up @@ -200,14 +201,19 @@ def _show_missing_doctype_msg(self, df):
# customizations are removed or some custom app is removed but hasn't cleaned
# up after itself.
frappe.clear_last_message()
customize_form_link = f'<a href="/app/customize-form/?doc_type={self.name}">Customize Form</a>'
frappe.throw(
_(
"Field {0} is referring to non-existing doctype {1}, please remove the field from {2} or add the required doctype."
).format(frappe.bold(df.fieldname), frappe.bold(df.options), customize_form_link),
title=_("Missing DocType"),

msg = _("Field {0} is referring to non-existing doctype {1}.").format(
frappe.bold(df.fieldname), frappe.bold(df.options)
)

if df.get("is_custom_field"):
custom_field_link = get_link_to_form("Custom Field", df.name)
msg += " " + _("Please delete the field from {2} or add the required doctype.").format(
custom_field_link
)

frappe.throw(msg, title=_("Missing DocType"))

def add_linked_document_type(self):
for df in self.get("fields", {"fieldtype": "Link"}):
if df.options:
Expand Down
1 change: 1 addition & 0 deletions frappe/email/doctype/notification/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def validate(self):
frappe.cache().hdel("notifications", self.document_type)

def on_update(self):
frappe.cache().hdel("notifications", self.document_type)
path = export_module_json(self, self.is_standard, self.module)
if path:
# js
Expand Down

0 comments on commit 4593bb9

Please sign in to comment.