mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 03:25:42 +00:00
Add some helper magic for setting objects
- If the setting is defined as a "bool" then the returned value is automatically cast to a bool - Add some more unit testing
This commit is contained in:
@ -85,6 +85,13 @@ class InvenTreeSetting(models.Model):
|
||||
'validator': bool
|
||||
},
|
||||
|
||||
'PART_COMPONENT': {
|
||||
'name': _('Component'),
|
||||
'description': _('Parts can be used as sub-components by default'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
|
||||
'PART_PURCHASEABLE': {
|
||||
'name': _('Purchaseable'),
|
||||
'description': _('Parts are purchaseable by default'),
|
||||
@ -264,6 +271,11 @@ class InvenTreeSetting(models.Model):
|
||||
|
||||
if setting:
|
||||
value = setting.value
|
||||
|
||||
# If the particular setting is defined as a boolean, cast the value to a boolean
|
||||
if setting.is_bool():
|
||||
value = InvenTree.helpers.str2bool(value)
|
||||
|
||||
else:
|
||||
value = backup_value
|
||||
|
||||
|
Reference in New Issue
Block a user