Merge branch 'aureplop/amend_supplier_model' into 'test/views_kfet'

Most data of suppliers should be optionnal.

See merge request !246
This commit is contained in:
Martin Pepin 2017-08-30 20:32:43 +02:00
commit b7502e51ed
2 changed files with 51 additions and 8 deletions

View file

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('kfet', '0057_add_perms_config'),
]
operations = [
migrations.AlterField(
model_name='supplier',
name='address',
field=models.TextField(verbose_name='adresse', blank=True),
),
migrations.AlterField(
model_name='supplier',
name='articles',
field=models.ManyToManyField(verbose_name='articles vendus', through='kfet.SupplierArticle', related_name='suppliers', to='kfet.Article'),
),
migrations.AlterField(
model_name='supplier',
name='comment',
field=models.TextField(verbose_name='commentaire', blank=True),
),
migrations.AlterField(
model_name='supplier',
name='email',
field=models.EmailField(max_length=254, verbose_name='adresse mail', blank=True),
),
migrations.AlterField(
model_name='supplier',
name='phone',
field=models.CharField(max_length=20, verbose_name='téléphone', blank=True),
),
]

View file

@ -8,6 +8,7 @@ from gestioncof.models import CofProfile
from django.utils.six.moves import reduce from django.utils.six.moves import reduce
from django.utils import timezone from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.db import transaction from django.db import transaction
from django.db.models import F from django.db.models import F
from datetime import date from datetime import date
@ -524,21 +525,24 @@ class InventoryArticle(models.Model):
self.stock_error = self.stock_new - self.stock_old self.stock_error = self.stock_new - self.stock_old
super(InventoryArticle, self).save(*args, **kwargs) super(InventoryArticle, self).save(*args, **kwargs)
@python_2_unicode_compatible
class Supplier(models.Model): class Supplier(models.Model):
articles = models.ManyToManyField( articles = models.ManyToManyField(
Article, Article,
verbose_name=_("articles vendus"),
through='SupplierArticle', through='SupplierArticle',
related_name = "suppliers") related_name='suppliers',
name = models.CharField("nom", max_length = 45) )
address = models.TextField("adresse") name = models.CharField(_("nom"), max_length=45)
email = models.EmailField("adresse mail") address = models.TextField(_("adresse"), blank=True)
phone = models.CharField("téléphone", max_length = 10) email = models.EmailField(_("adresse mail"), blank=True)
comment = models.TextField("commentaire") phone = models.CharField(_("téléphone"), max_length=20, blank=True)
comment = models.TextField(_("commentaire"), blank=True)
def __str__(self): def __str__(self):
return self.name return self.name
class SupplierArticle(models.Model): class SupplierArticle(models.Model):
supplier = models.ForeignKey( supplier = models.ForeignKey(
Supplier, on_delete = models.PROTECT) Supplier, on_delete = models.PROTECT)