general modifications

This commit is contained in:
guillaume-renaud
2016-11-14 00:38:33 +01:00
parent 587ad96326
commit 5cb75ec3eb
7 changed files with 82 additions and 17 deletions

View File

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