diff --git a/counter/templates/counter/counter_list.jinja b/counter/templates/counter/counter_list.jinja index 0dc72d1f..5ecdf358 100644 --- a/counter/templates/counter/counter_list.jinja +++ b/counter/templates/counter/counter_list.jinja @@ -32,9 +32,9 @@ {% trans %}Edit{% endtrans %} - {% trans %}Stats{% endtrans %} - {%if c.stock %} - Stock - + Stock - {% else %} - {% trans %}Create new stock{% endtrans%} - + {% trans %}Create new stock{% endtrans%} - {% endif %} {% endif %} {% if user.is_owner(c) %} diff --git a/stock/migrations/0002_auto_20161113_2325.py b/stock/migrations/0002_auto_20161113_2325.py new file mode 100644 index 00000000..8f36b593 --- /dev/null +++ b/stock/migrations/0002_auto_20161113_2325.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('counter', '0011_auto_20161004_2039'), + ('stock', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='stockitem', + name='type', + field=models.ForeignKey(to='counter.ProductType', blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, verbose_name='type', related_name='stockItem_type'), + ), + migrations.AlterField( + model_name='stockitem', + name='effective_quantity', + field=models.IntegerField(help_text='total number of bottle/barrel', verbose_name='effective quantity', default=0), + ), + migrations.AlterField( + model_name='stockitem', + name='unit_quantity', + field=models.IntegerField(help_text='number of beer in one crate (equal one for barrels)', verbose_name='unit quantity', default=0), + ), + ] diff --git a/stock/models.py b/stock/models.py index 50336f72..4b2cccfd 100644 --- a/stock/models.py +++ b/stock/models.py @@ -2,11 +2,12 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from django.core.urlresolvers import reverse - -from counter.models import Counter +from counter.models import Counter, ProductType class Stock(models.Model): - """ The Stock class, this one is used to know how many products are left for a specific counter """ + """ + The Stock class, this one is used to know how many products are left for a specific counter + """ name = models.CharField(_('name'), max_length=64) counter = models.OneToOneField(Counter, verbose_name=_('counter'), related_name='stock') @@ -17,12 +18,17 @@ class Stock(models.Model): return reverse('stock:list') class StockItem(models.Model): - """ The StockItem class, element of the stock """ + """ + The StockItem class, element of the stock + """ name = models.CharField(_('name'), max_length=64) - unit_quantity = models.IntegerField(_('unit quantity'), default=0) - effective_quantity = models.IntegerField(_('effective quantity'), default=0) + unit_quantity = models.IntegerField(_('unit quantity'), default=0, help_text='number of beer in one crate (equal one for barrels)') + effective_quantity = models.IntegerField(_('effective quantity'), default=0, help_text='total number of bottle/barrel') + type = models.ForeignKey(ProductType, related_name="stockItem_type", verbose_name=_("type"), null=True, blank=True, + on_delete=models.SET_NULL) stock_owner = models.ForeignKey(Stock, related_name="stock_owner") + def __str__(self): return "%s (%s)" % (self.name, self.stock_owner) diff --git a/stock/templates/stock/stock_item_list.jinja b/stock/templates/stock/stock_item_list.jinja new file mode 100644 index 00000000..77ccab36 --- /dev/null +++ b/stock/templates/stock/stock_item_list.jinja @@ -0,0 +1,15 @@ +{% extends "core/base.jinja" %} + +{% block title %} +{% trans s=stock %}{{stock}}{% endtrans %} +{% endblock %} + +{% block content %} +{% if current_tab == "stocks" %} +
{% trans %}New item{% endtrans %}
+{% endif %} +