Fix issues with circular imports

This commit is contained in:
Oliver Walters 2020-09-17 22:44:17 +10:00
parent 303db293b7
commit 95c5c4b575
7 changed files with 36 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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():

View File

@ -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')
)

View File

@ -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 """

View File

@ -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):
"""