Display units in Sale / Product and don't show brackets when no units entered
This commit is contained in:
@ -187,7 +187,7 @@ class Product(Base):
|
||||
|
||||
@hybrid_property
|
||||
def full_name(self):
|
||||
return "{0} ({1})".format(self.name, self.units)
|
||||
return f"{self.name} ({self.units})" if self.units else self.name
|
||||
|
||||
@full_name.expression
|
||||
def full_name(cls):
|
||||
|
||||
@ -195,8 +195,7 @@ def show_list_sale(request):
|
||||
products.append(
|
||||
{
|
||||
"id": item.id,
|
||||
"name": item.name,
|
||||
"units": item.units,
|
||||
"name": item.full_name,
|
||||
"saleCategory": {
|
||||
"id": item.sale_category_id,
|
||||
"name": item.sale_category.name,
|
||||
|
||||
Reference in New Issue
Block a user