From d11692c52ff113f1024a7b82f373b07e1ed3fdbe Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 17 Aug 2022 14:40:40 +0530 Subject: [PATCH] fix: has_content check for fieldtype TextEditor When a TextEditor field contains only an image, while checking for content, HTML tags are stripped off including the only image. This change adds a loose but explicit check for img tag. --- frappe/model/base_document.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frappe/model/base_document.py b/frappe/model/base_document.py index 1162ceacd3..5b6caf4f6e 100644 --- a/frappe/model/base_document.py +++ b/frappe/model/base_document.py @@ -671,10 +671,19 @@ class BaseDocument: return _("Error: Value missing for {0}: {1}").format(_(df.parent), _(df.label)) + def has_content(df): + value = cstr(self.get(df.fieldname)) + has_text_content = strip_html(value).strip() + has_img_tag = "