mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +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')
|
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(
|
batch = models.CharField(
|
||||||
verbose_name=_('Batch Code'),
|
verbose_name=_('Batch Code'),
|
||||||
max_length=100,
|
max_length=100,
|
||||||
|
@ -248,6 +248,11 @@ class PurchaseOrder(Order):
|
|||||||
status = models.PositiveIntegerField(default=PurchaseOrderStatus.PENDING, choices=PurchaseOrderStatus.items(),
|
status = models.PositiveIntegerField(default=PurchaseOrderStatus.PENDING, choices=PurchaseOrderStatus.items(),
|
||||||
help_text=_('Purchase order status'))
|
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(
|
supplier = models.ForeignKey(
|
||||||
Company, on_delete=models.SET_NULL,
|
Company, on_delete=models.SET_NULL,
|
||||||
null=True,
|
null=True,
|
||||||
@ -645,6 +650,11 @@ class SalesOrder(Order):
|
|||||||
status = models.PositiveIntegerField(default=SalesOrderStatus.PENDING, choices=SalesOrderStatus.items(),
|
status = models.PositiveIntegerField(default=SalesOrderStatus.PENDING, choices=SalesOrderStatus.items(),
|
||||||
verbose_name=_('Status'), help_text=_('Purchase order status'))
|
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"))
|
customer_reference = models.CharField(max_length=64, blank=True, verbose_name=_('Customer Reference '), help_text=_("Customer order reference code"))
|
||||||
|
|
||||||
target_date = models.DateField(
|
target_date = models.DateField(
|
||||||
|
@ -670,6 +670,11 @@ class StockItem(InvenTreeBarcodeMixin, MetadataMixin, MPTTModel):
|
|||||||
choices=StockStatus.items(),
|
choices=StockStatus.items(),
|
||||||
validators=[MinValueValidator(0)])
|
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'))
|
notes = InvenTreeNotesField(help_text=_('Stock Item Notes'))
|
||||||
|
|
||||||
purchase_price = InvenTreeModelMoneyField(
|
purchase_price = InvenTreeModelMoneyField(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user