Fix counter view with no stock

This commit is contained in:
Skia 2017-05-01 16:53:30 +02:00
parent 58fdb36911
commit c7f48bd5f7

View File

@ -143,12 +143,14 @@ class CounterTabsMixin(TabedViewMixin):
'slug': 'last_ops', 'slug': 'last_ops',
'name': _("Last operations"), 'name': _("Last operations"),
}) })
tab_list.append({ try:
'url': reverse_lazy('stock:take_items', tab_list.append({
kwargs={'stock_id': self.object.stock.id if hasattr(self.object, 'stock') else self.object.stock_owner.id}), 'url': reverse_lazy('stock:take_items',
'slug': 'take_items_from_stock', kwargs={'stock_id': self.object.stock.id if hasattr(self.object, 'stock') else self.object.stock_owner.id}),
'name': _("Take items from stock"), 'slug': 'take_items_from_stock',
}) 'name': _("Take items from stock"),
})
except: pass # The counter just have no stock
return tab_list return tab_list
class CounterMain(CounterTabsMixin, CanViewMixin, DetailView, ProcessFormView, FormMixin): class CounterMain(CounterTabsMixin, CanViewMixin, DetailView, ProcessFormView, FormMixin):