2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 04:25:42 +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

@ -27,6 +27,7 @@ from build.validators import generate_next_build_reference, validate_build_order
import InvenTree.fields
import InvenTree.helpers
import InvenTree.helpers_model
import InvenTree.models
import InvenTree.ready
import InvenTree.tasks
@ -539,7 +540,7 @@ class Build(MPTTModel, InvenTree.models.InvenTreeBarcodeMixin, InvenTree.models.
'name': name,
'slug': 'build.completed',
'message': _('A build order has been completed'),
'link': InvenTree.helpers.construct_absolute_url(self.get_absolute_url()),
'link': InvenTree.helpers_model.construct_absolute_url(self.get_absolute_url()),
'template': {
'html': 'email/build_order_completed.html',
'subject': name,
@ -1210,7 +1211,7 @@ def after_save_build(sender, instance: Build, created: bool, **kwargs):
InvenTree.tasks.offload_task(build_tasks.check_build_stock, instance)
# Notify the responsible users that the build order has been created
InvenTree.helpers.notify_responsible(instance, sender, exclude=instance.issued_by)
InvenTree.helpers_model.notify_responsible(instance, sender, exclude=instance.issued_by)
class BuildOrderAttachment(InvenTree.models.InvenTreeAttachment):

View File

@ -13,7 +13,7 @@ from plugin.events import trigger_event
import common.notifications
import build.models
import InvenTree.email
import InvenTree.helpers
import InvenTree.helpers_model
import InvenTree.tasks
from InvenTree.status_codes import BuildStatus
from InvenTree.ready import isImportingData
@ -65,7 +65,7 @@ def check_build_stock(build: build.models.Build):
# There is not sufficient stock for this part
lines.append({
'link': InvenTree.helpers.construct_absolute_url(sub_part.get_absolute_url()),
'link': InvenTree.helpers_model.construct_absolute_url(sub_part.get_absolute_url()),
'part': sub_part,
'in_stock': in_stock,
'allocated': allocated,
@ -89,7 +89,7 @@ def check_build_stock(build: build.models.Build):
logger.info(f"Notifying users of stock required for build {build.pk}")
context = {
'link': InvenTree.helpers.construct_absolute_url(build.get_absolute_url()),
'link': InvenTree.helpers_model.construct_absolute_url(build.get_absolute_url()),
'build': build,
'part': build.part,
'lines': lines,
@ -122,7 +122,7 @@ def notify_overdue_build_order(bo: build.models.Build):
'order': bo,
'name': name,
'message': _(f"Build order {bo} is now overdue"),
'link': InvenTree.helpers.construct_absolute_url(
'link': InvenTree.helpers_model.construct_absolute_url(
bo.get_absolute_url(),
),
'template': {