Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback to item_name if description is not found #30619

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions erpnext/stock/doctype/item/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
now_datetime,
nowtime,
strip,
strip_html,
)
from frappe.utils.html_utils import clean_html

Expand Down Expand Up @@ -69,10 +70,6 @@ def autoname(self):
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:
Expand All @@ -86,7 +83,7 @@ def validate(self):
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()
Expand Down
7 changes: 7 additions & 0 deletions erpnext/stock/doctype/item/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,13 @@ def test_item_dashboard(self):
self.assertTrue(get_data(warehouse="_Test Warehouse - _TC"))
self.assertTrue(get_data(item_group="All Item Groups"))

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")
Expand Down