2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

Refactor model helpers into own file (#4927)

* Refactor model helpers into own file to allow helper import when apps not loaded yet

* Import helper functions at module level

* Added missing imports where vscode couldnt help because its no explicit import
This commit is contained in:
Lukas
2023-05-31 01:18:42 +02:00
committed by GitHub
parent a196f443a1
commit 99d122baa9
20 changed files with 343 additions and 316 deletions

View File

@ -19,8 +19,8 @@ from company.models import SupplierPart
from InvenTree.api import (APIDownloadMixin, AttachmentMixin,
ListCreateDestroyAPIView, MetadataView, StatusView)
from InvenTree.filters import SEARCH_ORDER_FILTER, SEARCH_ORDER_FILTER_ALIAS
from InvenTree.helpers import (DownloadFile, construct_absolute_url,
get_base_url, str2bool)
from InvenTree.helpers import DownloadFile, str2bool
from InvenTree.helpers_model import construct_absolute_url, get_base_url
from InvenTree.mixins import (CreateAPI, ListAPI, ListCreateAPI,
RetrieveUpdateDestroyAPI)
from InvenTree.status_codes import (PurchaseOrderStatus, ReturnOrderLineStatus,

View File

@ -36,7 +36,8 @@ from company.models import Company, Contact, SupplierPart
from InvenTree.exceptions import log_error
from InvenTree.fields import (InvenTreeModelMoneyField, InvenTreeURLField,
RoundingDecimalField)
from InvenTree.helpers import decimal2string, getSetting, notify_responsible
from InvenTree.helpers import decimal2string
from InvenTree.helpers_model import getSetting, notify_responsible
from InvenTree.models import (InvenTreeAttachment, InvenTreeBarcodeMixin,
InvenTreeNotesMixin, MetadataMixin,
ReferenceIndexingMixin)

View File

@ -5,7 +5,7 @@ from datetime import datetime, timedelta
from django.utils.translation import gettext_lazy as _
import common.notifications
import InvenTree.helpers
import InvenTree.helpers_model
import order.models
from InvenTree.status_codes import PurchaseOrderStatus, SalesOrderStatus
from InvenTree.tasks import ScheduledTask, scheduled_task
@ -29,7 +29,7 @@ def notify_overdue_purchase_order(po: order.models.PurchaseOrder):
'order': po,
'name': name,
'message': _(f'Purchase order {po} is now overdue'),
'link': InvenTree.helpers.construct_absolute_url(
'link': InvenTree.helpers_model.construct_absolute_url(
po.get_absolute_url(),
),
'template': {
@ -92,7 +92,7 @@ def notify_overdue_sales_order(so: order.models.SalesOrder):
'order': so,
'name': name,
'message': _(f"Sales order {so} is now overdue"),
'link': InvenTree.helpers.construct_absolute_url(
'link': InvenTree.helpers_model.construct_absolute_url(
so.get_absolute_url(),
),
'template': {