From fd1111f37853ff74499adc14d94316ddbc6b5243 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Wed, 21 Aug 2019 14:13:53 +0530 Subject: [PATCH] Display units in Sale / Product and don't show brackets when no units entered --- barker/models/master.py | 2 +- barker/views/product.py | 3 +-- bookie/src/app/sales/products/products.component.html | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/barker/models/master.py b/barker/models/master.py index eb640f6..2f8776b 100644 --- a/barker/models/master.py +++ b/barker/models/master.py @@ -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): diff --git a/barker/views/product.py b/barker/views/product.py index c381260..4b9959e 100644 --- a/barker/views/product.py +++ b/barker/views/product.py @@ -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, diff --git a/bookie/src/app/sales/products/products.component.html b/bookie/src/app/sales/products/products.component.html index 651d275..496187b 100644 --- a/bookie/src/app/sales/products/products.component.html +++ b/bookie/src/app/sales/products/products.component.html @@ -3,6 +3,7 @@

{{item.name}}

+ {{item.price | currency:'INR'}}