From c7f48bd5f7ffffed580b82e56f70baab0c0c0e23 Mon Sep 17 00:00:00 2001 From: Skia Date: Mon, 1 May 2017 16:53:30 +0200 Subject: [PATCH] Fix counter view with no stock --- counter/views.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/counter/views.py b/counter/views.py index dc8bf1a8..8981bfda 100644 --- a/counter/views.py +++ b/counter/views.py @@ -143,12 +143,14 @@ class CounterTabsMixin(TabedViewMixin): 'slug': 'last_ops', 'name': _("Last operations"), }) - tab_list.append({ - 'url': reverse_lazy('stock:take_items', - kwargs={'stock_id': self.object.stock.id if hasattr(self.object, 'stock') else self.object.stock_owner.id}), - 'slug': 'take_items_from_stock', - 'name': _("Take items from stock"), - }) + try: + tab_list.append({ + 'url': reverse_lazy('stock:take_items', + kwargs={'stock_id': self.object.stock.id if hasattr(self.object, 'stock') else self.object.stock_owner.id}), + 'slug': 'take_items_from_stock', + 'name': _("Take items from stock"), + }) + except: pass # The counter just have no stock return tab_list class CounterMain(CounterTabsMixin, CanViewMixin, DetailView, ProcessFormView, FormMixin):