Merge pull request #633 from SchrodingersGat/inventree-settings

Inventree settings
This commit is contained in:
Oliver 2020-02-03 21:33:34 +11:00 committed by GitHub
commit 0939ffeb76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 330 additions and 80 deletions

View File

@ -6,6 +6,10 @@ from django.conf import settings
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _
from common.models import InvenTreeSetting
import re
def allowable_url_schemes():
""" Return the list of allowable URL schemes.
@ -36,6 +40,18 @@ def validate_part_name(value):
)
def validate_part_ipn(value):
""" Validate the Part IPN against regex rule """
pattern = InvenTreeSetting.get_setting('part_ipn_regex')
if pattern:
match = re.search(pattern, value)
if match is None:
raise ValidationError(_('IPN must match regex pattern') + " '{pat}'".format(pat=pattern))
def validate_tree_name(value):
""" Prevent illegal characters in tree item names """

View File

@ -1,5 +1,48 @@
from django.apps import AppConfig
from django.db.utils import OperationalError
import os
import yaml
class CommonConfig(AppConfig):
name = 'common'
def ready(self):
""" Will be called when the Common app is first loaded """
self.populate_default_settings()
def populate_default_settings(self):
""" Populate the default values for InvenTree key:value pairs.
If a setting does not exist, it will be created.
"""
from .models import InvenTreeSetting
here = os.path.dirname(os.path.abspath(__file__))
settings_file = os.path.join(here, 'kvp.yaml')
with open(settings_file) as kvp:
values = yaml.safe_load(kvp)
for value in values:
key = value['key']
default = value['default']
description = value['description']
try:
# If a particular setting does not exist in the database, create it now
if not InvenTreeSetting.objects.filter(key=key).exists():
setting = InvenTreeSetting(
key=key,
value=default,
description=description
)
setting.save()
print("Creating new key: '{k}' = '{v}'".format(k=key, v=default))
except OperationalError:
# Migrations have not yet been applied - table does not exist
break

13
InvenTree/common/kvp.yaml Normal file
View File

@ -0,0 +1,13 @@
# This file contains the default values for the key:value settings available in InvenTree
# This file should not be edited locally.
# Note: The description strings provided here will be translatable,
# so ensure that any translations are provided as appropriate.
- key: 'part_ipn_regex'
default: ''
description: 'Format string for internal part number'
- key: part_deep_copy
default: True
description: 'Parts are deep-copied by default'

View File

@ -0,0 +1,17 @@
# Generated by Django 2.2.9 on 2020-02-03 09:51
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('common', '0005_auto_20190915_1256'),
]
operations = [
migrations.AlterModelOptions(
name='inventreesetting',
options={'verbose_name': 'InvenTree Setting', 'verbose_name_plural': 'InvenTree Settings'},
),
]

View File

@ -21,6 +21,10 @@ class InvenTreeSetting(models.Model):
even if that key does not exist.
"""
class Meta:
verbose_name = "InvenTree Setting"
verbose_name_plural = "InvenTree Settings"
@classmethod
def get_setting(cls, key, backup_value=None):
"""

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-02 10:40+0000\n"
"POT-Creation-Date: 2020-02-03 10:28+0000\n"
"PO-Revision-Date: 2020-02-02 08:07+0100\n"
"Last-Translator: Christian Schlüter <chschlue@gmail.com>\n"
"Language-Team: C <kde-i18n-doc@kde.org>\n"
@ -109,27 +109,35 @@ msgstr "Zerstört"
msgid "Allocated"
msgstr "Zugeordnet"
#: InvenTree/validators.py:35
#: InvenTree/validators.py:39
msgid "Invalid character in part name"
msgstr "Ungültiger Buchstabe im Teilenamen"
#: InvenTree/validators.py:44
#: InvenTree/validators.py:52
msgid "IPN must match regex pattern"
msgstr ""
#: InvenTree/validators.py:60
#, python-brace-format
msgid "Illegal character in name ({x})"
msgstr "Ungültiges Zeichen im Namen ({x})"
#: InvenTree/validators.py:63 InvenTree/validators.py:79
#: InvenTree/validators.py:79 InvenTree/validators.py:95
msgid "Overage value must not be negative"
msgstr "Überschuss-Wert darf nicht negativ sein"
#: InvenTree/validators.py:81
#: InvenTree/validators.py:97
msgid "Overage must not exceed 100%"
msgstr "Überschuss darf 100% nicht überschreiten"
#: InvenTree/validators.py:88
#: InvenTree/validators.py:104
msgid "Overage must be an integer value or a percentage"
msgstr "Überschuss muss eine Ganzzahl oder ein Prozentwert sein"
#: InvenTree/views.py:548
msgid "Database Statistics"
msgstr ""
#: build/forms.py:35
msgid "Confirm"
msgstr "Bestätigen"
@ -356,41 +364,41 @@ msgstr "Teile zuweisen"
msgid "The following serial numbers already exist: ({sn})"
msgstr "Die folgende Seriennummer existiert bereits: ({sn})"
#: common/models.py:65
#: common/models.py:69
msgid "Settings key (must be unique - case insensitive"
msgstr ""
"Einstellungs-Schlüssel (muss einzigartig sein, Groß-/ Kleinschreibung wird "
"nicht beachtet)"
#: common/models.py:67
#: common/models.py:71
msgid "Settings value"
msgstr "Einstellungs-Wert"
#: common/models.py:69
#: common/models.py:73
msgid "Settings description"
msgstr "Einstellungs-Beschreibung"
#: common/models.py:82
#: common/models.py:86
msgid "Key string must be unique"
msgstr "Schlüsseltext muss eindeutig sein"
#: common/models.py:103
#: common/models.py:107
msgid "Currency Symbol e.g. $"
msgstr "Währungs-Symbol (z.B. €)"
#: common/models.py:105
#: common/models.py:109
msgid "Currency Suffix e.g. AUD"
msgstr "Währungs-Suffix (z.B. EUR)"
#: common/models.py:107
#: common/models.py:111
msgid "Currency Description"
msgstr "Währungs-Beschreibung"
#: common/models.py:109
#: common/models.py:113
msgid "Currency Value"
msgstr "Währungs-Wert"
#: common/models.py:111
#: common/models.py:115
msgid "Use this currency as the base currency"
msgstr "Benutze diese Währung als Basis-Währung"
@ -582,7 +590,8 @@ msgstr ""
#: company/templates/company/index.html:69
#: company/templates/company/partdetail.html:6
#: part/templates/part/category.html:73
#: part/templates/part/category.html:73 templates/navbar.html:10
#: templates/stats.html:7 templates/stats.html:10
msgid "Parts"
msgstr "Teile"
@ -657,6 +666,7 @@ msgid "No price breaks have been added for this part"
msgstr ""
#: company/templates/company/tabs.html:12 part/templates/part/tabs.html:17
#: templates/navbar.html:11
msgid "Stock"
msgstr "Lagerbestand"
@ -696,7 +706,7 @@ msgstr "Link auf externe Seite"
msgid "Order notes"
msgstr "Bestell-Notizen"
#: order/models.py:159 order/models.py:210 part/views.py:1065
#: order/models.py:159 order/models.py:210 part/views.py:1067
#: stock/models.py:440
msgid "Quantity must be greater than zero"
msgstr "Anzahl muss größer Null sein"
@ -1062,6 +1072,7 @@ msgid "Delete attachment"
msgstr "Anhang löschen"
#: part/templates/part/category.html:13 part/templates/part/category.html:69
#: templates/stats.html:14
msgid "Part Categories"
msgstr "Teile-Kategorien"
@ -1246,6 +1257,7 @@ msgid "BOM"
msgstr "Stückliste"
#: part/templates/part/tabs.html:28 stock/templates/stock/item_base.html:102
#: templates/navbar.html:12
msgid "Build"
msgstr "Bau"
@ -1253,7 +1265,7 @@ msgstr "Bau"
msgid "Used In"
msgstr "Benutzt in"
#: part/templates/part/tabs.html:37
#: part/templates/part/tabs.html:37 templates/navbar.html:13
msgid "Suppliers"
msgstr "Zulieferer"
@ -1270,27 +1282,27 @@ msgstr "Anhänge"
msgid "Set category for {n} parts"
msgstr "Kategorie für {n} Teile setzen"
#: part/views.py:806
#: part/views.py:808
msgid "No BOM file provided"
msgstr "Keine Stückliste angegeben"
#: part/views.py:1067
#: part/views.py:1069
msgid "Enter a valid quantity"
msgstr "Bitte eine gültige Anzahl eingeben"
#: part/views.py:1091 part/views.py:1094
#: part/views.py:1093 part/views.py:1096
msgid "Select valid part"
msgstr "Bitte ein gültiges Teil auswählen"
#: part/views.py:1100
#: part/views.py:1102
msgid "Duplicate part selected"
msgstr "Teil doppelt ausgewählt"
#: part/views.py:1128
#: part/views.py:1130
msgid "Select a part"
msgstr "Teil auswählen"
#: part/views.py:1132
#: part/views.py:1134
msgid "Specify quantity"
msgstr "Anzahl angeben"
@ -1504,7 +1516,8 @@ msgid "Sublocations"
msgstr "Sub-Standorte"
#: stock/templates/stock/location.html:52
#: stock/templates/stock/location.html:64
#: stock/templates/stock/location.html:64 templates/stats.html:18
#: templates/stats.html:21
msgid "Stock Items"
msgstr "Lagerobjekte"
@ -1513,7 +1526,7 @@ msgid "Stock Details"
msgstr "Objekt-Details"
#: stock/templates/stock/location.html:60
#: templates/InvenTree/search_stock_location.html:6
#: templates/InvenTree/search_stock_location.html:6 templates/stats.html:25
msgid "Stock Locations"
msgstr "Lagerobjekt-Standorte"
@ -1696,3 +1709,37 @@ msgstr "InvenTree-Dokumentation"
#: templates/about.html:37
msgid "View Code on GitHub"
msgstr "Code auf GitHub ansehen"
#: templates/navbar.html:14
#, fuzzy
#| msgid "On Order"
msgid "Orders"
msgstr "bestellt"
#: templates/navbar.html:23
msgid "Admin"
msgstr ""
#: templates/navbar.html:26
#, fuzzy
#| msgid "Settings value"
msgid "Settings"
msgstr "Einstellungs-Wert"
#: templates/navbar.html:27
msgid "Logout"
msgstr ""
#: templates/navbar.html:29
msgid "Login"
msgstr ""
#: templates/navbar.html:32
msgid "About InvenTree"
msgstr ""
#: templates/navbar.html:33
#, fuzzy
#| msgid "Status"
msgid "Statistics"
msgstr "Status"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-02 10:40+0000\n"
"POT-Creation-Date: 2020-02-03 10:28+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -108,27 +108,35 @@ msgstr ""
msgid "Allocated"
msgstr ""
#: InvenTree/validators.py:35
#: InvenTree/validators.py:39
msgid "Invalid character in part name"
msgstr ""
#: InvenTree/validators.py:44
#: InvenTree/validators.py:52
msgid "IPN must match regex pattern"
msgstr ""
#: InvenTree/validators.py:60
#, python-brace-format
msgid "Illegal character in name ({x})"
msgstr ""
#: InvenTree/validators.py:63 InvenTree/validators.py:79
#: InvenTree/validators.py:79 InvenTree/validators.py:95
msgid "Overage value must not be negative"
msgstr ""
#: InvenTree/validators.py:81
#: InvenTree/validators.py:97
msgid "Overage must not exceed 100%"
msgstr ""
#: InvenTree/validators.py:88
#: InvenTree/validators.py:104
msgid "Overage must be an integer value or a percentage"
msgstr ""
#: InvenTree/views.py:548
msgid "Database Statistics"
msgstr ""
#: build/forms.py:35
msgid "Confirm"
msgstr ""
@ -352,39 +360,39 @@ msgstr ""
msgid "The following serial numbers already exist: ({sn})"
msgstr ""
#: common/models.py:65
#: common/models.py:69
msgid "Settings key (must be unique - case insensitive"
msgstr ""
#: common/models.py:67
#: common/models.py:71
msgid "Settings value"
msgstr ""
#: common/models.py:69
#: common/models.py:73
msgid "Settings description"
msgstr ""
#: common/models.py:82
#: common/models.py:86
msgid "Key string must be unique"
msgstr ""
#: common/models.py:103
#: common/models.py:107
msgid "Currency Symbol e.g. $"
msgstr ""
#: common/models.py:105
#: common/models.py:109
msgid "Currency Suffix e.g. AUD"
msgstr ""
#: common/models.py:107
#: common/models.py:111
msgid "Currency Description"
msgstr ""
#: common/models.py:109
#: common/models.py:113
msgid "Currency Value"
msgstr ""
#: common/models.py:111
#: common/models.py:115
msgid "Use this currency as the base currency"
msgstr ""
@ -562,7 +570,8 @@ msgstr ""
#: company/templates/company/index.html:69
#: company/templates/company/partdetail.html:6
#: part/templates/part/category.html:73
#: part/templates/part/category.html:73 templates/navbar.html:10
#: templates/stats.html:7 templates/stats.html:10
msgid "Parts"
msgstr ""
@ -626,6 +635,7 @@ msgid "No price breaks have been added for this part"
msgstr ""
#: company/templates/company/tabs.html:12 part/templates/part/tabs.html:17
#: templates/navbar.html:11
msgid "Stock"
msgstr ""
@ -665,7 +675,7 @@ msgstr ""
msgid "Order notes"
msgstr ""
#: order/models.py:159 order/models.py:210 part/views.py:1065
#: order/models.py:159 order/models.py:210 part/views.py:1067
#: stock/models.py:440
msgid "Quantity must be greater than zero"
msgstr ""
@ -1027,6 +1037,7 @@ msgid "Delete attachment"
msgstr ""
#: part/templates/part/category.html:13 part/templates/part/category.html:69
#: templates/stats.html:14
msgid "Part Categories"
msgstr ""
@ -1211,6 +1222,7 @@ msgid "BOM"
msgstr ""
#: part/templates/part/tabs.html:28 stock/templates/stock/item_base.html:102
#: templates/navbar.html:12
msgid "Build"
msgstr ""
@ -1218,7 +1230,7 @@ msgstr ""
msgid "Used In"
msgstr ""
#: part/templates/part/tabs.html:37
#: part/templates/part/tabs.html:37 templates/navbar.html:13
msgid "Suppliers"
msgstr ""
@ -1235,27 +1247,27 @@ msgstr ""
msgid "Set category for {n} parts"
msgstr ""
#: part/views.py:806
#: part/views.py:808
msgid "No BOM file provided"
msgstr ""
#: part/views.py:1067
#: part/views.py:1069
msgid "Enter a valid quantity"
msgstr ""
#: part/views.py:1091 part/views.py:1094
#: part/views.py:1093 part/views.py:1096
msgid "Select valid part"
msgstr ""
#: part/views.py:1100
#: part/views.py:1102
msgid "Duplicate part selected"
msgstr ""
#: part/views.py:1128
#: part/views.py:1130
msgid "Select a part"
msgstr ""
#: part/views.py:1132
#: part/views.py:1134
msgid "Specify quantity"
msgstr ""
@ -1462,7 +1474,8 @@ msgid "Sublocations"
msgstr ""
#: stock/templates/stock/location.html:52
#: stock/templates/stock/location.html:64
#: stock/templates/stock/location.html:64 templates/stats.html:18
#: templates/stats.html:21
msgid "Stock Items"
msgstr ""
@ -1471,7 +1484,7 @@ msgid "Stock Details"
msgstr ""
#: stock/templates/stock/location.html:60
#: templates/InvenTree/search_stock_location.html:6
#: templates/InvenTree/search_stock_location.html:6 templates/stats.html:25
msgid "Stock Locations"
msgstr ""
@ -1652,3 +1665,31 @@ msgstr ""
#: templates/about.html:37
msgid "View Code on GitHub"
msgstr ""
#: templates/navbar.html:14
msgid "Orders"
msgstr ""
#: templates/navbar.html:23
msgid "Admin"
msgstr ""
#: templates/navbar.html:26
msgid "Settings"
msgstr ""
#: templates/navbar.html:27
msgid "Logout"
msgstr ""
#: templates/navbar.html:29
msgid "Login"
msgstr ""
#: templates/navbar.html:32
msgid "About InvenTree"
msgstr ""
#: templates/navbar.html:33
msgid "Statistics"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-02 10:40+0000\n"
"POT-Creation-Date: 2020-02-03 10:28+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -108,27 +108,35 @@ msgstr ""
msgid "Allocated"
msgstr ""
#: InvenTree/validators.py:35
#: InvenTree/validators.py:39
msgid "Invalid character in part name"
msgstr ""
#: InvenTree/validators.py:44
#: InvenTree/validators.py:52
msgid "IPN must match regex pattern"
msgstr ""
#: InvenTree/validators.py:60
#, python-brace-format
msgid "Illegal character in name ({x})"
msgstr ""
#: InvenTree/validators.py:63 InvenTree/validators.py:79
#: InvenTree/validators.py:79 InvenTree/validators.py:95
msgid "Overage value must not be negative"
msgstr ""
#: InvenTree/validators.py:81
#: InvenTree/validators.py:97
msgid "Overage must not exceed 100%"
msgstr ""
#: InvenTree/validators.py:88
#: InvenTree/validators.py:104
msgid "Overage must be an integer value or a percentage"
msgstr ""
#: InvenTree/views.py:548
msgid "Database Statistics"
msgstr ""
#: build/forms.py:35
msgid "Confirm"
msgstr ""
@ -352,39 +360,39 @@ msgstr ""
msgid "The following serial numbers already exist: ({sn})"
msgstr ""
#: common/models.py:65
#: common/models.py:69
msgid "Settings key (must be unique - case insensitive"
msgstr ""
#: common/models.py:67
#: common/models.py:71
msgid "Settings value"
msgstr ""
#: common/models.py:69
#: common/models.py:73
msgid "Settings description"
msgstr ""
#: common/models.py:82
#: common/models.py:86
msgid "Key string must be unique"
msgstr ""
#: common/models.py:103
#: common/models.py:107
msgid "Currency Symbol e.g. $"
msgstr ""
#: common/models.py:105
#: common/models.py:109
msgid "Currency Suffix e.g. AUD"
msgstr ""
#: common/models.py:107
#: common/models.py:111
msgid "Currency Description"
msgstr ""
#: common/models.py:109
#: common/models.py:113
msgid "Currency Value"
msgstr ""
#: common/models.py:111
#: common/models.py:115
msgid "Use this currency as the base currency"
msgstr ""
@ -562,7 +570,8 @@ msgstr ""
#: company/templates/company/index.html:69
#: company/templates/company/partdetail.html:6
#: part/templates/part/category.html:73
#: part/templates/part/category.html:73 templates/navbar.html:10
#: templates/stats.html:7 templates/stats.html:10
msgid "Parts"
msgstr ""
@ -626,6 +635,7 @@ msgid "No price breaks have been added for this part"
msgstr ""
#: company/templates/company/tabs.html:12 part/templates/part/tabs.html:17
#: templates/navbar.html:11
msgid "Stock"
msgstr ""
@ -665,7 +675,7 @@ msgstr ""
msgid "Order notes"
msgstr ""
#: order/models.py:159 order/models.py:210 part/views.py:1065
#: order/models.py:159 order/models.py:210 part/views.py:1067
#: stock/models.py:440
msgid "Quantity must be greater than zero"
msgstr ""
@ -1027,6 +1037,7 @@ msgid "Delete attachment"
msgstr ""
#: part/templates/part/category.html:13 part/templates/part/category.html:69
#: templates/stats.html:14
msgid "Part Categories"
msgstr ""
@ -1211,6 +1222,7 @@ msgid "BOM"
msgstr ""
#: part/templates/part/tabs.html:28 stock/templates/stock/item_base.html:102
#: templates/navbar.html:12
msgid "Build"
msgstr ""
@ -1218,7 +1230,7 @@ msgstr ""
msgid "Used In"
msgstr ""
#: part/templates/part/tabs.html:37
#: part/templates/part/tabs.html:37 templates/navbar.html:13
msgid "Suppliers"
msgstr ""
@ -1235,27 +1247,27 @@ msgstr ""
msgid "Set category for {n} parts"
msgstr ""
#: part/views.py:806
#: part/views.py:808
msgid "No BOM file provided"
msgstr ""
#: part/views.py:1067
#: part/views.py:1069
msgid "Enter a valid quantity"
msgstr ""
#: part/views.py:1091 part/views.py:1094
#: part/views.py:1093 part/views.py:1096
msgid "Select valid part"
msgstr ""
#: part/views.py:1100
#: part/views.py:1102
msgid "Duplicate part selected"
msgstr ""
#: part/views.py:1128
#: part/views.py:1130
msgid "Select a part"
msgstr ""
#: part/views.py:1132
#: part/views.py:1134
msgid "Specify quantity"
msgstr ""
@ -1462,7 +1474,8 @@ msgid "Sublocations"
msgstr ""
#: stock/templates/stock/location.html:52
#: stock/templates/stock/location.html:64
#: stock/templates/stock/location.html:64 templates/stats.html:18
#: templates/stats.html:21
msgid "Stock Items"
msgstr ""
@ -1471,7 +1484,7 @@ msgid "Stock Details"
msgstr ""
#: stock/templates/stock/location.html:60
#: templates/InvenTree/search_stock_location.html:6
#: templates/InvenTree/search_stock_location.html:6 templates/stats.html:25
msgid "Stock Locations"
msgstr ""
@ -1652,3 +1665,31 @@ msgstr ""
#: templates/about.html:37
msgid "View Code on GitHub"
msgstr ""
#: templates/navbar.html:14
msgid "Orders"
msgstr ""
#: templates/navbar.html:23
msgid "Admin"
msgstr ""
#: templates/navbar.html:26
msgid "Settings"
msgstr ""
#: templates/navbar.html:27
msgid "Logout"
msgstr ""
#: templates/navbar.html:29
msgid "Login"
msgstr ""
#: templates/navbar.html:32
msgid "About InvenTree"
msgstr ""
#: templates/navbar.html:33
msgid "Statistics"
msgstr ""

View File

@ -0,0 +1,19 @@
# Generated by Django 2.2.9 on 2020-02-03 10:07
import InvenTree.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('part', '0027_auto_20200202_1024'),
]
operations = [
migrations.AlterField(
model_name='part',
name='IPN',
field=models.CharField(blank=True, help_text='Internal Part Number', max_length=100, validators=[InvenTree.validators.validate_part_ipn]),
),
]

View File

@ -349,7 +349,7 @@ class Part(models.Model):
on_delete=models.DO_NOTHING,
help_text=_('Part category'))
IPN = models.CharField(max_length=100, blank=True, help_text=_('Internal Part Number'))
IPN = models.CharField(max_length=100, blank=True, help_text=_('Internal Part Number'), validators=[validators.validate_part_ipn])
revision = models.CharField(max_length=100, blank=True, help_text=_('Part revision or version number'))

View File

@ -6,6 +6,8 @@ from django import template
from InvenTree import version
from InvenTree.helpers import decimal2string
from common.models import InvenTreeSetting
register = template.Library()
@ -69,3 +71,8 @@ def inventree_github_url(*args, **kwargs):
def inventree_docs_url(*args, **kwargs):
""" Return URL for InvenTree documenation site """
return "https://inventree.github.io"
@register.simple_tag()
def inventree_setting(key, *args, **kwargs):
return InvenTreeSetting.get_setting(key)

View File

@ -23,7 +23,7 @@ from .models import PartParameterTemplate, PartParameter
from .models import BomItem
from .models import match_part_names
from common.models import Currency
from common.models import Currency, InvenTreeSetting
from company.models import SupplierPart
from . import forms as part_forms
@ -396,6 +396,8 @@ class PartDuplicate(AjaxCreateView):
else:
initials = super(AjaxCreateView, self).get_initial()
initials['deep_copy'] = str2bool(InvenTreeSetting.get_setting('part_deep_copy', True))
return initials