diff --git a/InvenTree/InvenTree/fields.py b/InvenTree/InvenTree/fields.py index ba3648da30..884bd0c49f 100644 --- a/InvenTree/InvenTree/fields.py +++ b/InvenTree/InvenTree/fields.py @@ -11,7 +11,7 @@ from django.core import validators from django import forms from decimal import Decimal -from InvenTree.helpers import normalize +import InvenTree.helpers class InvenTreeURLFormField(FormURLField): @@ -55,7 +55,7 @@ class RoundingDecimalFormField(forms.DecimalField): """ if type(value) == Decimal: - return normalize(value) + return InvenTree.helpers.normalize(value) else: return value diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index 4ec84c7912..9b470902b1 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -15,7 +15,8 @@ from django.http import StreamingHttpResponse from django.core.exceptions import ValidationError from django.utils.translation import ugettext as _ -from .version import inventreeVersion, inventreeInstanceName +import InvenTree.version + from .settings import MEDIA_URL, STATIC_URL @@ -263,8 +264,8 @@ def MakeBarcode(object_name, object_pk, object_data, **kwargs): data[object_name] = object_pk else: data['tool'] = 'InvenTree' - data['version'] = inventreeVersion() - data['instance'] = inventreeInstanceName() + data['version'] = InvenTree.version.inventreeVersion() + data['instance'] = InvenTree.version.inventreeInstanceName() # Ensure PK is included object_data['id'] = object_pk diff --git a/InvenTree/InvenTree/validators.py b/InvenTree/InvenTree/validators.py index b1e455283b..548bce12ab 100644 --- a/InvenTree/InvenTree/validators.py +++ b/InvenTree/InvenTree/validators.py @@ -6,7 +6,7 @@ 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 common.models import re @@ -43,7 +43,7 @@ def validate_part_name(value): def validate_part_ipn(value): """ Validate the Part IPN against regex rule """ - pattern = InvenTreeSetting.get_setting('part_ipn_regex') + pattern = common.models.InvenTreeSetting.get_setting('part_ipn_regex') if pattern: match = re.search(pattern, value) diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index e000f40076..4aac01c8df 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -3,15 +3,16 @@ Provides information on the current InvenTree version """ import subprocess -from common.models import InvenTreeSetting import django +import common.models + INVENTREE_SW_VERSION = "0.1.3 pre" def inventreeInstanceName(): """ Returns the InstanceName settings for the current database """ - return InvenTreeSetting.get_setting("InstanceName", "") + return common.modelsInvenTreeSetting.get_setting("InstanceName", "") def inventreeVersion(): diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 89e79761e8..35870adde4 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -22,8 +22,8 @@ from markdownx.models import MarkdownxField from mptt.models import MPTTModel, TreeForeignKey from InvenTree.status_codes import BuildStatus -from InvenTree.fields import InvenTreeURLField from InvenTree.helpers import decimal2string +import InvenTree.fields from stock import models as StockModels from part import models as PartModels @@ -151,7 +151,7 @@ class Build(MPTTModel): related_name='builds_completed' ) - link = InvenTreeURLField( + link = InvenTree.fields.InvenTreeURLField( verbose_name=_('External Link'), blank=True, help_text=_('Link to external URL') ) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index b8e9959f01..774bba2443 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -14,6 +14,8 @@ from django.utils.translation import ugettext as _ from django.core.validators import MinValueValidator, MaxValueValidator from django.core.exceptions import ValidationError +import InvenTree.fields + class InvenTreeSetting(models.Model): """ @@ -159,6 +161,19 @@ class Currency(models.Model): super().save(*args, **kwargs) +class PriceBreak(models.Model): + + class Meta: + abstract = True + + quantity = InvenTree.fields.RoundingDecimalField(max_digits=15, decimal_places=5, default=1, validators=[MinValueValidator(1)]) + + cost = InvenTree.fields.RoundingDecimalField(max_digits=10, decimal_places=5, validators=[MinValueValidator(0)]) + + currency = models.ForeignKey(Currency, blank=True, null=True, on_delete=models.SET_NULL) + + + class ColorTheme(models.Model): """ Color Theme Setting """ diff --git a/tasks.py b/tasks.py index 51c5a68849..cbf9d1722c 100644 --- a/tasks.py +++ b/tasks.py @@ -108,6 +108,14 @@ def superuser(c): manage(c, 'createsuperuser', pty=True) +@task +def check(c): + """ + Check validity of django codebase + """ + + manage(c, "check") + @task def migrate(c): """