2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 03:30:54 +00:00

Adds 'status_text' functions to models (#3752)

- Convert status codes into text representation (translated)
- Useful for template rendering
This commit is contained in:
Oliver
2022-10-07 00:18:11 +11:00
committed by GitHub
parent cfff5ea264
commit d194aef79e
3 changed files with 20 additions and 0 deletions

View File

@ -248,6 +248,11 @@ class PurchaseOrder(Order):
status = models.PositiveIntegerField(default=PurchaseOrderStatus.PENDING, choices=PurchaseOrderStatus.items(),
help_text=_('Purchase order status'))
@property
def status_text(self):
"""Return the text representation of the status field"""
return PurchaseOrderStatus.text(self.status)
supplier = models.ForeignKey(
Company, on_delete=models.SET_NULL,
null=True,
@ -645,6 +650,11 @@ class SalesOrder(Order):
status = models.PositiveIntegerField(default=SalesOrderStatus.PENDING, choices=SalesOrderStatus.items(),
verbose_name=_('Status'), help_text=_('Purchase order status'))
@property
def status_text(self):
"""Return the text representation of the status field"""
return SalesOrderStatus.text(self.status)
customer_reference = models.CharField(max_length=64, blank=True, verbose_name=_('Customer Reference '), help_text=_("Customer order reference code"))
target_date = models.DateField(