mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix issues with circular imports
This commit is contained in:
parent
303db293b7
commit
95c5c4b575
@ -11,7 +11,7 @@ from django.core import validators
|
|||||||
from django import forms
|
from django import forms
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from InvenTree.helpers import normalize
|
import InvenTree.helpers
|
||||||
|
|
||||||
|
|
||||||
class InvenTreeURLFormField(FormURLField):
|
class InvenTreeURLFormField(FormURLField):
|
||||||
@ -55,7 +55,7 @@ class RoundingDecimalFormField(forms.DecimalField):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if type(value) == Decimal:
|
if type(value) == Decimal:
|
||||||
return normalize(value)
|
return InvenTree.helpers.normalize(value)
|
||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@ -15,7 +15,8 @@ from django.http import StreamingHttpResponse
|
|||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from .version import inventreeVersion, inventreeInstanceName
|
import InvenTree.version
|
||||||
|
|
||||||
from .settings import MEDIA_URL, STATIC_URL
|
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
|
data[object_name] = object_pk
|
||||||
else:
|
else:
|
||||||
data['tool'] = 'InvenTree'
|
data['tool'] = 'InvenTree'
|
||||||
data['version'] = inventreeVersion()
|
data['version'] = InvenTree.version.inventreeVersion()
|
||||||
data['instance'] = inventreeInstanceName()
|
data['instance'] = InvenTree.version.inventreeInstanceName()
|
||||||
|
|
||||||
# Ensure PK is included
|
# Ensure PK is included
|
||||||
object_data['id'] = object_pk
|
object_data['id'] = object_pk
|
||||||
|
@ -6,7 +6,7 @@ from django.conf import settings
|
|||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from common.models import InvenTreeSetting
|
import common.models
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ def validate_part_name(value):
|
|||||||
def validate_part_ipn(value):
|
def validate_part_ipn(value):
|
||||||
""" Validate the Part IPN against regex rule """
|
""" 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:
|
if pattern:
|
||||||
match = re.search(pattern, value)
|
match = re.search(pattern, value)
|
||||||
|
@ -3,15 +3,16 @@ Provides information on the current InvenTree version
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
from common.models import InvenTreeSetting
|
|
||||||
import django
|
import django
|
||||||
|
|
||||||
|
import common.models
|
||||||
|
|
||||||
INVENTREE_SW_VERSION = "0.1.3 pre"
|
INVENTREE_SW_VERSION = "0.1.3 pre"
|
||||||
|
|
||||||
|
|
||||||
def inventreeInstanceName():
|
def inventreeInstanceName():
|
||||||
""" Returns the InstanceName settings for the current database """
|
""" Returns the InstanceName settings for the current database """
|
||||||
return InvenTreeSetting.get_setting("InstanceName", "")
|
return common.modelsInvenTreeSetting.get_setting("InstanceName", "")
|
||||||
|
|
||||||
|
|
||||||
def inventreeVersion():
|
def inventreeVersion():
|
||||||
|
@ -22,8 +22,8 @@ from markdownx.models import MarkdownxField
|
|||||||
from mptt.models import MPTTModel, TreeForeignKey
|
from mptt.models import MPTTModel, TreeForeignKey
|
||||||
|
|
||||||
from InvenTree.status_codes import BuildStatus
|
from InvenTree.status_codes import BuildStatus
|
||||||
from InvenTree.fields import InvenTreeURLField
|
|
||||||
from InvenTree.helpers import decimal2string
|
from InvenTree.helpers import decimal2string
|
||||||
|
import InvenTree.fields
|
||||||
|
|
||||||
from stock import models as StockModels
|
from stock import models as StockModels
|
||||||
from part import models as PartModels
|
from part import models as PartModels
|
||||||
@ -151,7 +151,7 @@ class Build(MPTTModel):
|
|||||||
related_name='builds_completed'
|
related_name='builds_completed'
|
||||||
)
|
)
|
||||||
|
|
||||||
link = InvenTreeURLField(
|
link = InvenTree.fields.InvenTreeURLField(
|
||||||
verbose_name=_('External Link'),
|
verbose_name=_('External Link'),
|
||||||
blank=True, help_text=_('Link to external URL')
|
blank=True, help_text=_('Link to external URL')
|
||||||
)
|
)
|
||||||
|
@ -14,6 +14,8 @@ from django.utils.translation import ugettext as _
|
|||||||
from django.core.validators import MinValueValidator, MaxValueValidator
|
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
|
import InvenTree.fields
|
||||||
|
|
||||||
|
|
||||||
class InvenTreeSetting(models.Model):
|
class InvenTreeSetting(models.Model):
|
||||||
"""
|
"""
|
||||||
@ -159,6 +161,19 @@ class Currency(models.Model):
|
|||||||
super().save(*args, **kwargs)
|
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):
|
class ColorTheme(models.Model):
|
||||||
""" Color Theme Setting """
|
""" Color Theme Setting """
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user