internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: inventree/InvenTree

Issue:
[FR/P-UI] Translation integration
```[tasklist]
### Tasks
- [x] Add new translation files to Crowdin project
- [x] Update translation CI to build Platform UI files
```



Discussion:

Resolving patch:
diff --git a/tasks.py b/tasks.py
--- a/tasks.py
+++ b/tasks.py
@@ -259,7 +259,7 @@ def translate_stats(c):
 
 
 @task(post=[translate_stats])
-def translate(c, skip_static=False):
+def translate(c):
     """Rebuild translation source files. Advanced use only!
 
     Note: This command should not be used on a local install,
@@ -269,13 +269,12 @@ def translate(c, skip_static=False):
     manage(c, "makemessages --all -e py,html,js --no-wrap")
     manage(c, "compilemessages")
 
-    if not skip_static:
-        if node_available():
-            frontend_trans(c)
-            frontend_build(c)
+    if node_available():
+        frontend_trans(c)
+        frontend_build(c)
 
-        # Update static files
-        static(c)
+    # Update static files
+    static(c)
 
 
 @task


Test patch:
Repository: inventree/InvenTree

Issue:
[FR/P-UI] Fast Language / Theme selection
Follow up to #5207 
We need an easy way for users to select language, theme and instance without polluting the main menu/nav. Maybe this could be moved onto the main login page and user settings.


Discussion:

Resolving patch:
diff --git a/tasks.py b/tasks.py
--- a/tasks.py
+++ b/tasks.py
@@ -129,7 +129,7 @@ def check(cmd):
         print('Node is available but yarn is not. Install yarn if you wish to build the frontend.')
 
     # Return the result
-    return ret((not yarn_passes or not node_version), node_version, yarn_version)
+    return ret(yarn_passes and node_version, node_version, yarn_version)
 
 
 def check_file_existance(filename: str, overwrite: bool = False):


Test patch:
Repository: inventree/InvenTree

Issue:
Unable to Set Password for OAuth Registrations Due to "Old Password" Requirement
### Please verify that this bug has NOT been raised before.

- [X] I checked and didn't find a similar issue

### Describe the bug*

For accounts created via OAuth (e.g., Google), setting up a password through the Settings page in the web UI poses an issue. The process prompts for three fields: `Enter Password`, `Confirm Password`, and `Old Password`. Since no initial password exists for OAuth-based sign-ups, it becomes impossible to provide an "Old Password". Consequently, I'm unable to set a password for my account. This hinders access to my account through the app, especially in scenarios where I lack admin rights to change it via the admin dashboard.

### Steps to Reproduce

1. Register an account using OAuth.
2. Navigate to Settings -> Account -> Set Password.


### Expected behaviour

For accounts created through OAuth, the `Set Password` form should not require an `Old Password` field.

### Deployment Method

- [X] Docker
- [ ] Bare metal

### Version Information

# Version Information:
InvenTree-Version: 0.12.1
Django Version: 3.2.19
Commit Hash: 93b44ad
Commit Date: 2023-07-13

Database: postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-5.10.0-25-amd64-x86_64-with-glibc2.36
Installer: DOC

Active plugins: [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.0.0'}, {'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'}, {'name': 'EventHooks', 'slug': 'eventhooks', 'version': '0.0.1'}, {'name': 'QrUrlRedirect', 'slug': 'qrurlredirect', 'version': '0.0.1'}]


### Please verify if you can reproduce this bug on the demo site.

- [ ] I can reproduce this bug on the demo site.

### Relevant log output

_No response_


Discussion:
@Adoliin thanks for reporting. Would you be willing to look into this one yourself?

Resolving patch:
diff --git a/InvenTree/InvenTree/forms.py b/InvenTree/InvenTree/forms.py
--- a/InvenTree/InvenTree/forms.py
+++ b/InvenTree/InvenTree/forms.py
@@ -161,6 +161,7 @@ class Meta:
     old_password = forms.CharField(
         label=_("Old password"),
         strip=False,
+        required=False,
         widget=forms.PasswordInput(attrs={'autocomplete': 'current-password', 'autofocus': True}),
     )
 
diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py
--- a/InvenTree/InvenTree/views.py
+++ b/InvenTree/InvenTree/views.py
@@ -443,8 +443,7 @@ def post(self, request, *args, **kwargs):
 
         if valid:
             # Old password must be correct
-
-            if not user.check_password(old_password):
+            if user.has_usable_password() and not user.check_password(old_password):
                 form.add_error('old_password', _('Wrong password provided'))
                 valid = False
 


Test patch:
Repository: inventree/InvenTree

Issue:
Stocktake doesn't save parts with no stock
### Please verify that this bug has NOT been raised before.

- [X] I checked and didn't find a similar issue

### Describe the bug*

Stocktake is ignoring active parts with 0 stock. (see https://github.com/inventree/InvenTree/blob/master/InvenTree/part/stocktake.py#L252-L254)

### Steps to Reproduce

1. Add a Part
2. Give it some Stock
3. Run stocktake
4. Sell all the Stock
5. Run stocktake again
6. In the Parts stocktake you'll see no new ("0") entry 

### Expected behaviour

If I have an active part and I run stocktake, I expect the Part to be noted down with "0 Stock at DateTime".

### Deployment Method

- [X] Docker
- [ ] Bare metal

### Version Information

# Version Information:
InvenTree-Version: 0.13.0 dev
Django Version: 3.2.21
Commit Hash: 2b0d81f
Commit Date: 2023-09-25

Database: postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-5.15.0-82-generic-x86_64-with
Installer: DOC

Active plugins: False


### Please verify if you can reproduce this bug on the demo site.

- [X] I can reproduce this bug on the demo site.

### Relevant log output

_No response_


Discussion:
If there's no complains on this, I could give it a try. Maybe we can allow users in the settings to toggle this on/off to not break with the current behaviour!?
@lippoliv this is a fair point - the stocktake should definitely save "zero stock" results. Happy for you to take a crack at this, I do not think it necessarily needs to be behind a setting - the current behaviour is IMO erroneous
PR incoming

Resolving patch:
diff --git a/InvenTree/part/stocktake.py b/InvenTree/part/stocktake.py
--- a/InvenTree/part/stocktake.py
+++ b/InvenTree/part/stocktake.py
@@ -249,10 +249,6 @@ def generate_stocktake_report(**kwargs):
             location=location,
         )
 
-        if stocktake.quantity == 0:
-            # Skip rows with zero total quantity
-            continue
-
         total_parts += 1
 
         stocktake_instances.append(stocktake)


Test patch:
diff --git a/InvenTree/part/test_api.py b/InvenTree/part/test_api.py
--- a/InvenTree/part/test_api.py
+++ b/InvenTree/part/test_api.py
@@ -3015,7 +3015,7 @@ def test_report_list(self):
 
         data = response.data[0]
 
-        self.assertEqual(data['part_count'], 8)
+        self.assertEqual(data['part_count'], 14)
         self.assertEqual(data['user'], None)
         self.assertTrue(data['report'].endswith('.csv'))
Repository: inventree/InvenTree

Issue:
[PUI] Render "status" labels
Status values (i.e. StockItem.ATTENTION_NEEDED) are served via the API - can be cached by the client.

- Fetch from the server
- Use translated text in a "badge"


Discussion:

Resolving patch:
diff --git a/InvenTree/InvenTree/api_version.py b/InvenTree/InvenTree/api_version.py
--- a/InvenTree/InvenTree/api_version.py
+++ b/InvenTree/InvenTree/api_version.py
@@ -2,11 +2,14 @@
 
 
 # InvenTree API version
-INVENTREE_API_VERSION = 141
+INVENTREE_API_VERSION = 142
 
 """
 Increment this API version number whenever there is a significant change to the API that any clients need to know about
 
+v142 -> 2023-10-20: https://github.com/inventree/InvenTree/pull/5759
+    - Adds generic API endpoints for looking up status models
+
 v141 -> 2023-10-23 : https://github.com/inventree/InvenTree/pull/5774
     - Changed 'part.responsible' from User to Owner
 
diff --git a/InvenTree/common/api.py b/InvenTree/common/api.py
--- a/InvenTree/common/api.py
+++ b/InvenTree/common/api.py
@@ -18,6 +18,7 @@
 
 import common.models
 import common.serializers
+from generic.states.api import AllStatusViews, StatusView
 from InvenTree.api import BulkDeleteMixin, MetadataView
 from InvenTree.config import CONFIG_LOOKUPS
 from InvenTree.filters import ORDER_FILTER, SEARCH_ORDER_FILTER
@@ -617,6 +618,14 @@ def get_object(self):
         path('<str:key>/', FlagDetail.as_view(), name='api-flag-detail'),
         re_path(r'^.*$', FlagList.as_view(), name='api-flag-list'),
     ])),
+
+    # Status
+    path('generic/status/', include([
+        path(f'<str:{StatusView.MODEL_REF}>/', include([
+            path('', StatusView.as_view(), name='api-status'),
+        ])),
+        path('', AllStatusViews.as_view(), name='api-status-all'),
+    ])),
 ]
 
 admin_api_urls = [
diff --git a/InvenTree/generic/states/api.py b/InvenTree/generic/states/api.py
--- a/InvenTree/generic/states/api.py
+++ b/InvenTree/generic/states/api.py
@@ -26,7 +26,7 @@ class StatusView(APIView):
     MODEL_REF = 'statusmodel'
 
     def get_status_model(self, *args, **kwargs):
-        """Return the StatusCode moedl based on extra parameters passed to the view"""
+        """Return the StatusCode model based on extra parameters passed to the view"""
         status_model = self.kwargs.get(self.MODEL_REF, None)
 
         if status_model is None:
@@ -50,3 +50,23 @@ def get(self, request, *args, **kwargs):
         }
 
         return Response(data)
+
+
+class AllStatusViews(StatusView):
+    """Endpoint for listing all defined status models."""
+
+    permission_classes = [
+        permissions.IsAuthenticated,
+    ]
+
+    def get(self, request, *args, **kwargs):
+        """Perform a GET request to learn information about status codes"""
+        data = {}
+
+        for status_class in StatusCode.__subclasses__():
+            data[status_class.__name__] = {
+                'class': status_class.__name__,
+                'values': status_class.dict(),
+            }
+
+        return Response(data)


Test patch:
Repository: inventree/InvenTree

Issue:
Cancel purchase order - Error object
### Please verify that this bug has NOT been raised before.

- [X] I checked and didn't find a similar issue

### Describe the bug*

When trying to cancel a purchase order, I get an error and the order does not get cancelled.

### Steps to Reproduce

1. Create purchase order with a supplier
2. Add order items (optional)
3. Issue order (optional)
4. Cancel order

### Expected behaviour

Order gets cancelled.

### Deployment Method

- [X] Docker
- [ ] Bare metal

### Version Information

# Version Information:
InvenTree-Version: 0.13.0
Django Version: 3.2.23
Commit Hash: 301afaa
Commit Date: 2023-12-15

Database: postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-5.15.0-91-generic-x86_64-with
Installer: DOC

Active plugins: [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.0.0'}, {'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'}, {'name': 'InvenTreeCurrencyExchange', 'slug': 'inventreecurrencyexchange', 'version': '1.0.0'}, {'name': 'InvenTreeLabel', 'slug': 'inventreelabel', 'version': '1.0.0'}, {'name': 'InvenTreeLabelSheet', 'slug': 'inventreelabelsheet', 'version': '1.0.0'}, {'name': 'DigiKeyPlugin', 'slug': 'digikeyplugin', 'version': '1.0.0'}, {'name': 'LCSCPlugin', 'slug': 'lcscplugin', 'version': '1.0.0'}, {'name': 'MouserPlugin', 'slug': 'mouserplugin', 'version': '1.0.0'}, {'name': 'TMEPlugin', 'slug': 'tmeplugin', 'version': '1.0.0'}]


### Please verify if you can reproduce this bug on the demo site.

- [X] I can reproduce this bug on the demo site.

### Relevant log output

```shell
192.168.2.3 - - [26/Dec/2023:13:44:47 +0000] "GET /api/order/po-line/?search=&offset=0&limit=25&order=1&part_detail=true HTTP/1.0" 200 2162 "https://inventree-server/order/purchase-order/1/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0"
'bool' object is not callable
/root/.local/lib/python3.10/site-packages/django/db/models/fields/__init__.py:1358: RuntimeWarning: DateTimeField NotificationEntry.updated received a naive datetime (2023-12-25 00:00:00) while time zone support is active.
  warnings.warn("DateTimeField %s.%s received a naive datetime "
Internal Server Error: /api/order/po/1/cancel/
```



Discussion:
Ca reporduce on stable. Thank you for the report @pdsccode !

Resolving patch:
diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py
--- a/InvenTree/order/serializers.py
+++ b/InvenTree/order/serializers.py
@@ -247,7 +247,7 @@ def get_context_data(self):
         self.order = self.context['order']
 
         return {
-            'can_cancel': self.order.can_cancel(),
+            'can_cancel': self.order.can_cancel,
         }
 
     def save(self):
@@ -1219,7 +1219,7 @@ def get_context_data(self):
         order = self.context['order']
 
         return {
-            'can_cancel': order.can_cancel(),
+            'can_cancel': order.can_cancel,
         }
 
     def save(self):


Test patch:
Repository: inventree/InvenTree

Issue:
[PUI] Global login
Global Login (CUI logs in PUI and vice versa) is not working (anymore)


Discussion:

Resolving patch:
diff --git a/InvenTree/users/api.py b/InvenTree/users/api.py
--- a/InvenTree/users/api.py
+++ b/InvenTree/users/api.py
@@ -3,6 +3,7 @@
 import datetime
 import logging
 
+from django.contrib.auth import get_user, login
 from django.contrib.auth.models import Group, User
 from django.urls import include, path, re_path
 
@@ -242,6 +243,10 @@ def get(self, request, *args, **kwargs):
                 "Created new API token for user '%s' (name='%s')", user.username, name
             )
 
+            # Ensure that the users session is logged in (PUI -> CUI login)
+            if not get_user(request).is_authenticated:
+                login(request, user)
+
             return Response(data)
 
         else:


Test patch:
Repository: inventree/InvenTree

Issue:
Plugin with git, but no commits causes all plugins to fail to load
### Please verify that this bug has NOT been raised before.

- [X] I checked and didn't find a similar issue

### Describe the bug*

Creating a plugin in `InvenTree/plugins/your_plugin/` with the proper files required, and then initiating a git repo in this directory will cause all plugins to fail on the next reload of the server

### Steps to Reproduce

1. `mkdir InvenTree/plugins/someplugin && touch InvenTree/plugins/someplugin/__init__.py && cd InvenTree/plugins/someplugin && git init`
2. 2. Start up the InvenTree instance
3. All plugins will be listed with "?" icons, and even installed plugins will be unavailable

### Expected behaviour

Ignore that no commits have been issues

### Deployment Method

- [X] Docker
- [X] Bare metal

### Version Information

# Version Information:
InvenTree-Version: 0.14.0 dev
Django Version: 3.2.23
Commit Hash: 5d018e8
Commit Date: 2024-01-15
Commit Branch: details-panel
Database: sqlite3
Debug-Mode: True
Deployed using Docker: True
Platform: Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with
Installer: DOC

Active plugins: []


### Please verify if you can reproduce this bug on the demo site.

- [ ] I can reproduce this bug on the demo site.

### Relevant log output

```shell
a
```



Discussion:

Resolving patch:
diff --git a/InvenTree/plugin/helpers.py b/InvenTree/plugin/helpers.py
--- a/InvenTree/plugin/helpers.py
+++ b/InvenTree/plugin/helpers.py
@@ -145,6 +145,8 @@ def get_git_log(path):
                 datetime.datetime.fromtimestamp(commit.author_time).isoformat(),
                 commit.message.decode().split('\n')[0],
             ]
+        except KeyError as err:
+            logger.debug('No HEAD tag found in git repo at path %s', path)
         except NotGitRepository:
             pass
 


Test patch:
Repository: inventree/InvenTree

Issue:
[PUI] Registration
Support user registration via PUI if enabled


Discussion:

Resolving patch:
diff --git a/InvenTree/InvenTree/api_version.py b/InvenTree/InvenTree/api_version.py
--- a/InvenTree/InvenTree/api_version.py
+++ b/InvenTree/InvenTree/api_version.py
@@ -1,11 +1,14 @@
 """InvenTree API version information."""
 
 # InvenTree API version
-INVENTREE_API_VERSION = 162
+INVENTREE_API_VERSION = 163
 """Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
 
 INVENTREE_API_TEXT = """
 
+v163 -> 2024-01-22 : https://github.com/inventree/InvenTree/pull/6314
+    - Extends API endpoint to expose auth configuration information for signin pages
+
 v162 -> 2024-01-14 : https://github.com/inventree/InvenTree/pull/6230
     - Adds API endpoints to provide information on background tasks
 
diff --git a/InvenTree/InvenTree/social_auth_urls.py b/InvenTree/InvenTree/social_auth_urls.py
--- a/InvenTree/InvenTree/social_auth_urls.py
+++ b/InvenTree/InvenTree/social_auth_urls.py
@@ -153,6 +153,10 @@ def get(self, request, *args, **kwargs):
             'sso_registration': InvenTree.sso.registration_enabled(),
             'mfa_required': InvenTreeSetting.get_setting('LOGIN_ENFORCE_MFA'),
             'providers': provider_list,
+            'registration_enabled': InvenTreeSetting.get_setting('LOGIN_ENABLE_REG'),
+            'password_forgotten_enabled': InvenTreeSetting.get_setting(
+                'LOGIN_ENABLE_PWD_FORGOT'
+            ),
         }
         return Response(data)
 


Test patch:
Repository: inventree/InvenTree

Issue:
[Testing] Event triggers disabled during tests
### Please verify that this bug has NOT been raised before.

- [X] I checked and didn't find a similar issue

### Describe the bug*

Writing tests for the IPN plugin, I didn't get it to run on create and save events.
Doing some digging, I found the culprit. When running tests, all table events are disabled by default.

### Steps to Reproduce

https://github.com/inventree/InvenTree/blob/7905c556cf2ca7afb0b7e4c80033d4993338ae22/InvenTree/plugin/base/event/events.py#L119-L122

### Expected behaviour

Perhaps we should allow events if you explicitly set `settings.PLUGIN_TESTING_EVENTS = True`?

### Deployment Method

- [ ] Docker
- [ ] Bare metal

### Version Information

0.15.0-dev

### Please verify if you can reproduce this bug on the demo site.

- [ ] I can reproduce this bug on the demo site.

### Relevant log output

_No response_


Discussion:
@LavissaWoW I'm happy with the suggested solution of adding a configurable setting. However it is not solely related to plugins so maybe `TEST_TABLE_EVENTS`?

Resolving patch:
diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py
--- a/InvenTree/InvenTree/settings.py
+++ b/InvenTree/InvenTree/settings.py
@@ -1202,6 +1202,9 @@
 )  # How often should plugin loading be tried?
 PLUGIN_FILE_CHECKED = False  # Was the plugin file checked?
 
+# Flag to allow table events during testing
+TESTING_TABLE_EVENTS = False
+
 # User interface customization values
 CUSTOM_LOGO = get_custom_file(
     'INVENTREE_CUSTOM_LOGO', 'customize.logo', 'custom logo', lookup_media=True
diff --git a/InvenTree/plugin/base/event/events.py b/InvenTree/plugin/base/event/events.py
--- a/InvenTree/plugin/base/event/events.py
+++ b/InvenTree/plugin/base/event/events.py
@@ -117,7 +117,7 @@ def allow_table_event(table_name):
         return False  # pragma: no cover
 
     # Prevent table events when in testing mode (saves a lot of time)
-    if settings.TESTING:
+    if settings.TESTING and not settings.TESTING_TABLE_EVENTS:
         return False
 
     table_name = table_name.lower().strip()


Test patch:
Repository: inventree/InvenTree

Issue:
[FR] Increase Length of URL limit on import
### Please verify that this feature request has NOT been suggested before.

- [X] I checked and didn't find a similar feature request

### Problem statement

See [Discussion 7078](https://github.com/inventree/InvenTree/discussions/7078)


### Suggested solution

Possible options:
- Increase length of URL limit to something greater than 200 (Maybe 300?).
- Make the maximum length adjustable in the Admin settings somewhere.
- Remove the limit and replace it with content validation that validates and then accepts the link regardless of length if it is valid.


### Describe alternatives you've considered

Not much I can do here... If the supplier's or manufacturer's website requires a link longer than 200 characters to link to the part on their site, then the limit isn't high enough.  The only other option would be to run our own URL shortening service and manually shorten any link that's too long on a one-off basis.

### Examples of other systems

_No response_

### Do you want to develop this?

- [ ] I want to develop this.


Discussion:
I think extending this is not too problematic. I think 2000 chars should be enough for now, I will submit a patch later tonight.

Resolving patch:
diff --git a/src/backend/InvenTree/company/models.py b/src/backend/InvenTree/company/models.py
--- a/src/backend/InvenTree/company/models.py
+++ b/src/backend/InvenTree/company/models.py
@@ -513,6 +513,7 @@ def get_api_url():
         null=True,
         verbose_name=_('Link'),
         help_text=_('URL for external manufacturer part link'),
+        max_length=2000,
     )
 
     description = models.CharField(
@@ -829,6 +830,7 @@ def save(self, *args, **kwargs):
         null=True,
         verbose_name=_('Link'),
         help_text=_('URL for external supplier part link'),
+        max_length=2000,
     )
 
     description = models.CharField(


Test patch:
Repository: WeblateOrg/weblate

Issue:
Can't update unit from XLIFF file
I have just installed and configured weblate locally, pulling XLIFFs from a remote git repository.
Whenever I try to update a string on the frontend interface I get an error: "Message not found in backend storage, it is probably corrupted."

I dig a bit into the code and found the unit [context check](/nijel/weblate/blob/master/weblate/trans/formats.py#L462) was failing due to translate-toolkit XLIFF shenanigans (as comments indicated in the same file). Posting a pull request soon, but i literally just learned python by example, will need a review.

Here's my setup just in case
- Weblate 2.2
- Python 2.7.6
- Django 1.6.1
- python-social-auth 0.2.1
- Translate Toolkit 1.12.0
- Whoosh 2.5.7
- Git 1.9.1
- South 1.0.2
- Pillow (PIL) 1.1.7
- dateutil 1.5
- lxml 3.3.3
- django-crispy-forms 1.4.0
- pyLibravatar N/A
- Mercurial 2.8.2



Discussion:

Resolving patch:
diff --git a/weblate/trans/formats.py b/weblate/trans/formats.py
--- a/weblate/trans/formats.py
+++ b/weblate/trans/formats.py
@@ -458,8 +458,18 @@ def _find_unit_bilingual(self, context, source):
         # Find is broken for propfile, ignore results
         if len(found_units) > 0 and not isinstance(self.store, propfile):
             for ttkit_unit in found_units:
+                # XLIFF is special in ttkit - it uses locations for what
+                # is context in other formats
+                if isinstance(ttkit_unit, xliffunit):
+                    ttkit_unit_context = ttkit_unit.getlocations()
+                    if len(ttkit_unit.getlocations()) == 0:
+                        ttkit_unit_context =  ''
+                    else:
+                        ttkit_unit_context = ttkit_unit.getlocations()[0]
+                else:
+                    ttkit_unit_context = ttkit_unit.getcontext()
                 # Does context match?
-                if ttkit_unit.getcontext() == context:
+                if ttkit_unit_context == context:
                     return (FileUnit(ttkit_unit), False)
         else:
             # Fallback to manual find for value based files


Test patch: