Display units in Sale / Product and don't show brackets when no units entered

This commit is contained in:
Amritanshu
2019-08-21 14:13:53 +05:30
parent b898e26dc6
commit fd1111f378
3 changed files with 3 additions and 3 deletions

View File

@ -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):

View File

@ -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,