mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-01 17:51:23 +00:00
Add "updated_at" field to Orders model (#11374)
* add "updated_at" field to PurchaseOrder model * change to use abstract po instead * add api filters * add show, order and filter by po updated_at date to frontend * add tests and increment api_version * change updated_at to null by default * never trust github conflict resolution * bump docker image to python 3.14 (#11414) * chore(deps): bump the dependencies group across 1 directory with 4 updates (#11416) Bumps the dependencies group with 4 updates in the / directory: [depot/setup-action](https://github.com/depot/setup-action), [depot/build-push-action](https://github.com/depot/build-push-action), [anchore/sbom-action](https://github.com/anchore/sbom-action) and [actions/stale](https://github.com/actions/stale). Updates `depot/setup-action` from 1.6.0 to 1.7.1 - [Release notes](https://github.com/depot/setup-action/releases) - [Commits](https://github.com/depot/setup-action/compare/b0b1ea4f69e92ebf5dea3f8713a1b0c37b2126a5...15c09a5f77a0840ad4bce955686522a257853461) Updates `depot/build-push-action` from 1.16.2 to 1.17.0 - [Release notes](https://github.com/depot/build-push-action/releases) - [Commits](https://github.com/depot/build-push-action/compare/9785b135c3c76c33db102e45be96a25ab55cd507...5f3b3c2e5a00f0093de47f657aeaefcedff27d18) Updates `anchore/sbom-action` from 0.21.1 to 0.22.2 - [Release notes](https://github.com/anchore/sbom-action/releases) - [Changelog](https://github.com/anchore/sbom-action/blob/main/RELEASE.md) - [Commits](https://github.com/anchore/sbom-action/compare/0b82b0b1a22399a1c542d4d656f70cd903571b5c...28d71544de8eaf1b958d335707167c5f783590ad) Updates `actions/stale` from 10.1.1 to 10.2.0 - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/997185467fa4f803885201cee163a9f38240193d...b5d41d4e1d5dceea10e7104786b73624c18a190f) --- updated-dependencies: - dependency-name: depot/setup-action dependency-version: 1.7.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: depot/build-push-action dependency-version: 1.17.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: anchore/sbom-action dependency-version: 0.22.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: actions/stale dependency-version: 10.2.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * [UI] Copy cells expansion (#11410) * Prevent copy button if copy value is null * Add "link" columns to order tables * Support copy for default column types * Tweak padding to avoid flickering issues * Refactor IPNColumn * Adjust visual styling * Copy for SKU and MPN columns * Add more copy columns * More tweaks * Tweak playwright testing * Further cleanup * More copy cols * Fix auto pricing overwriting manual purchase price #10846 (#11411) * Fix auto pricing overwriting manual purchase price #10846 * Added entry to api_version.py --------- Co-authored-by: Oliver <oliver.henry.walters@gmail.com> * [UI] Default locale (#11412) * [UI] Support default server language * Handle faulty theme * Add option for default language * Improve language selection * Brief docs entry * Fix typo * Fix yarn build * Remove debug msg * Fix calendar locale * feat(backend): ensure restore of backups only works in correct enviroments (#11372) * [FR] ensure restore of backups only works in correct enviroments Fixes #11214 * update PR nbr * fix wrong ty detection * fix link * ensure tracing does not enagage while running backup ops * fix import * remove debugging string * add error codes * add tests for backup and restore * complete test for restore * we do not need e2e on every matrix entry there is no realy db dep here * fix changelog format * add flag to allow bypass * update CHANGELOG.md --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Oliver <oliver.henry.walters@gmail.com> Co-authored-by: Matthias Mair <code@mjmair.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JustusRijke <53965859+JustusRijke@users.noreply.github.com>
This commit is contained in:
co-authored by
Oliver
Matthias Mair
dependabot[bot]
JustusRijke
parent
23d60bf05f
commit
3d9104e9a5
@@ -9,7 +9,7 @@ from django.core.validators import MinValueValidator
|
||||
from django.db import models, transaction
|
||||
from django.db.models import F, Q, QuerySet, Sum
|
||||
from django.db.models.functions import Coalesce
|
||||
from django.db.models.signals import post_save
|
||||
from django.db.models.signals import post_delete, post_save
|
||||
from django.dispatch.dispatcher import receiver
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@@ -331,6 +331,8 @@ class Order(
|
||||
if not self.creation_date:
|
||||
self.creation_date = InvenTree.helpers.current_date()
|
||||
|
||||
self.updated_at = InvenTree.helpers.current_time()
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def check_locked(self, db: bool = False) -> bool:
|
||||
@@ -498,6 +500,13 @@ class Order(
|
||||
help_text=_('Date order was issued'),
|
||||
)
|
||||
|
||||
updated_at = models.DateTimeField(
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name=_('Updated At'),
|
||||
help_text=_('Timestamp of last update'),
|
||||
)
|
||||
|
||||
responsible = models.ForeignKey(
|
||||
UserModels.Owner,
|
||||
on_delete=models.SET_NULL,
|
||||
@@ -3072,3 +3081,43 @@ class ReturnOrderExtraLine(OrderExtraLine):
|
||||
verbose_name=_('Order'),
|
||||
help_text=_('Return Order'),
|
||||
)
|
||||
|
||||
|
||||
def _touch_order_updated_at(instance):
|
||||
"""Bump updated_at on the parent order without triggering a full save."""
|
||||
if not InvenTree.ready.canAppAccessDatabase(allow_test=True):
|
||||
return
|
||||
instance.order.__class__.objects.filter(pk=instance.order_id).update(
|
||||
updated_at=InvenTree.helpers.current_time()
|
||||
)
|
||||
|
||||
|
||||
@receiver(post_save, sender=PurchaseOrderLineItem, dispatch_uid='po_lineitem_post_save')
|
||||
@receiver(
|
||||
post_delete, sender=PurchaseOrderLineItem, dispatch_uid='po_lineitem_post_delete'
|
||||
)
|
||||
@receiver(
|
||||
post_save, sender=PurchaseOrderExtraLine, dispatch_uid='po_extraline_post_save'
|
||||
)
|
||||
@receiver(
|
||||
post_delete, sender=PurchaseOrderExtraLine, dispatch_uid='po_extraline_post_delete'
|
||||
)
|
||||
@receiver(post_save, sender=SalesOrderLineItem, dispatch_uid='so_lineitem_post_save')
|
||||
@receiver(
|
||||
post_delete, sender=SalesOrderLineItem, dispatch_uid='so_lineitem_post_delete'
|
||||
)
|
||||
@receiver(post_save, sender=SalesOrderExtraLine, dispatch_uid='so_extraline_post_save')
|
||||
@receiver(
|
||||
post_delete, sender=SalesOrderExtraLine, dispatch_uid='so_extraline_post_delete'
|
||||
)
|
||||
@receiver(post_save, sender=ReturnOrderLineItem, dispatch_uid='ro_lineitem_post_save')
|
||||
@receiver(
|
||||
post_delete, sender=ReturnOrderLineItem, dispatch_uid='ro_lineitem_post_delete'
|
||||
)
|
||||
@receiver(post_save, sender=ReturnOrderExtraLine, dispatch_uid='ro_extraline_post_save')
|
||||
@receiver(
|
||||
post_delete, sender=ReturnOrderExtraLine, dispatch_uid='ro_extraline_post_delete'
|
||||
)
|
||||
def update_order_on_lineitem_change(sender, instance, **kwargs):
|
||||
"""Update parent order updated_at when any line item is saved or deleted."""
|
||||
_touch_order_updated_at(instance)
|
||||
|
||||
Reference in New Issue
Block a user