code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def update(self, instance, validated_data): """Update an existing selection list. Save the choices separately.""" inst_mapping = {inst.id: inst for inst in instance.entries.all()} existing_ids = {a.get('id') for a in self._choices_validated} # Perform creations and updates. ret ...
Update an existing selection list. Save the choices separately.
update
python
inventree/InvenTree
src/backend/InvenTree/common/serializers.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/serializers.py
MIT
def global_setting_overrides() -> dict: """Return a dictionary of global settings overrides. These values are set via environment variables or configuration file. """ from django.conf import settings if hasattr(settings, 'GLOBAL_SETTINGS_OVERRIDES'): return settings.GLOBAL_SETTINGS_OVERRID...
Return a dictionary of global settings overrides. These values are set via environment variables or configuration file.
global_setting_overrides
python
inventree/InvenTree
src/backend/InvenTree/common/settings.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/settings.py
MIT
def get_global_setting(key, backup_value=None, enviroment_key=None, **kwargs): """Return the value of a global setting using the provided key.""" from common.models import InvenTreeSetting if enviroment_key: value = environ.get(enviroment_key) if value: return value if back...
Return the value of a global setting using the provided key.
get_global_setting
python
inventree/InvenTree
src/backend/InvenTree/common/settings.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/settings.py
MIT
def set_global_setting(key, value, change_user=None, create=True, **kwargs): """Set the value of a global setting using the provided key.""" from common.models import InvenTreeSetting kwargs['change_user'] = change_user kwargs['create'] = create return InvenTreeSetting.set_setting(key, value, **kw...
Set the value of a global setting using the provided key.
set_global_setting
python
inventree/InvenTree
src/backend/InvenTree/common/settings.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/settings.py
MIT
def stock_expiry_enabled(): """Returns True if the stock expiry feature is enabled.""" from common.models import InvenTreeSetting return InvenTreeSetting.get_setting('STOCK_ENABLE_EXPIRY', False, create=False)
Returns True if the stock expiry feature is enabled.
stock_expiry_enabled
python
inventree/InvenTree
src/backend/InvenTree/common/settings.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/settings.py
MIT
def prevent_build_output_complete_on_incompleted_tests(): """Returns True if the completion of the build outputs is disabled until the required tests are passed.""" from common.models import InvenTreeSetting return InvenTreeSetting.get_setting( 'PREVENT_BUILD_COMPLETION_HAVING_INCOMPLETED_TESTS', F...
Returns True if the completion of the build outputs is disabled until the required tests are passed.
prevent_build_output_complete_on_incompleted_tests
python
inventree/InvenTree
src/backend/InvenTree/common/settings.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/settings.py
MIT
def cleanup_old_data_outputs(): """Remove old data outputs from the database.""" # Remove any outputs which are older than 5 days # Note: Remove them individually, to ensure that the files are removed too threshold = InvenTree.helpers.current_date() - timedelta(days=5) for output in common.models.D...
Remove old data outputs from the database.
cleanup_old_data_outputs
python
inventree/InvenTree
src/backend/InvenTree/common/tasks.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tasks.py
MIT
def delete_old_notifications(): """Remove old notifications from the database. Anything older than ~3 months is removed """ try: from common.models import NotificationEntry except AppRegistryNotReady: # pragma: no cover logger.info( "Could not perform 'delete_old_notifi...
Remove old notifications from the database. Anything older than ~3 months is removed
delete_old_notifications
python
inventree/InvenTree
src/backend/InvenTree/common/tasks.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tasks.py
MIT
def delete_old_notes_images(): """Remove old notes images from the database. Anything older than ~3 months is removed, unless it is linked to a note """ try: from common.models import NotesImage except AppRegistryNotReady: logger.info( "Could not perform 'delete_old_note...
Remove old notes images from the database. Anything older than ~3 months is removed, unless it is linked to a note
delete_old_notes_images
python
inventree/InvenTree
src/backend/InvenTree/common/tasks.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tasks.py
MIT
def test_filename_validation(self): """Test that the filename validation works as expected. The django file-upload mechanism should sanitize filenames correctly. """ part = Part.objects.first() filenames = { 'test.txt': 'test.txt', 'r####at.mp4': 'rat.mp...
Test that the filename validation works as expected. The django file-upload mechanism should sanitize filenames correctly.
test_filename_validation
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_mixin(self): """Test that the mixin class works as expected.""" part = Part.objects.first() self.assertEqual(part.attachments.count(), 0) part.create_attachment( attachment=self.generate_file('test.txt'), comment='Hello world' ) self.assertEqual(pa...
Test that the mixin class works as expected.
test_mixin
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_upload_via_api(self): """Test that we can upload attachments via the API.""" part = Part.objects.first() url = reverse('api-attachment-list') data = { 'model_type': 'part', 'model_id': part.pk, 'link': 'https://www.google.com', 'c...
Test that we can upload attachments via the API.
test_upload_via_api
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_settings_objects(self): """Test fixture loading and lookup for settings.""" # There should be two settings objects in the database settings = InvenTreeSetting.objects.all() self.assertGreaterEqual(settings.count(), 2) instance_name = InvenTreeSetting.objects.get(pk=1) ...
Test fixture loading and lookup for settings.
test_settings_objects
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_allValues(self): """Make sure that the allValues functions returns correctly.""" # define testing settings # check a few keys result = InvenTreeSetting.allValues() self.assertIn('INVENTREE_INSTANCE', result) self.assertIn('PART_COPY_TESTS', result) self....
Make sure that the allValues functions returns correctly.
test_allValues
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_all_settings(self): """Make sure that the all_settings function returns correctly.""" result = InvenTreeSetting.all_settings() self.assertIn('INVENTREE_INSTANCE', result) self.assertIsInstance(result['INVENTREE_INSTANCE'], InvenTreeSetting)
Make sure that the all_settings function returns correctly.
test_all_settings
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_check_all_settings(self, get_setting_definition): """Make sure that the check_all_settings function returns correctly.""" # define partial schema settings_definition = { 'AB': { # key that's has not already been accessed 'required': True }, ...
Make sure that the check_all_settings function returns correctly.
test_check_all_settings
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_settings_validator(self, get_setting_definition): """Make sure that the validator function gets called on set setting.""" def validator(x): if x == 'hello': return x raise ValidationError(f'{x} is not valid') mock_validator = mock.Mock(side_eff...
Make sure that the validator function gets called on set setting.
test_settings_validator
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def run_settings_check(self, key, setting): """Test that all settings are valid. - Ensure that a name is set and that it is translated - Ensure that a description is set - Ensure that every setting key is valid - Ensure that a validator is supplied """ self.asser...
Test that all settings are valid. - Ensure that a name is set and that it is translated - Ensure that a description is set - Ensure that every setting key is valid - Ensure that a validator is supplied
run_settings_check
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_setting_data(self): """Test for settings data. - Ensure that every setting has a name, which is translated - Ensure that every setting has a description, which is translated """ for key, setting in InvenTreeSetting.SETTINGS.items(): try: self...
Test for settings data. - Ensure that every setting has a name, which is translated - Ensure that every setting has a description, which is translated
test_setting_data
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_defaults(self): """Populate the settings with default values.""" for key in InvenTreeSetting.SETTINGS: value = InvenTreeSetting.get_setting_default(key) try: InvenTreeSetting.set_setting(key, value, change_user=self.user) except Exception as ...
Populate the settings with default values.
test_defaults
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_global_setting_caching(self): """Test caching operations for the global settings class.""" key = 'PART_NAME_FORMAT' cache_key = InvenTreeSetting.create_cache_key(key) self.assertEqual(cache_key, 'InvenTreeSetting:PART_NAME_FORMAT') cache.clear() self.assertIsN...
Test caching operations for the global settings class.
test_global_setting_caching
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_user_setting_caching(self): """Test caching operation for the user settings class.""" cache.clear() # Generate a number of new users for idx in range(5): get_user_model().objects.create( username=f'User_{idx}', password='hunter42', email='email@dot.c...
Test caching operation for the user settings class.
test_user_setting_caching
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_global_settings_api_list(self): """Test list URL for global settings.""" url = reverse('api-global-setting-list') # Read out each of the global settings value, to ensure they are instantiated in the database for key in InvenTreeSetting.SETTINGS: InvenTreeSetting.get...
Test list URL for global settings.
test_global_settings_api_list
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_currency_settings(self): """Run tests for currency specific settings.""" url = reverse('api-global-setting-detail', kwargs={'key': 'CURRENCY_CODES'}) response = self.patch(url, data={'value': 'USD,XYZ'}, expected_code=400) self.assertIn("Invalid currency code: 'XYZ'", str(resp...
Run tests for currency specific settings.
test_currency_settings
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_api_detail(self): """Test that we can access the detail view for a setting based on the <key>.""" # These keys are invalid, and should return 404 for key in ['apple', 'carrot', 'dog']: response = self.get( reverse('api-global-setting-detail', kwargs={'key': k...
Test that we can access the detail view for a setting based on the <key>.
test_api_detail
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_user_setting_init(self): """Test we can retrieve a setting which has not yet been initialized.""" key = 'LABEL_INLINE' # Ensure it does not actually exist in the database self.assertFalse(InvenTreeUserSetting.objects.filter(key=key).exists()) url = reverse('api-user-se...
Test we can retrieve a setting which has not yet been initialized.
test_user_setting_init
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_setting(self): """Test the string name for NotificationUserSetting.""" NotificationUserSetting.set_setting( 'NOTIFICATION_METHOD_MAIL', True, change_user=self.user, user=self.user ) test_setting = NotificationUserSetting.get_setting_object( 'NOTIFICATION_...
Test the string name for NotificationUserSetting.
test_setting
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_valid_plugin_slug(self): """Test that an valid plugin slug runs through.""" # Activate plugin registry.set_plugin_state('sample', True) # get data url = reverse( 'api-plugin-setting-detail', kwargs={'plugin': 'sample', 'key': 'API_KEY'} ) res...
Test that an valid plugin slug runs through.
test_valid_plugin_slug
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_pending_tasks(self): """Test that the pending tasks endpoint is available.""" # Schedule some tasks from django_q.models import OrmQ from InvenTree.tasks import offload_task n = OrmQ.objects.count() for i in range(3): offload_task(f'fake_module.tes...
Test that the pending tasks endpoint is available.
test_pending_tasks
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_scheduled_tasks(self): """Test that the scheduled tasks endpoint is available.""" from django_q.models import Schedule for i in range(5): Schedule.objects.create( name='time.sleep', func='time.sleep', args=f'{i + 1}' ) n = Schedule.objec...
Test that the scheduled tasks endpoint is available.
test_scheduled_tasks
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_bad_method(self): """Test that a wrong HTTP method does not work.""" response = self.client.get(self.url) assert response.status_code == HTTPStatus.METHOD_NOT_ALLOWED
Test that a wrong HTTP method does not work.
test_bad_method
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_bad_token(self): """Test that a wrong token is not working.""" response = self.client.post( self.url, content_type=CONTENT_TYPE_JSON, HTTP_TOKEN='1234567fghj' ) assert response.status_code == HTTPStatus.FORBIDDEN assert ( json.loads(response.cont...
Test that a wrong token is not working.
test_bad_token
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_bad_url(self): """Test that a wrongly formed url is not working.""" response = self.client.post( '/api/webhook/1234/', content_type=CONTENT_TYPE_JSON ) assert response.status_code == HTTPStatus.NOT_FOUND
Test that a wrongly formed url is not working.
test_bad_url
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_bad_json(self): """Test that malformed JSON is not accepted.""" response = self.client.post( self.url, data="{'this': 123}", content_type=CONTENT_TYPE_JSON, HTTP_TOKEN=str(self.endpoint_def.token), ) assert response.status_code ==...
Test that malformed JSON is not accepted.
test_bad_json
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_success_no_token_check(self): """Test that a endpoint without a token set does not require one.""" # delete token self.endpoint_def.token = '' self.endpoint_def.save() # check response = self.client.post(self.url, content_type=CONTENT_TYPE_JSON) assert ...
Test that a endpoint without a token set does not require one.
test_success_no_token_check
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_bad_hmac(self): """Test that a malformed HMAC does not pass.""" # delete token self.endpoint_def.token = '' self.endpoint_def.secret = '123abc' self.endpoint_def.save() # check response = self.client.post(self.url, content_type=CONTENT_TYPE_JSON) ...
Test that a malformed HMAC does not pass.
test_bad_hmac
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_success(self): """Test full e2e webhook call. The message should go through and save the json payload. """ response = self.client.post( self.url, data={'this': 'is a message'}, content_type=CONTENT_TYPE_JSON, HTTP_TOKEN=str(self.e...
Test full e2e webhook call. The message should go through and save the json payload.
test_success
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_check_notification_entries(self): """Test that notification entries can be created.""" # Create some notification entries self.assertEqual(NotificationEntry.objects.count(), 0) NotificationEntry.notify('test.notification', 1) self.assertEqual(NotificationEntry.objects...
Test that notification entries can be created.
test_check_notification_entries
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_bulk_delete(self): """Tests for bulk deletion of user notifications.""" from error_report.models import Error # Ensure *this* user has permission to view error reports addUserPermission(self.user, 'error_report', 'error', 'view') # Create some notification messages by ...
Tests for bulk deletion of user notifications.
test_bulk_delete
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_restart_flag(self): """Test that the restart flag is reset on start.""" from plugin import registry # set flag true set_global_setting('SERVER_RESTART_REQUIRED', True, None) # reload the app registry.reload_plugins() # now it should be false again ...
Test that the restart flag is reset on start.
test_restart_flag
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_exchange_endpoint(self): """Test that the currency exchange endpoint works as expected.""" response = self.get(reverse('api-currency-exchange'), expected_code=200) self.assertIn('base_currency', response.data) self.assertIn('exchange_rates', response.data)
Test that the currency exchange endpoint works as expected.
test_exchange_endpoint
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_invalid_files(self): """Test that invalid files are rejected.""" n = NotesImage.objects.count() # Test upload of a simple text file response = self.post( reverse('api-notes-image-list'), data={ 'image': SimpleUploadedFile( ...
Test that invalid files are rejected.
test_invalid_files
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_valid_image(self): """Test upload of a valid image file.""" n = NotesImage.objects.count() # Construct a simple image file image = PIL.Image.new('RGB', (100, 100), color='red') with io.BytesIO() as output: image.save(output, format='PNG') conten...
Test upload of a valid image file.
test_valid_image
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_delete(self): """Test we can delete a project code via the API.""" n = ProjectCode.objects.count() # Get the first project code code = ProjectCode.objects.first() # Delete it self.delete( reverse('api-project-code-detail', kwargs={'pk': code.pk}), ...
Test we can delete a project code via the API.
test_delete
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_duplicate_code(self): """Test that we cannot create two project codes with the same code.""" # Create a new project code response = self.post( self.url, data={'code': 'PRJ-001', 'description': 'Test project code'}, expected_code=400, ) ...
Test that we cannot create two project codes with the same code.
test_duplicate_code
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_write_access(self): """Test that non-staff users have read-only access.""" # By default user has staff access, can create a new project code response = self.post( self.url, data={'code': 'PRJ-xxx', 'description': 'Test project code'}, expected_code=20...
Test that non-staff users have read-only access.
test_write_access
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def setUpTestData(cls): """Construct some initial test fixture data.""" super().setUpTestData() units = [ CustomUnit( name='metres_per_amp', definition='meter / ampere', symbol='m/A' ), CustomUnit( name='hectares_per_second', ...
Construct some initial test fixture data.
setUpTestData
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_edit(self): """Test edit permissions for CustomUnit model.""" unit = CustomUnit.objects.first() # Try to edit without permission self.user.is_staff = False self.user.save() self.patch( reverse('api-custom-unit-detail', kwargs={'pk': unit.pk}), ...
Test edit permissions for CustomUnit model.
test_edit
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_validation(self): """Test that validation works as expected.""" unit = CustomUnit.objects.first() self.user.is_staff = True self.user.save() # Test invalid 'name' values (must be valid identifier) invalid_name_values = ['1', '1abc', 'abc def', 'abc-def', 'abc.d...
Test that validation works as expected.
test_validation
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_validation_logicalkey(self): """Tests Logical key must be present.""" data = self.data data.pop('logical_key') with self.assertRaises(ValidationError): InvenTreeCustomUserStateModel.objects.create(**data) self.assertEqual(InvenTreeCustomUserStateModel.objects...
Tests Logical key must be present.
test_validation_logicalkey
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_validation_reference(self): """Tests Reference status must be present.""" data = self.data data.pop('reference_status') with self.assertRaises(ValidationError): InvenTreeCustomUserStateModel.objects.create(**data) self.assertEqual(InvenTreeCustomUserStateMode...
Tests Reference status must be present.
test_validation_reference
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_validation_logical_unique(self): """Tests Logical key must be unique.""" data = self.data data['logical_key'] = data['key'] with self.assertRaises(ValidationError): InvenTreeCustomUserStateModel.objects.create(**data) self.assertEqual(InvenTreeCustomUserState...
Tests Logical key must be unique.
test_validation_logical_unique
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_validation_reference_exsists(self): """Tests Reference status set not found.""" data = self.data data['reference_status'] = 'abcd' with self.assertRaises(ValidationError): InvenTreeCustomUserStateModel.objects.create(**data) self.assertEqual(InvenTreeCustomUs...
Tests Reference status set not found.
test_validation_reference_exsists
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_validation_key_unique(self): """Tests Key must be different from the logical keys of the reference.""" data = self.data data['key'] = 50 with self.assertRaises(ValidationError): InvenTreeCustomUserStateModel.objects.create(**data) self.assertEqual(InvenTreeCu...
Tests Key must be different from the logical keys of the reference.
test_validation_key_unique
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_validation_logical_key_exsists(self): """Tests Logical key must be in the logical keys of the reference status.""" data = self.data data['logical_key'] = 12 with self.assertRaises(ValidationError): InvenTreeCustomUserStateModel.objects.create(**data) self.ass...
Tests Logical key must be in the logical keys of the reference status.
test_validation_logical_key_exsists
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_api(self): """Test the SelectionList and SelctionListEntry API endpoints.""" url = reverse('api-selectionlist-list') response = self.get(url, expected_code=200) self.assertEqual(len(response.data), 2) response = self.get(self.list_url, expected_code=200) self.as...
Test the SelectionList and SelctionListEntry API endpoints.
test_api
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_api_update(self): """Test adding and editing via the SelectionList.""" # Test adding a new list via the API response = self.post( reverse('api-selectionlist-list'), { 'name': 'New List', 'active': True, 'choices': [...
Test adding and editing via the SelectionList.
test_api_update
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def test_api_locked(self): """Test editing with locked/unlocked list.""" # Lock list self.list.locked = True self.list.save() response = self.patch(self.entry_url, {'label': 'New Label'}, expected_code=400) self.assertIn('Selection list is locked', response.data['list']) ...
Test editing with locked/unlocked list.
test_api_locked
python
inventree/InvenTree
src/backend/InvenTree/common/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/tests.py
MIT
def get_legacy_models(): """Return a set of legacy attachment models.""" # Legacy attachment types to convert: # app_label, table name, target model, model ref return [ ('build', 'BuildOrderAttachment', 'build', 'build'), ('company', 'CompanyAttachment', 'company', 'company'), ( ...
Return a set of legacy attachment models.
get_legacy_models
python
inventree/InvenTree
src/backend/InvenTree/common/test_migrations.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_migrations.py
MIT
def generate_attachment(): """Generate a file attachment object for test upload.""" file_object = io.StringIO('Some dummy data') file_object.seek(0) return ContentFile(file_object.getvalue(), 'test.txt')
Generate a file attachment object for test upload.
generate_attachment
python
inventree/InvenTree
src/backend/InvenTree/common/test_migrations.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_migrations.py
MIT
def prepare(self): """Create initial data. Legacy attachment model types are: - BuildOrderAttachment - CompanyAttachment - ManufacturerPartAttachment - PurchaseOrderAttachment - SalesOrderAttachment - ReturnOrderAttachment - PartAttachment ...
Create initial data. Legacy attachment model types are: - BuildOrderAttachment - CompanyAttachment - ManufacturerPartAttachment - PurchaseOrderAttachment - SalesOrderAttachment - ReturnOrderAttachment - PartAttachment - StockItemAttachment ...
prepare
python
inventree/InvenTree
src/backend/InvenTree/common/test_migrations.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_migrations.py
MIT
def test_items_exist(self): """Test to ensure that the attachments are correctly migrated.""" Attachment = self.new_state.apps.get_model('common', 'Attachment') self.assertEqual(Attachment.objects.count(), 14) for model in [ 'build', 'company', 'purc...
Test to ensure that the attachments are correctly migrated.
test_items_exist
python
inventree/InvenTree
src/backend/InvenTree/common/test_migrations.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_migrations.py
MIT
def test_NotificationMethod(self): """Ensure the implementation requirements are tested.""" class FalseNotificationMethod(NotificationMethod): METHOD_NAME = 'FalseNotification' class AnotherFalseNotificationMethod(NotificationMethod): METHOD_NAME = 'AnotherFalseNotifica...
Ensure the implementation requirements are tested.
test_NotificationMethod
python
inventree/InvenTree
src/backend/InvenTree/common/test_notifications.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_notifications.py
MIT
def test_errors_passing(self): """Ensure that errors do not kill the whole delivery.""" class ErrorImplementation(SingleNotificationMethod): METHOD_NAME = 'ErrorImplementation' def get_targets(self): return [1] def send(self, target): ...
Ensure that errors do not kill the whole delivery.
test_errors_passing
python
inventree/InvenTree
src/backend/InvenTree/common/test_notifications.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_notifications.py
MIT
def test_BulkNotificationMethod(self): """Ensure the implementation requirements are tested. MixinNotImplementedError needs to raise if the send_bulk() method is not set. """ class WrongImplementation(BulkNotificationMethod): METHOD_NAME = 'WrongImplementationBulk' ...
Ensure the implementation requirements are tested. MixinNotImplementedError needs to raise if the send_bulk() method is not set.
test_BulkNotificationMethod
python
inventree/InvenTree
src/backend/InvenTree/common/test_notifications.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_notifications.py
MIT
def test_SingleNotificationMethod(self): """Ensure the implementation requirements are tested. MixinNotImplementedError needs to raise if the send() method is not set. """ class WrongImplementation(SingleNotificationMethod): METHOD_NAME = 'WrongImplementationSingle' ...
Ensure the implementation requirements are tested. MixinNotImplementedError needs to raise if the send() method is not set.
test_SingleNotificationMethod
python
inventree/InvenTree
src/backend/InvenTree/common/test_notifications.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_notifications.py
MIT
def test_setting_attributes(self): """Check notification method plugin methods: usersettings and tags.""" class SampleImplementation(BulkNotificationMethod): METHOD_NAME = 'test' GLOBAL_SETTING = 'ENABLE_NOTIFICATION_TEST' USER_SETTING = { 'name': 'En...
Check notification method plugin methods: usersettings and tags.
test_setting_attributes
python
inventree/InvenTree
src/backend/InvenTree/common/test_notifications.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_notifications.py
MIT
def test_delete(self): """Test that the task `delete_old_notifications` runs through without errors.""" # check empty run self.assertEqual(NotificationEntry.objects.all().count(), 0) offload_task(common_tasks.delete_old_notifications)
Test that the task `delete_old_notifications` runs through without errors.
test_delete
python
inventree/InvenTree
src/backend/InvenTree/common/test_tasks.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_tasks.py
MIT
def test_valid_url(self): """Tests that news feed is updated when accessing a valid URL.""" try: common_tasks.update_news_feed() except Exception as ex: # pragma: no cover self.fail(f'News feed raised exceptions: {ex}') self.assertNotEqual(NewsFeedEntry.objects....
Tests that news feed is updated when accessing a valid URL.
test_valid_url
python
inventree/InvenTree
src/backend/InvenTree/common/test_tasks.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_tasks.py
MIT
def test_connection_error(self): """Test connecting to an unavailable endpoint. This also emulates calling the endpoint behind a blocking proxy. """ settings.INVENTREE_NEWS_URL = 'http://10.255.255.1:81' with self.assertLogs('inventree', level='WARNING'): common_tas...
Test connecting to an unavailable endpoint. This also emulates calling the endpoint behind a blocking proxy.
test_connection_error
python
inventree/InvenTree
src/backend/InvenTree/common/test_tasks.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_tasks.py
MIT
def test_unset_url(self): """Test that no call is made to news feed if URL setting is invalid.""" settings.INVENTREE_NEWS_URL = '' self.assertTrue( offload_task(common_tasks.update_news_feed) ) # Task considered complete self.assertEqual( NewsFeedEntry.o...
Test that no call is made to news feed if URL setting is invalid.
test_unset_url
python
inventree/InvenTree
src/backend/InvenTree/common/test_tasks.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/test_tasks.py
MIT
def attachment_model_types(): """Return a list of valid attachment model choices.""" import InvenTree.models return list( InvenTree.helpers_model.getModelsWithMixin( InvenTree.models.InvenTreeAttachmentMixin ) )
Return a list of valid attachment model choices.
attachment_model_types
python
inventree/InvenTree
src/backend/InvenTree/common/validators.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/validators.py
MIT
def attachment_model_options(): """Return a list of options for models which support attachments.""" return [ (model.__name__.lower(), model._meta.verbose_name) for model in attachment_model_types() ]
Return a list of options for models which support attachments.
attachment_model_options
python
inventree/InvenTree
src/backend/InvenTree/common/validators.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/validators.py
MIT
def attachment_model_class_from_label(label: str): """Return the model class for the given label.""" if not label: raise ValidationError(_('No attachment model type provided')) for model in attachment_model_types(): if model.__name__.lower() == label.lower(): return model r...
Return the model class for the given label.
attachment_model_class_from_label
python
inventree/InvenTree
src/backend/InvenTree/common/validators.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/validators.py
MIT
def validate_attachment_model_type(value): """Ensure that the provided attachment model is valid.""" model_names = [el[0] for el in attachment_model_options()] if value not in model_names: raise ValidationError('Model type does not support attachments')
Ensure that the provided attachment model is valid.
validate_attachment_model_type
python
inventree/InvenTree
src/backend/InvenTree/common/validators.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/validators.py
MIT
def validate_notes_model_type(value): """Ensure that the provided model type is valid. The provided value must map to a model which implements the 'InvenTreeNotesMixin'. """ import InvenTree.helpers_model import InvenTree.models if not value: # Empty values are allowed return ...
Ensure that the provided model type is valid. The provided value must map to a model which implements the 'InvenTreeNotesMixin'.
validate_notes_model_type
python
inventree/InvenTree
src/backend/InvenTree/common/validators.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/validators.py
MIT
def validate_uppercase(value: str): """Ensure that the provided value is uppercase.""" value = str(value) if value != value.upper(): raise ValidationError(_('Value must be uppercase'))
Ensure that the provided value is uppercase.
validate_uppercase
python
inventree/InvenTree
src/backend/InvenTree/common/validators.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/validators.py
MIT
def validate_variable_string(value: str): """The passed value must be a valid variable identifier string.""" if not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*$', value): raise ValidationError(_('Value must be a valid variable identifier'))
The passed value must be a valid variable identifier string.
validate_variable_string
python
inventree/InvenTree
src/backend/InvenTree/common/validators.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/validators.py
MIT
def database_forwards(self, app_label, schema_editor, from_state, to_state) -> None: """Forwards migration *attempts* to create the model, but will fail gracefully if it already exists""" try: super().database_forwards(app_label, schema_editor, from_state, to_state) except Exception...
Forwards migration *attempts* to create the model, but will fail gracefully if it already exists
database_forwards
python
inventree/InvenTree
src/backend/InvenTree/common/migrations/0001_initial.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/migrations/0001_initial.py
MIT
def set_default_currency(apps, schema_editor): """ migrate the currency setting from config.yml to db """ # get value from settings-file base_currency = get_setting('INVENTREE_BASE_CURRENCY', 'base_currency', 'USD') from common.currency import currency_codes # check if value is valid if base_c...
migrate the currency setting from config.yml to db
set_default_currency
python
inventree/InvenTree
src/backend/InvenTree/common/migrations/0010_migrate_currency_setting.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/migrations/0010_migrate_currency_setting.py
MIT
def set_currencies(apps, schema_editor): """Set the default currency codes. Ref: https://github.com/inventree/InvenTree/pull/7390 Previously, the allowed currency codes were set in the external configuration (e.g via the configuration file or environment variables). Now, they are set in t...
Set the default currency codes. Ref: https://github.com/inventree/InvenTree/pull/7390 Previously, the allowed currency codes were set in the external configuration (e.g via the configuration file or environment variables). Now, they are set in the database (via the InvenTreeSetting model). ...
set_currencies
python
inventree/InvenTree
src/backend/InvenTree/common/migrations/0023_auto_20240602_1332.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/migrations/0023_auto_20240602_1332.py
MIT
def update_attachments(apps, schema_editor): """Migrate any existing attachment models to the new attachment table.""" Attachment = apps.get_model('common', 'attachment') N = 0 for app, model, target_model, model_ref in get_legacy_models(): LegacyAttachmentModel = apps.get_model(app, model) ...
Migrate any existing attachment models to the new attachment table.
update_attachments
python
inventree/InvenTree
src/backend/InvenTree/common/migrations/0026_auto_20240608_1238.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/migrations/0026_auto_20240608_1238.py
MIT
def reverse_attachments(apps, schema_editor): """Reverse data migration, and map new Attachment model back to legacy models.""" Attachment = apps.get_model('common', 'attachment') N = 0 for app, model, target_model, model_ref in get_legacy_models(): LegacyAttachmentModel = apps.get_model(app,...
Reverse data migration, and map new Attachment model back to legacy models.
reverse_attachments
python
inventree/InvenTree
src/backend/InvenTree/common/migrations/0026_auto_20240608_1238.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/migrations/0026_auto_20240608_1238.py
MIT
def migrate_userthemes(apps, schema_editor): """Mgrate text-based user references to ForeignKey references.""" ColorTheme = apps.get_model("common", "ColorTheme") User = apps.get_model(settings.AUTH_USER_MODEL) for theme in ColorTheme.objects.all(): try: theme.user_obj = User.object...
Mgrate text-based user references to ForeignKey references.
migrate_userthemes
python
inventree/InvenTree
src/backend/InvenTree/common/migrations/0028_colortheme_user_obj.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/migrations/0028_colortheme_user_obj.py
MIT
def update_news_feed_urls(apps, schema_editor): """Update and validate the news feed URLs.""" from common.models import NewsFeedEntry n = 0 for entry in NewsFeedEntry.objects.all(): if entry.link and entry.link.startswith('/'): entry.link = settings.INVENTREE_BASE_URL + entry.link...
Update and validate the news feed URLs.
update_news_feed_urls
python
inventree/InvenTree
src/backend/InvenTree/common/migrations/0031_auto_20241026_0024.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/migrations/0031_auto_20241026_0024.py
MIT
def validate_part_name_format(value): """Validate part name format. Make sure that each template container has a field of Part Model """ # Make sure that the field_name exists in Part model from part.models import Part jinja_template_regex = re.compile(r'{{.*?}}') field_name_regex = re.com...
Validate part name format. Make sure that each template container has a field of Part Model
validate_part_name_format
python
inventree/InvenTree
src/backend/InvenTree/common/setting/system.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/setting/system.py
MIT
def update_instance_name(setting): """Update the first site objects name to instance name.""" if not django_settings.SITE_MULTI: return try: from django.contrib.sites.models import Site except (ImportError, RuntimeError): # Multi-site support not enabled return site...
Update the first site objects name to instance name.
update_instance_name
python
inventree/InvenTree
src/backend/InvenTree/common/setting/system.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/setting/system.py
MIT
def update_instance_url(setting): """Update the first site objects domain to url.""" if not django_settings.SITE_MULTI: return try: from django.contrib.sites.models import Site except (ImportError, RuntimeError): # Multi-site support not enabled return site_obj = Si...
Update the first site objects domain to url.
update_instance_url
python
inventree/InvenTree
src/backend/InvenTree/common/setting/system.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/setting/system.py
MIT
def reload_plugin_registry(setting): """When a core plugin setting is changed, reload the plugin registry.""" from common.models import logger from plugin import registry logger.info("Reloading plugin registry due to change in setting '%s'", setting.key) registry.reload_plugins(full_reload=True, f...
When a core plugin setting is changed, reload the plugin registry.
reload_plugin_registry
python
inventree/InvenTree
src/backend/InvenTree/common/setting/system.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/setting/system.py
MIT
def barcode_plugins() -> list: """Return a list of plugin choices which can be used for barcode generation.""" try: from plugin import PluginMixinEnum, registry plugins = registry.with_mixin(PluginMixinEnum.BARCODE, active=True) except Exception: # pragma: no cover plugins = [] ...
Return a list of plugin choices which can be used for barcode generation.
barcode_plugins
python
inventree/InvenTree
src/backend/InvenTree/common/setting/system.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/setting/system.py
MIT
def label_printer_options(): """Build a list of available label printer options.""" printers = [] label_printer_plugins = registry.with_mixin(PluginMixinEnum.LABELS) if label_printer_plugins: printers.extend([ (p.slug, p.name + ' - ' + p.human_name) for p in label_printer_plugins ...
Build a list of available label printer options.
label_printer_options
python
inventree/InvenTree
src/backend/InvenTree/common/setting/user.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/common/setting/user.py
MIT
def get_queryset(self): """Return annotated queryset for the company detail endpoint.""" queryset = super().get_queryset() queryset = CompanySerializer.annotate_queryset(queryset) return queryset
Return annotated queryset for the company detail endpoint.
get_queryset
python
inventree/InvenTree
src/backend/InvenTree/company/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/company/api.py
MIT
def get_serializer(self, *args, **kwargs): """Return serializer instance for this endpoint.""" # Do we wish to include extra detail? try: params = self.request.query_params kwargs['part_detail'] = str2bool(params.get('part_detail', None)) kwargs['manufacturer...
Return serializer instance for this endpoint.
get_serializer
python
inventree/InvenTree
src/backend/InvenTree/company/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/company/api.py
MIT
def filter_company(self, queryset, name, value: int): """Filter the queryset by either manufacturer or supplier.""" return queryset.filter( Q(manufacturer_part__manufacturer=value) | Q(supplier=value) ).distinct()
Filter the queryset by either manufacturer or supplier.
filter_company
python
inventree/InvenTree
src/backend/InvenTree/company/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/company/api.py
MIT
def filter_has_stock(self, queryset, name, value): """Filter the queryset based on whether the SupplierPart has stock available.""" if value: return queryset.filter(in_stock__gt=0) else: return queryset.exclude(in_stock__gt=0)
Filter the queryset based on whether the SupplierPart has stock available.
filter_has_stock
python
inventree/InvenTree
src/backend/InvenTree/company/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/company/api.py
MIT
def get_queryset(self, *args, **kwargs): """Return annotated queryest object for the SupplierPart list.""" queryset = super().get_queryset(*args, **kwargs) queryset = SupplierPartSerializer.annotate_queryset(queryset) queryset = queryset.prefetch_related('part', 'part__pricing_data') ...
Return annotated queryest object for the SupplierPart list.
get_queryset
python
inventree/InvenTree
src/backend/InvenTree/company/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/company/api.py
MIT
def get_queryset(self): """Return annotated queryset for the SupplierPriceBreak list endpoint.""" queryset = super().get_queryset() queryset = SupplierPriceBreakSerializer.annotate_queryset(queryset) return queryset
Return annotated queryset for the SupplierPriceBreak list endpoint.
get_queryset
python
inventree/InvenTree
src/backend/InvenTree/company/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/company/api.py
MIT
def annotate_on_order_quantity(): """Annotate the 'on_order' quantity for each SupplierPart in a queryset. - This is the total quantity of parts on order from all open purchase orders - Takes into account the 'received' quantity for each order line """ # Filter only 'active' purhase orders # Fi...
Annotate the 'on_order' quantity for each SupplierPart in a queryset. - This is the total quantity of parts on order from all open purchase orders - Takes into account the 'received' quantity for each order line
annotate_on_order_quantity
python
inventree/InvenTree
src/backend/InvenTree/company/filters.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/company/filters.py
MIT
def rename_company_image(instance, filename): """Function to rename a company image after upload. Args: instance: Company object filename: uploaded image filename Returns: New image filename """ base = 'company_images' ext = filename.split('.')[-1] if filename.count('....
Function to rename a company image after upload. Args: instance: Company object filename: uploaded image filename Returns: New image filename
rename_company_image
python
inventree/InvenTree
src/backend/InvenTree/company/models.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/company/models.py
MIT
def address(self): """Return the string representation for the primary address. This property exists for backwards compatibility """ addr = self.primary_address return str(addr) if addr is not None else None
Return the string representation for the primary address. This property exists for backwards compatibility
address
python
inventree/InvenTree
src/backend/InvenTree/company/models.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/company/models.py
MIT