Auto-rebuild the reference field for the SalesOrder on save

This commit is contained in:
Oliver 2021-10-14 18:00:17 +11:00
parent 068b54f666
commit d3d1d2f577
2 changed files with 6 additions and 2 deletions

View File

@ -31,7 +31,6 @@ def build_refs(apps, schema_editor):
order.save()
print(f" - Updated {n} PurchaseOrder objects")
print("\n - Rebuilding reference field for SalesOrder model...")
SalesOrder = apps.get_model('order', 'salesorder')
@ -54,7 +53,6 @@ def build_refs(apps, schema_editor):
order.save()
print(f" - Updated {n} SalesOrder objects")
print(f" - COMPLETE! -")

View File

@ -534,6 +534,12 @@ class SalesOrder(Order):
return queryset
def save(self, *args, **kwargs):
self.rebuild_reference_field()
super().save(*args, **kwargs)
def __str__(self):
prefix = getSetting('SALESORDER_REFERENCE_PREFIX')