fix: Handle None value for item description in customer portal invoice view #43823
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the description was not set in an item it throws an error in the customer portal invoice view.
Steps to replicate:
Before:
After:
backport-version-15
Traceback
```log Traceback (most recent call last): File "apps/frappe/frappe/website/serve.py", line 20, in get_response response = renderer_instance.render() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/website/page_renderers/template_page.py", line 84, in render html = self.get_html() ^^^^^^^^^^^^^^^ File "apps/frappe/frappe/website/utils.py", line 523, in cache_html_decorator html = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/website/page_renderers/template_page.py", line 101, in get_html html = self.render_template() ^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/website/page_renderers/template_page.py", line 236, in render_template html = frappe.render_template(self.source, self.context, safe_render=safe_render) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/utils/jinja.py", line 97, in render_template return get_jenv().from_string(template).render(context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "env/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render self.environment.handle_exception() File "env/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception raise rewrite_traceback_stack(source=source) File "", line 179, in top-level template code File "apps/frappe/frappe/templates/web.html", line 1, in top-level template code {% extends base_template_path %} ^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/templates/base.html", line 77, in top-level template code {% block content %} File "apps/frappe/frappe/templates/web.html", line 63, in block 'content' {{ main_content() }} File "env/lib/python3.11/site-packages/jinja2/sandbox.py", line 393, in call return __context.call(__obj, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "env/lib/python3.11/site-packages/jinja2/runtime.py", line 777, in _invoke rv = self._func(*arguments) ^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/templates/web.html", line 15, in template {% block page_container %} ^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/templates/web.html", line 30, in block 'page_container' {%- block page_content -%}{%- endblock -%} ^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 110, in block 'page_content' File "env/lib/python3.11/site-packages/jinja2/sandbox.py", line 393, in call return __context.call(__obj, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "env/lib/python3.11/site-packages/jinja2/runtime.py", line 777, in _invoke rv = self._func(*arguments) ^^^^^^^^^^^^^^^^^^^^^^ File "", line 176, in template File "env/lib/python3.11/site-packages/jinja2/sandbox.py", line 393, in call return __context.call(__obj, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/core/utils.py", line 91, in html2text return md(html, heading_style="ATX", strip=strip, wrap=wrap) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "env/lib/python3.11/site-packages/markdownify/__init__.py", line 395, in markdownify return MarkdownConverter(**options).convert(html) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "env/lib/python3.11/site-packages/markdownify/__init__.py", line 96, in convert soup = BeautifulSoup(html, 'html.parser') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "env/lib/python3.11/site-packages/bs4/__init__.py", line 315, in __init__ elif len(markup) <= 256 and ( ^^^^^^^^^^^ TypeError: object of type 'NoneType' has no len()