mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +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:
parent
cfff5ea264
commit
d194aef79e
@ -236,6 +236,11 @@ class Build(MPTTModel, ReferenceIndexingMixin):
|
||||
help_text=_('Build status code')
|
||||
)
|
||||
|
||||
@property
|
||||
def status_text(self):
|
||||
"""Return the text representation of the status field"""
|
||||
return BuildStatus.text(self.status)
|
||||
|
||||
batch = models.CharField(
|
||||
verbose_name=_('Batch Code'),
|
||||
max_length=100,
|
||||
|
@ -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(
|
||||
|
@ -670,6 +670,11 @@ class StockItem(InvenTreeBarcodeMixin, MetadataMixin, MPTTModel):
|
||||
choices=StockStatus.items(),
|
||||
validators=[MinValueValidator(0)])
|
||||
|
||||
@property
|
||||
def status_text(self):
|
||||
"""Return the text representation of the status field"""
|
||||
return StockStatus.text(self.status)
|
||||
|
||||
notes = InvenTreeNotesField(help_text=_('Stock Item Notes'))
|
||||
|
||||
purchase_price = InvenTreeModelMoneyField(
|
||||
|
Loading…
Reference in New Issue
Block a user