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 handle(self, *args, **kwargs): """Export report context information to a JSON file.""" from report.helpers import report_model_types from report.models import ( BaseContextExtension, LabelContextExtension, ReportContextExtension, ) context...
Export report context information to a JSON file.
handle
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/export_report_context.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/export_report_context.py
MIT
def handle(self, *args, **kwargs): """Export settings information to a JSON file.""" from common.models import InvenTreeSetting, InvenTreeUserSetting settings = {'global': {}, 'user': {}} # Global settings for key, setting in InvenTreeSetting.SETTINGS.items(): setti...
Export settings information to a JSON file.
handle
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/export_settings_definitions.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/export_settings_definitions.py
MIT
def handle(self, *args, **kwargs): """Export tag information to a YAML file.""" tags = discover_tags() # Write filename = kwargs.get('filename', 'inventree_tags.yml') with open(filename, 'w', encoding='utf-8') as f: yaml.dump(tags, f, indent=4) print(f"Export...
Export tag information to a YAML file.
handle
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/export_tags.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/export_tags.py
MIT
def discover_tags(): """Discover all available tags. This function is a copy of a function from the Django 'admindocs' module in django.contrib.admindocs.views.TemplateTagIndexView """ tags = [] try: engine = Engine.get_default() except ImproperlyConfigured: # Non-trivial TEMPLA...
Discover all available tags. This function is a copy of a function from the Django 'admindocs' module in django.contrib.admindocs.views.TemplateTagIndexView
discover_tags
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/export_tags.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/export_tags.py
MIT
def handle(self, *args, **kwargs): """Generate an icon map from the FontAwesome library to the new icon library.""" # Check for invalid combinations of arguments if kwargs['output_file'] and kwargs['input_file']: raise CommandError('Cannot specify both --input-file and --output-file'...
Generate an icon map from the FontAwesome library to the new icon library.
handle
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/migrate_icons.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/migrate_icons.py
MIT
def get_model_items_with_icons(model: models.Model, icon_field: str): """Return a list of models with icon fields.""" return model.objects.exclude(**{f'{icon_field}__isnull': True}).exclude(**{ f'{icon_field}__exact': '' })
Return a list of models with icon fields.
get_model_items_with_icons
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/migrate_icons.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/migrate_icons.py
MIT
def rebuild_models(self): """Rebuild all MPTT models in the database.""" # Part model try: logger.info('Rebuilding Part objects') from part.models import Part Part.objects.rebuild() except Exception: logger.info('Error rebuilding Part obj...
Rebuild all MPTT models in the database.
rebuild_models
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/rebuild_models.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/rebuild_models.py
MIT
def rebuild_thumbnail(self, model): """Rebuild the thumbnail specified by the "image" field of the provided model.""" if not model.image: return img = model.image # Check for image paths img_paths = [] for x in [model.image, model.image.thumbnail, model.ima...
Rebuild the thumbnail specified by the "image" field of the provided model.
rebuild_thumbnail
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/rebuild_thumbnails.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/rebuild_thumbnails.py
MIT
def handle(self, *args, **kwargs): """Remove MFA for the supplied user (by mail).""" # general settings mail = kwargs.get('mail') if not mail: raise KeyError('A mail is required') user = get_user_model() mfa_user = [ *set( user.obje...
Remove MFA for the supplied user (by mail).
handle
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/remove_mfa.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/remove_mfa.py
MIT
def handle(self, *args, **kwargs): """Extended schema generation that patches in django-allauth schemas.""" from allauth.headless.spec.internal import schema # gather paths org_path = Path(schema.__file__).parent.parent / 'doc/openapi.yaml' with open(org_path, 'rb') as f: ...
Extended schema generation that patches in django-allauth schemas.
handle
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/schema.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/schema.py
MIT
def handle(self, *args, **kwargs): """Wait till the database is ready.""" self.stdout.write('Waiting for database...') connected = False while not connected: time.sleep(2) try: connection.ensure_connection() connected = True ...
Wait till the database is ready.
handle
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/management/commands/wait_for_db.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/management/commands/wait_for_db.py
MIT
def setting_object(key, *args, **kwargs): """Return a setting object specified by the given key. (Or return None if the setting does not exist) if a user-setting was requested return that """ cache = kwargs.get('cache', True) if 'plugin' in kwargs: # Note, 'plugin' is an instance of an...
Return a setting object specified by the given key. (Or return None if the setting does not exist) if a user-setting was requested return that
setting_object
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/templatetags/inventree_extras.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/templatetags/inventree_extras.py
MIT
def settings_value(key, *args, **kwargs): """Return a settings value specified by the given key.""" if 'user' in kwargs: if not kwargs['user'] or ( kwargs['user'] and kwargs['user'].is_authenticated is False ): return common.models.InvenTreeUserSetting.get_setting(key) ...
Return a settings value specified by the given key.
settings_value
python
inventree/InvenTree
src/backend/InvenTree/InvenTree/templatetags/inventree_extras.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/InvenTree/templatetags/inventree_extras.py
MIT
def get_readonly_fields(self, request, obj): """If update, don't allow changes on machine_type and driver.""" if obj is not None: return ['machine_type', 'driver', *self.readonly_fields] return self.readonly_fields
If update, don't allow changes on machine_type and driver.
get_readonly_fields
python
inventree/InvenTree
src/backend/InvenTree/machine/admin.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/admin.py
MIT
def get_machine(machine_pk): """Get machine by pk. Raises: NotFound: If machine is not found Returns: BaseMachineType: The machine instance in the registry """ machine = registry.get_machine(machine_pk) if machine is None: raise NotFound(detail=f"Machine '{machine_pk}'...
Get machine by pk. Raises: NotFound: If machine is not found Returns: BaseMachineType: The machine instance in the registry
get_machine
python
inventree/InvenTree
src/backend/InvenTree/machine/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/api.py
MIT
def get(self, request, pk): """Return all settings for a machine config.""" machine = get_machine(pk) all_settings = [] for settings, config_type in machine.setting_types: settings_dict = MachineSetting.all_settings( settings_definition=settings, ...
Return all settings for a machine config.
get
python
inventree/InvenTree
src/backend/InvenTree/machine/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/api.py
MIT
def get_object(self): """Lookup machine setting object, based on the URL.""" pk = self.kwargs['pk'] key = self.kwargs['key'] config_type = MachineSetting.get_config_type(self.kwargs['config_type']) machine = get_machine(pk) setting_map = {d: s for s, d in machine.settin...
Lookup machine setting object, based on the URL.
get_object
python
inventree/InvenTree
src/backend/InvenTree/machine/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/api.py
MIT
def get(self, request): """Provide status data for the machine registry.""" result = MachineSerializers.MachineRegistryStatusSerializer({ 'registry_errors': [{'message': str(error)} for error in registry.errors] }).data return Response(result)
Provide status data for the machine registry.
get
python
inventree/InvenTree
src/backend/InvenTree/machine/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/api.py
MIT
def ready(self) -> None: """Initialization method for the machine app.""" if ( not canAppAccessDatabase(allow_test=True) or not isPluginRegistryLoaded() or isRunningMigrations() or isImportingData() ): logger.debug('Machine app: Skippin...
Initialization method for the machine app.
ready
python
inventree/InvenTree
src/backend/InvenTree/machine/apps.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/apps.py
MIT
def init_driver(self): """This method gets called after all machines are created and can be used to initialize the driver. After the driver is initialized, the self.init_machine function is called for each machine associated with that driver. """
This method gets called after all machines are created and can be used to initialize the driver. After the driver is initialized, the self.init_machine function is called for each machine associated with that driver.
init_driver
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def init_machine(self, machine: 'BaseMachineType'): """This method gets called for each active machine using that driver while initialization. If this function raises an Exception, it gets added to the machine.errors list and the machine does not initialize successfully. Arguments: ...
This method gets called for each active machine using that driver while initialization. If this function raises an Exception, it gets added to the machine.errors list and the machine does not initialize successfully. Arguments: machine: Machine instance
init_machine
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def update_machine( self, old_machine_state: dict[str, Any], machine: 'BaseMachineType' ): """This method gets called for each update of a machine. Note: machine.restart_required can be set to True here if the machine needs a manual restart to apply the changes Argument...
This method gets called for each update of a machine. Note: machine.restart_required can be set to True here if the machine needs a manual restart to apply the changes Arguments: old_machine_state: Dict holding the old machine state before update machine: Machine in...
update_machine
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def restart_machine(self, machine: 'BaseMachineType'): """This method gets called on manual machine restart e.g. by using the restart machine action in the Admin Center. Note: `machine.restart_required` gets set to False again before this function is called Arguments: m...
This method gets called on manual machine restart e.g. by using the restart machine action in the Admin Center. Note: `machine.restart_required` gets set to False again before this function is called Arguments: machine: Machine instance
restart_machine
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def get_machines(self, **kwargs): """Return all machines using this driver (By default only initialized machines). Keyword Arguments: name (str): Machine name machine_type (BaseMachineType): Machine type definition (class) initialized (bool | None): use None to get a...
Return all machines using this driver (By default only initialized machines). Keyword Arguments: name (str): Machine name machine_type (BaseMachineType): Machine type definition (class) initialized (bool | None): use None to get all machines (default: True) activ...
get_machines
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def machine_config(self): """Machine_config property which is a reference to the database entry.""" # always fetch the machine_config if needed to ensure we get the newest reference from .models import MachineConfig return MachineConfig.objects.filter(pk=self.pk).first()
Machine_config property which is a reference to the database entry.
machine_config
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def initialize(self): """Machine initialization function, gets called after all machines are loaded.""" if self.driver is None: return # check if all required settings are defined before continue with init process settings_valid, missing_settings = self.check_settings() ...
Machine initialization function, gets called after all machines are loaded.
initialize
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def update(self, old_state: dict[str, Any]): """Machine update function, gets called if the machine itself changes or their settings. Arguments: old_state: Dict holding the old machine state before update """ if self.driver is None: return try: ...
Machine update function, gets called if the machine itself changes or their settings. Arguments: old_state: Dict holding the old machine state before update
update
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def restart(self): """Machine restart function, can be used to manually restart the machine from the admin ui. This will first reset the machines state (errors, status, status_text) and then call the drivers restart function. """ if self.driver is None: return try: ...
Machine restart function, can be used to manually restart the machine from the admin ui. This will first reset the machines state (errors, status, status_text) and then call the drivers restart function.
restart
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def get_setting( self, key: str, config_type_str: Literal['M', 'D'], cache: bool = False ): """Return the 'value' of the setting associated with this machine. Arguments: key: The 'name' of the setting value to be retrieved config_type_str: Either "M" (machine scoped ...
Return the 'value' of the setting associated with this machine. Arguments: key: The 'name' of the setting value to be retrieved config_type_str: Either "M" (machine scoped settings) or "D" (driver scoped settings) cache: Whether to use RAM cached value (default = False) ...
get_setting
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def set_setting(self, key: str, config_type_str: Literal['M', 'D'], value: Any): """Set plugin setting value by key. Arguments: key: The 'name' of the setting to set config_type_str: Either "M" (machine scoped settings) or "D" (driver scoped settings) value: The 'val...
Set plugin setting value by key. Arguments: key: The 'name' of the setting to set config_type_str: Either "M" (machine scoped settings) or "D" (driver scoped settings) value: The 'value' of the setting
set_setting
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def check_settings(self): """Check if all required settings for this machine are defined. Returns: is_valid: Are all required settings defined missing_settings: dict[ConfigType, list[str]] of all settings that are missing (empty if is_valid is 'True') """ from ma...
Check if all required settings for this machine are defined. Returns: is_valid: Are all required settings defined missing_settings: dict[ConfigType, list[str]] of all settings that are missing (empty if is_valid is 'True')
check_settings
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_type.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_type.py
MIT
def save(self, *args, **kwargs) -> None: """Custom save function to capture creates/updates to notify the registry.""" created = self._state.adding old_machine = None if ( not created and self.pk and (old_machine := MachineConfig.objects.get(pk=self.p...
Custom save function to capture creates/updates to notify the registry.
save
python
inventree/InvenTree
src/backend/InvenTree/machine/models.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/models.py
MIT
def to_dict(self): """Serialize a machine config to a dict including setting.""" machine = {f.name: f.value_to_string(self) for f in self._meta.fields} machine['settings'] = { (setting.config_type, setting.key): setting.value for setting in MachineSetting.objects.filter(m...
Serialize a machine config to a dict including setting.
to_dict
python
inventree/InvenTree
src/backend/InvenTree/machine/models.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/models.py
MIT
def get_admin_errors(self): """Get machine errors for django admin interface.""" return format_html_join( mark_safe('<br>'), '{}', ((str(error),) for error in self.errors) ) or mark_safe(f'<i>{_("No errors")}</i>')
Get machine errors for django admin interface.
get_admin_errors
python
inventree/InvenTree
src/backend/InvenTree/machine/models.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/models.py
MIT
def get_machine_status(self): """Get machine status for django admin interface.""" if self.machine is None: return None out = mark_safe(self.machine.status.render(self.machine.status)) if self.machine.status_text: out += escape(f' ({self.machine.status_text})') ...
Get machine status for django admin interface.
get_machine_status
python
inventree/InvenTree
src/backend/InvenTree/machine/models.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/models.py
MIT
def save(self, *args, **kwargs) -> None: """Custom save method to notify the registry on changes.""" old_machine = self.machine_config.to_dict() super().save(*args, **kwargs) registry.update_machine(old_machine, self.machine_config)
Custom save method to notify the registry on changes.
save
python
inventree/InvenTree
src/backend/InvenTree/machine/models.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/models.py
MIT
def get_config_type(cls, config_type_str: Literal['M', 'D']): """Helper method to get the correct enum value for easier usage with literal strings.""" if config_type_str == 'M': return cls.ConfigType.MACHINE elif config_type_str == 'D': return cls.ConfigType.DRIVER
Helper method to get the correct enum value for easier usage with literal strings.
get_config_type
python
inventree/InvenTree
src/backend/InvenTree/machine/models.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/models.py
MIT
def get_setting_definition(cls, key, **kwargs): """In the BaseInvenTreeSetting class, we have a class attribute named 'SETTINGS'. which is a dict object that fully defines all the setting parameters. Here, unlike the BaseInvenTreeSetting, we do not know the definitions of all settings ...
In the BaseInvenTreeSetting class, we have a class attribute named 'SETTINGS'. which is a dict object that fully defines all the setting parameters. Here, unlike the BaseInvenTreeSetting, we do not know the definitions of all settings 'ahead of time' (as they are defined externally in the mach...
get_setting_definition
python
inventree/InvenTree
src/backend/InvenTree/machine/models.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/models.py
MIT
def __init__(self) -> None: """Initialize machine registry. Set up all needed references for internal and external states. """ self.machine_types: dict[str, type[BaseMachineType]] = {} self.drivers: dict[str, type[BaseDriver]] = {} self.driver_instances: dict[str, BaseDr...
Initialize machine registry. Set up all needed references for internal and external states.
__init__
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def discover_machine_types(self): """Discovers all machine types by inferring all classes that inherit the BaseMachineType class.""" import InvenTree.helpers logger.debug('Collecting machine types') machine_types: dict[str, type[BaseMachineType]] = {} base_drivers: list[type[Ba...
Discovers all machine types by inferring all classes that inherit the BaseMachineType class.
discover_machine_types
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def discover_drivers(self): """Discovers all machine drivers by inferring all classes that inherit the BaseDriver class.""" import InvenTree.helpers logger.debug('Collecting machine drivers') drivers: dict[str, type[BaseDriver]] = {} discovered_drivers: set[type[BaseDriver]] =...
Discovers all machine drivers by inferring all classes that inherit the BaseDriver class.
discover_drivers
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def get_driver_instance(self, slug: str): """Return or create a driver instance if needed.""" if slug not in self.driver_instances: driver = self.drivers.get(slug, None) if driver is None: return None self.driver_instances[slug] = driver() re...
Return or create a driver instance if needed.
get_driver_instance
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def load_machines(self, main: bool = False): """Load all machines defined in the database into the machine registry.""" # Imports need to be in this level to prevent early db model imports from machine.models import MachineConfig for machine_config in MachineConfig.objects.all(): ...
Load all machines defined in the database into the machine registry.
load_machines
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def add_machine(self, machine_config, initialize=True, update_registry_hash=True): """Add a machine to the machine registry.""" machine_type = self.machine_types.get(machine_config.machine_type, None) if machine_type is None: self.handle_error(f"Machine type '{machine_config.machine_...
Add a machine to the machine registry.
add_machine
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def update_machine( self, old_machine_state, machine_config, update_registry_hash=True ): """Notify the machine about an update.""" if machine := machine_config.machine: machine.update(old_machine_state) if update_registry_hash: self._update_registry_...
Notify the machine about an update.
update_machine
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def get_machines(self, **kwargs): """Get loaded machines from registry (By default only initialized machines). Kwargs: name: Machine name machine_type: Machine type definition (class) driver: Machine driver (class) initialized (bool | None): use None to g...
Get loaded machines from registry (By default only initialized machines). Kwargs: name: Machine name machine_type: Machine type definition (class) driver: Machine driver (class) initialized (bool | None): use None to get all machines (default: True) a...
get_machines
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def get_machine(self, pk: Union[str, UUID]): """Get machine from registry by pk.""" self._check_reload() return self.machines.get(str(pk), None)
Get machine from registry by pk.
get_machine
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def get_drivers(self, machine_type: str): """Get all drivers for a specific machine type.""" return [ driver for driver in self.driver_instances.values() if driver.machine_type == machine_type ]
Get all drivers for a specific machine type.
get_drivers
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def _calculate_registry_hash(self): """Calculate a hash of the machine registry state.""" from hashlib import md5 from plugin import registry as plugin_registry data = md5() # If the plugin registry has changed, the machine registry hash will change plugin_registry.upd...
Calculate a hash of the machine registry state.
_calculate_registry_hash
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def _check_reload(self): """Check if the registry needs to be reloaded, and reload it.""" if not self._hash: self._hash = self._calculate_registry_hash() try: reg_hash = get_global_setting('_MACHINE_REGISTRY_HASH', '', create=False) except Exception as exc: ...
Check if the registry needs to be reloaded, and reload it.
_check_reload
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def call_machine_function( self, machine_id: str, function_name: str, *args, **kwargs ): """Call a named function against a machine instance. Arguments: machine_id: The UUID of the machine to call the function against function_name: The name of the function to call ...
Call a named function against a machine instance. Arguments: machine_id: The UUID of the machine to call the function against function_name: The name of the function to call
call_machine_function
python
inventree/InvenTree
src/backend/InvenTree/machine/registry.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/registry.py
MIT
def get_status(self, obj: MachineConfig) -> int: """Serializer method for the status field.""" status = getattr(obj.machine, 'status', None) if status is not None: return status.value return -1
Serializer method for the status field.
get_status
python
inventree/InvenTree
src/backend/InvenTree/machine/serializers.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/serializers.py
MIT
def __init__(self, *args, **kwargs): """Custom init method to make the config_type field read only.""" super().__init__(*args, **kwargs) self.Meta.read_only_fields = ['config_type'] # type: ignore
Custom init method to make the config_type field read only.
__init__
python
inventree/InvenTree
src/backend/InvenTree/machine/serializers.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/serializers.py
MIT
def get_errors(self, obj) -> list[str]: """Serializer method for the errors field.""" driver_instance = registry.driver_instances.get(obj.SLUG, None) if driver_instance is None: return [] return [str(err) for err in driver_instance.errors]
Serializer method for the errors field.
get_errors
python
inventree/InvenTree
src/backend/InvenTree/machine/serializers.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/serializers.py
MIT
def setUp(self): """Setup the label printer machine type.""" super().setUp() class TestingLabelPrinterDriver(LabelPrinterBaseDriver): """Label printer driver for testing.""" SLUG = 'testing-label-printer' NAME = 'Testing Label Printer' DESCRIPTIO...
Setup the label printer machine type.
setUp
python
inventree/InvenTree
src/backend/InvenTree/machine/tests.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/tests.py
MIT
def test_machine_type_list(self): """Test machine types list API endpoint.""" response = self.get(reverse('api-machine-types')) machine_type = [t for t in response.data if t['slug'] == 'label-printer'] self.assertEqual(len(machine_type), 1) machine_type = machine_type[0] ...
Test machine types list API endpoint.
test_machine_type_list
python
inventree/InvenTree
src/backend/InvenTree/machine/test_api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/test_api.py
MIT
def test_machine_driver_list(self): """Test machine driver list API endpoint.""" response = self.get(reverse('api-machine-drivers')) driver = [a for a in response.data if a['slug'] == 'test-label-printer-api'] self.assertEqual(len(driver), 1) driver = driver[0] self.asser...
Test machine driver list API endpoint.
test_machine_driver_list
python
inventree/InvenTree
src/backend/InvenTree/machine/test_api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/test_api.py
MIT
def test_machine_detail_settings(self): """Test machine detail settings API endpoint.""" machine_setting_url = reverse( 'api-machine-settings-detail', kwargs={'pk': self.placeholder_uuid, 'config_type': 'M', 'key': 'LOCATION'}, ) # Test machine settings for non-e...
Test machine detail settings API endpoint.
test_machine_detail_settings
python
inventree/InvenTree
src/backend/InvenTree/machine/test_api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/test_api.py
MIT
def print_label( self, machine: 'LabelPrinterMachine', label: LabelTemplate, item: models.Model, **kwargs, ) -> None: """Print a single label with the provided template and item. Arguments: machine: The LabelPrintingMachine instance that should be...
Print a single label with the provided template and item. Arguments: machine: The LabelPrintingMachine instance that should be used for printing label: The LabelTemplate object to use for printing item: The database item to print (e.g. StockItem instance) Keyword Ar...
print_label
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def print_labels( self, machine: 'LabelPrinterMachine', label: LabelTemplate, items: QuerySet[models.Model], **kwargs, ) -> Union[JsonResponse, None]: """Print one or more labels with the provided template and items. Arguments: machine: The LabelP...
Print one or more labels with the provided template and items. Arguments: machine: The LabelPrintingMachine instance that should be used for printing label: The LabelTemplate object to use for printing items: The list of database items to print (e.g. StockItem instances) ...
print_labels
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def get_printers( self, label: LabelTemplate, items: QuerySet, **kwargs ) -> list['LabelPrinterMachine']: """Get all printers that would be available to print this job. By default all printers that are initialized using this driver are returned. Arguments: label: The La...
Get all printers that would be available to print this job. By default all printers that are initialized using this driver are returned. Arguments: label: The LabelTemplate object to use for printing items: The lost of database items to print (e.g. StockItem instances) ...
get_printers
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def get_printing_options_serializer( self, request: Request, *args, **kwargs ) -> 'LabelPrinterBaseDriver.PrintingOptionsSerializer': """Return a serializer class instance with dynamic printing options. Arguments: request: The request made to print a label or interfering the ava...
Return a serializer class instance with dynamic printing options. Arguments: request: The request made to print a label or interfering the available serializer fields via an OPTIONS request Note: `*args`, `**kwargs` needs to be passed to the serializer instance Returns...
get_printing_options_serializer
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def machine_plugin(self) -> LabelPrintingMixin: """Returns the builtin machine label printing plugin that manages printing through machines.""" plg = plg_registry.get_plugin('inventreelabelmachine') return cast(LabelPrintingMixin, plg)
Returns the builtin machine label printing plugin that manages printing through machines.
machine_plugin
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def render_to_pdf( self, label: LabelTemplate, item: models.Model, **kwargs ) -> HttpResponse: """Helper method to render a label to PDF format for a specific item. Arguments: label: The LabelTemplate object to render item: The item to render the label with "...
Helper method to render a label to PDF format for a specific item. Arguments: label: The LabelTemplate object to render item: The item to render the label with
render_to_pdf
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def render_to_pdf_data( self, label: LabelTemplate, item: models.Model, **kwargs ) -> bytes: """Helper method to render a label to PDF and return it as bytes for a specific item. Arguments: label: The LabelTemplate object to render item: The item to render the label ...
Helper method to render a label to PDF and return it as bytes for a specific item. Arguments: label: The LabelTemplate object to render item: The item to render the label with
render_to_pdf_data
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def render_to_html(self, label: LabelTemplate, item: models.Model, **kwargs) -> str: """Helper method to render a label to HTML format for a specific item. Arguments: label: The LabelTemplate object to render item: The item to render the label with """ request = ...
Helper method to render a label to HTML format for a specific item. Arguments: label: The LabelTemplate object to render item: The item to render the label with
render_to_html
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def render_to_png( self, label: LabelTemplate, item: models.Model, **kwargs ) -> Union[Image, None]: """Helper method to render a label to PNG format for a specific item. Arguments: label: The LabelTemplate object to render item: The item to render the label with ...
Helper method to render a label to PNG format for a specific item. Arguments: label: The LabelTemplate object to render item: The item to render the label with Keyword Arguments: pdf_data (bytes): The pdf document as bytes (optional) dpi (int): The dpi u...
render_to_png
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def _get_dummy_request(self): """Return a dummy request object to it work with legacy code. Note: this is a private method and can be removed at anytime """ r = HttpRequest() r.META['SERVER_PORT'] = '80' r.META['SERVER_NAME'] = 'localhost' r.user = AnonymousUser(...
Return a dummy request object to it work with legacy code. Note: this is a private method and can be removed at anytime
_get_dummy_request
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def location(self): """Access the machines location instance using this property.""" location_pk = self.get_setting('LOCATION', 'M') if not location_pk: return None return StockLocation.objects.get(pk=location_pk)
Access the machines location instance using this property.
location
python
inventree/InvenTree
src/backend/InvenTree/machine/machine_types/label_printer.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py
MIT
def get_queryset(self, *args, **kwargs): """Return the annotated queryset for this endpoint.""" queryset = super().get_queryset(*args, **kwargs) queryset = queryset.prefetch_related('order') return queryset
Return the annotated queryset for this endpoint.
get_queryset
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def create(self, request, *args, **kwargs): """Save user information on order creation.""" serializer = self.get_serializer(data=self.clean_data(request.data)) serializer.is_valid(raise_exception=True) item = serializer.save() item.created_by = request.user item.save() ...
Save user information on order creation.
create
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_status(self, queryset, name, value): """Filter by integer status code. Note: Also account for the possibility of a custom status code. """ q1 = Q(status=value, status_custom_key__isnull=True) q2 = Q(status_custom_key=value) return queryset.filter(q1 | q2).dis...
Filter by integer status code. Note: Also account for the possibility of a custom status code.
filter_status
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_overdue(self, queryset, name, value): """Generic filter for determining if an order is 'overdue'. Note that the overdue_filter() classmethod must be defined for the model """ if str2bool(value): return queryset.filter(self.Meta.model.overdue_filter()) retu...
Generic filter for determining if an order is 'overdue'. Note that the overdue_filter() classmethod must be defined for the model
filter_overdue
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_outstanding(self, queryset, name, value): """Generic filter for determining if an order is 'outstanding'.""" if str2bool(value): return queryset.filter(status__in=self.Meta.model.get_status_class().OPEN) return queryset.exclude(status__in=self.Meta.model.get_status_class()...
Generic filter for determining if an order is 'outstanding'.
filter_outstanding
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_min_date(self, queryset, name, value): """Filter the queryset to include orders *after* a specified date. This is used in combination with filter_max_date, to provide a queryset which matches a particular range of dates. In particular, this is used in the UI for the calendar...
Filter the queryset to include orders *after* a specified date. This is used in combination with filter_max_date, to provide a queryset which matches a particular range of dates. In particular, this is used in the UI for the calendar view.
filter_min_date
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_max_date(self, queryset, name, value): """Filter the queryset to include orders *before* a specified date. This is used in combination with filter_min_date, to provide a queryset which matches a particular range of dates. In particular, this is used in the UI for the calenda...
Filter the queryset to include orders *before* a specified date. This is used in combination with filter_min_date, to provide a queryset which matches a particular range of dates. In particular, this is used in the UI for the calendar view.
filter_max_date
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_has_pricing(self, queryset, name, value): """Filter by whether or not the line item has pricing information.""" filters = {self.Meta.price_field: None} if str2bool(value): return queryset.exclude(**filters) return queryset.filter(**filters)
Filter by whether or not the line item has pricing information.
filter_has_pricing
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def get_serializer_context(self): """Add the PurchaseOrder object to the serializer context.""" context = super().get_serializer_context() # Pass the purchase order through to the serializer for validation try: context['order'] = models.PurchaseOrder.objects.get( ...
Add the PurchaseOrder object to the serializer context.
get_serializer_context
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_order_complete(self, queryset, name, value): """Filter by whether the order is 'complete' or not.""" if str2bool(value): return queryset.filter(order__status=PurchaseOrderStatus.COMPLETE.value) return queryset.exclude(order__status=PurchaseOrderStatus.COMPLETE.value)
Filter by whether the order is 'complete' or not.
filter_order_complete
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_base_part(self, queryset, name, base_part): """Filter by the 'base_part' attribute. Note: - If "include_variants" is True, include all variants of the selected part - Otherwise, just filter by the selected part """ include_variants = str2bool(self.data.get('in...
Filter by the 'base_part' attribute. Note: - If "include_variants" is True, include all variants of the selected part - Otherwise, just filter by the selected part
filter_base_part
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_pending(self, queryset, name, value): """Filter by "pending" status (order status = pending).""" if str2bool(value): return queryset.filter(order__status__in=PurchaseOrderStatusGroups.OPEN) return queryset.exclude(order__status__in=PurchaseOrderStatusGroups.OPEN)
Filter by "pending" status (order status = pending).
filter_pending
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_received(self, queryset, name, value): """Filter by lines which are "received" (or "not" received). A line is considered "received" when received >= quantity """ q = Q(received__gte=F('quantity')) if str2bool(value): return queryset.filter(q) # On...
Filter by lines which are "received" (or "not" received). A line is considered "received" when received >= quantity
filter_received
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def get_queryset(self, *args, **kwargs): """Return annotated queryset for this endpoint.""" queryset = super().get_queryset(*args, **kwargs) queryset = serializers.PurchaseOrderLineItemSerializer.annotate_queryset( queryset ) return queryset
Return annotated queryset for this endpoint.
get_queryset
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def perform_update(self, serializer): """Override the perform_update method to auto-update pricing if required.""" super().perform_update(serializer) # possibly auto-update pricing based on the supplier part pricing data if serializer.validated_data.get('auto_pricing', True): ...
Override the perform_update method to auto-update pricing if required.
perform_update
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def create(self, request, *args, **kwargs): """Create or update a new PurchaseOrderLineItem object.""" serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) data = cast(dict, serializer.validated_data) # possibly merge duplicate items ...
Create or update a new PurchaseOrderLineItem object.
create
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_part(self, queryset, name, part): """Filter SalesOrder by selected 'part'. Note: - If 'include_variants' is set to True, then all variants of the selected part will be included. - Otherwise, just filter by the selected part. """ include_variants = str2bool(sel...
Filter SalesOrder by selected 'part'. Note: - If 'include_variants' is set to True, then all variants of the selected part will be included. - Otherwise, just filter by the selected part.
filter_part
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_allocated(self, queryset, name, value): """Filter by lines which are 'allocated'. A line is 'allocated' when allocated >= quantity """ q = Q(allocated__gte=F('quantity')) if str2bool(value): return queryset.filter(q) return queryset.exclude(q)
Filter by lines which are 'allocated'. A line is 'allocated' when allocated >= quantity
filter_allocated
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_completed(self, queryset, name, value): """Filter by lines which are "completed". A line is 'completed' when shipped >= quantity """ q = Q(shipped__gte=F('quantity')) if str2bool(value): return queryset.filter(q) return queryset.exclude(q)
Filter by lines which are "completed". A line is 'completed' when shipped >= quantity
filter_completed
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_order_outstanding(self, queryset, name, value): """Filter by whether the order is 'outstanding' or not.""" if str2bool(value): return queryset.filter(order__status__in=SalesOrderStatusGroups.OPEN) return queryset.exclude(order__status__in=SalesOrderStatusGroups.OPEN)
Filter by whether the order is 'outstanding' or not.
filter_order_outstanding
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def get_serializer(self, *args, **kwargs): """Return serializer for this endpoint with extra data as requested.""" try: params = self.request.query_params kwargs['part_detail'] = str2bool(params.get('part_detail', False)) kwargs['order_detail'] = str2bool(params.get(...
Return serializer for this endpoint with extra data as requested.
get_serializer
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def get_serializer_context(self): """Add the 'order' reference to the serializer context for any classes which inherit this mixin.""" ctx = super().get_serializer_context() ctx['request'] = self.request try: ctx['order'] = models.SalesOrder.objects.get(pk=self.kwargs.get('p...
Add the 'order' reference to the serializer context for any classes which inherit this mixin.
get_serializer_context
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_part(self, queryset, name, part): """Filter by the 'part' attribute. Note: - If "include_variants" is True, include all variants of the selected part - Otherwise, just filter by the selected part """ include_variants = str2bool(self.data.get('include_variants'...
Filter by the 'part' attribute. Note: - If "include_variants" is True, include all variants of the selected part - Otherwise, just filter by the selected part
filter_part
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_assigned_to_shipment(self, queryset, name, value): """Filter by whether or not the allocation has been assigned to a shipment.""" if str2bool(value): return queryset.exclude(shipment=None) return queryset.filter(shipment=None)
Filter by whether or not the allocation has been assigned to a shipment.
filter_assigned_to_shipment
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def get_queryset(self, *args, **kwargs): """Annotate the queryset for this endpoint.""" queryset = super().get_queryset(*args, **kwargs) queryset = queryset.prefetch_related( 'item', 'item__sales_order', 'item__part', 'line__part', 'it...
Annotate the queryset for this endpoint.
get_queryset
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def get_serializer(self, *args, **kwargs): """Return the serializer instance for this endpoint. Adds extra detail serializers if requested """ try: params = self.request.query_params kwargs['part_detail'] = str2bool(params.get('part_detail', False)) ...
Return the serializer instance for this endpoint. Adds extra detail serializers if requested
get_serializer
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_shipped(self, queryset, name, value): """Filter SalesOrder list by 'shipped' status (boolean).""" if str2bool(value): return queryset.exclude(shipment_date=None) return queryset.filter(shipment_date=None)
Filter SalesOrder list by 'shipped' status (boolean).
filter_shipped
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_delivered(self, queryset, name, value): """Filter SalesOrder list by 'delivered' status (boolean).""" if str2bool(value): return queryset.exclude(delivery_date=None) return queryset.filter(delivery_date=None)
Filter SalesOrder list by 'delivered' status (boolean).
filter_delivered
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def get_serializer_context(self): """Pass the request object to the serializer.""" ctx = super().get_serializer_context() ctx['request'] = self.request try: ctx['shipment'] = models.SalesOrderShipment.objects.get( pk=self.kwargs.get('pk', None) ) ...
Pass the request object to the serializer.
get_serializer_context
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def filter_part(self, queryset, name, part): """Filter by selected 'part'. Note: - If 'include_variants' is set to True, then all variants of the selected part will be included. - Otherwise, just filter by the selected part. """ include_variants = str2bool(self.data.get(...
Filter by selected 'part'. Note: - If 'include_variants' is set to True, then all variants of the selected part will be included. - Otherwise, just filter by the selected part.
filter_part
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT
def __call__(self, request, *args, **kwargs): """Overload call in order to check for authentication. This is required to force Django to look for the authentication, otherwise login request with Basic auth via curl or similar are ignored, and login via a calendar client will not work. ...
Overload call in order to check for authentication. This is required to force Django to look for the authentication, otherwise login request with Basic auth via curl or similar are ignored, and login via a calendar client will not work. See: https://stackoverflow.com/questions/...
__call__
python
inventree/InvenTree
src/backend/InvenTree/order/api.py
https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py
MIT