Repository: inventree/InvenTree

Issue:
[BUG] ValueError on Part page
<!---
Everything inside these brackets is hidden - please remove them where you fill out information.
--->


**Describe the bug**
Accessing the part page fails with Invalid isoformat string: '04.02.2022'
The date is the creation_date from the part which i am trying to open (DD.MM.YYYY).
Looks like its realted to #2685 

**Stacktrace**
<details>
<summary>Click to expand</summary>

```
Environment:

Request Method: GET
Request URL: https://inventree.example.com/part/178/

Django Version: 3.2.12
Python Version: 3.7.3
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'user_sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'maintenance_mode',
 'build.apps.BuildConfig',
 'common.apps.CommonConfig',
 'company.apps.CompanyConfig',
 'label.apps.LabelConfig',
 'order.apps.OrderConfig',
 'part.apps.PartConfig',
 'report.apps.ReportConfig',
 'stock.apps.StockConfig',
 'users.apps.UsersConfig',
 'plugin.apps.PluginAppConfig',
 'InvenTree.apps.InvenTreeConfig',
 'django_filters',
 'rest_framework',
 'rest_framework.authtoken',
 'corsheaders',
 'crispy_forms',
 'import_export',
 'django_cleanup.apps.CleanupConfig',
 'mptt',
 'markdownx',
 'markdownify',
 'django_admin_shell',
 'djmoney',
 'djmoney.contrib.exchange',
 'error_report',
 'django_q',
 'formtools',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'django_otp',
 'django_otp.plugins.otp_totp',
 'django_otp.plugins.otp_static',
 'allauth_2fa',
 'allauth.socialaccount.providers.gitlab']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'user_sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django_otp.middleware.OTPMiddleware',
 'InvenTree.middleware.CustomAllauthTwoFactorMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'InvenTree.middleware.AuthRequiredMiddleware',
 'InvenTree.middleware.Check2FAMiddleware',
 'maintenance_mode.middleware.MaintenanceModeMiddleware',
 'error_report.middleware.ExceptionProcessor']


Template error:
In template /opt/invenTree/git/InvenTree/templates/base.html, error at line 0
   Invalid isoformat string: '04.02.2022'
   1 : {% load static %}
   2 : {% load i18n %}
   3 : {% load inventree_extras %}
   4 : 
   5 : {% settings_value 'BARCODE_ENABLE' as barcodes %}
   6 : {% settings_value 'REPORT_ENABLE_TEST_REPORT' as test_report_enabled %}
   7 : {% settings_value "REPORT_ENABLE" as report_enabled %}
   8 : {% settings_value "SERVER_RESTART_REQUIRED" as server_restart_required %}
   9 : {% inventree_demo_mode as demo_mode %}
   10 : 


Traceback (most recent call last):
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/core/handlers/base.py", line 204, in _get_response
    response = response.render()
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/response.py", line 83, in rendered_content
    return template.render(context, self._request)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/defaulttags.py", line 315, in render
    return nodelist.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/defaulttags.py", line 214, in render
    nodelist.append(node.render_annotated(context))
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/invenTree/env/lib/python3.7/site-packages/django/template/library.py", line 192, in render
    output = self.func(*resolved_args, **resolved_kwargs)
  File "/opt/invenTree/git/InvenTree/part/templatetags/inventree_extras.py", line 61, in render_date
    date_object = date.fromisoformat(date_object)

Exception Type: ValueError at /part/178/
Exception Value: Invalid isoformat string: '04.02.2022' 
```
</details>


**Deployment Method**
- [ ] Docker
- [x] Bare Metal

**Version Information**
InvenTree-Version: 0.7.0 dev
Django Version: 3.2.12
Commit Hash: 278887e11
Commit Date: 2022-03-17
Database: mysql
Debug-Mode: True
Deployed using Docker: False



Discussion:
Confirmed
Did some testing and found that its only happening when price_history is enabled. Does this really belong to 0.6.3? I think the render_date function currently is only in master
@ldet not sure if the helper function will not be transfered over. The fix is quite simple so not really blocking.

Resolving patch:
diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py
--- a/InvenTree/part/views.py
+++ b/InvenTree/part/views.py
@@ -441,9 +441,9 @@ def get_pricing(self, quantity=1, currency=None):
 
                 # set date for graph labels
                 if stock_item.purchase_order and stock_item.purchase_order.issue_date:
-                    line['date'] = stock_item.purchase_order.issue_date.strftime('%d.%m.%Y')
+                    line['date'] = stock_item.purchase_order.issue_date.isoformat()
                 elif stock_item.tracking_info.count() > 0:
-                    line['date'] = stock_item.tracking_info.first().date.strftime('%d.%m.%Y')
+                    line['date'] = stock_item.tracking_info.first().date.date().isoformat()
                 else:
                     # Not enough information
                     continue
@@ -500,9 +500,9 @@ def get_pricing(self, quantity=1, currency=None):
 
                 # set date for graph labels
                 if sale_item.order.issue_date:
-                    line['date'] = sale_item.order.issue_date.strftime('%d.%m.%Y')
+                    line['date'] = sale_item.order.issue_date.isoformat()
                 elif sale_item.order.creation_date:
-                    line['date'] = sale_item.order.creation_date.strftime('%d.%m.%Y')
+                    line['date'] = sale_item.order.creation_date.isoformat()
                 else:
                     line['date'] = _('None')
 


Test patch: