mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-27 02:28:30 +00:00
* fix: strip html tags before checking for empty description (#30619)
(cherry picked from commit e4c6d6a1a6)
# Conflicts:
# erpnext/stock/doctype/item/test_item.py
* fix: resolve conflicts
Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
@@ -18,6 +18,7 @@ from frappe.utils import (
|
||||
now_datetime,
|
||||
nowtime,
|
||||
strip,
|
||||
strip_html,
|
||||
)
|
||||
from frappe.utils.html_utils import clean_html
|
||||
|
||||
@@ -69,10 +70,6 @@ class Item(Document):
|
||||
self.item_code = strip(self.item_code)
|
||||
self.name = self.item_code
|
||||
|
||||
def before_insert(self):
|
||||
if not self.description:
|
||||
self.description = self.item_name
|
||||
|
||||
def after_insert(self):
|
||||
"""set opening stock and item price"""
|
||||
if self.standard_rate:
|
||||
@@ -86,7 +83,7 @@ class Item(Document):
|
||||
if not self.item_name:
|
||||
self.item_name = self.item_code
|
||||
|
||||
if not self.description:
|
||||
if not strip_html(cstr(self.description)).strip():
|
||||
self.description = self.item_name
|
||||
|
||||
self.validate_uom()
|
||||
|
||||
@@ -683,6 +683,13 @@ class TestItem(FrappeTestCase):
|
||||
self.assertEqual(item.sample_quantity, None)
|
||||
item.delete()
|
||||
|
||||
def test_empty_description(self):
|
||||
item = make_item(properties={"description": "<p></p>"})
|
||||
self.assertEqual(item.description, item.item_name)
|
||||
item.description = ""
|
||||
item.save()
|
||||
self.assertEqual(item.description, item.item_name)
|
||||
|
||||
|
||||
def set_item_variant_settings(fields):
|
||||
doc = frappe.get_doc("Item Variant Settings")
|
||||
|
||||
Reference in New Issue
Block a user