forked from DGNum/gestioCOF
Nouvel article - Sélection(et/ou création) de fournisseurs
This commit is contained in:
parent
be8243c4ce
commit
ab9bbac34f
7 changed files with 99 additions and 16 deletions
|
@ -8,7 +8,7 @@ from django.forms.models import BaseInlineFormSet
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from kfet.models import (Account, Checkout, Article, OperationGroup, Operation,
|
from kfet.models import (Account, Checkout, Article, OperationGroup, Operation,
|
||||||
CheckoutStatement, ArticleCategory, Settings, AccountNegative, Transfer,
|
CheckoutStatement, ArticleCategory, Settings, AccountNegative, Transfer,
|
||||||
TransferGroup)
|
TransferGroup, Supplier)
|
||||||
from gestioncof.models import CofProfile
|
from gestioncof.models import CofProfile
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
|
@ -192,6 +192,18 @@ class ArticleForm(forms.ModelForm):
|
||||||
queryset = ArticleCategory.objects.all(),
|
queryset = ArticleCategory.objects.all(),
|
||||||
required = False)
|
required = False)
|
||||||
|
|
||||||
|
suppliers = forms.ModelMultipleChoiceField(
|
||||||
|
queryset = Supplier.objects.all(),
|
||||||
|
required = False)
|
||||||
|
supplier_new = forms.CharField(
|
||||||
|
max_length = 45,
|
||||||
|
required = False)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(ArticleForm, self).__init__(*args, **kwargs)
|
||||||
|
if self.instance.pk:
|
||||||
|
self.initial['suppliers'] = self.instance.suppliers.values_list('pk', flat=True)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
category = self.cleaned_data.get('category')
|
category = self.cleaned_data.get('category')
|
||||||
category_new = self.cleaned_data.get('category_new')
|
category_new = self.cleaned_data.get('category_new')
|
||||||
|
@ -201,6 +213,7 @@ class ArticleForm(forms.ModelForm):
|
||||||
elif not category:
|
elif not category:
|
||||||
category, _ = ArticleCategory.objects.get_or_create(name=category_new)
|
category, _ = ArticleCategory.objects.get_or_create(name=category_new)
|
||||||
self.cleaned_data['category'] = category
|
self.cleaned_data['category'] = category
|
||||||
|
|
||||||
super(ArticleForm, self).clean()
|
super(ArticleForm, self).clean()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
39
kfet/migrations/0037_auto_20160826_2333.py
Normal file
39
kfet/migrations/0037_auto_20160826_2333.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('kfet', '0036_auto_20160823_1910'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierarticle',
|
||||||
|
name='TVA',
|
||||||
|
field=models.DecimalField(null=True, max_digits=4, decimal_places=2, default=None, blank=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierarticle',
|
||||||
|
name='box_capacity',
|
||||||
|
field=models.PositiveSmallIntegerField(null=True, default=None, blank=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierarticle',
|
||||||
|
name='box_type',
|
||||||
|
field=models.CharField(null=True, max_length=7, choices=[('caisse', 'Caisse'), ('carton', 'Carton'), ('palette', 'Palette'), ('fût', 'Fût')], default=None, blank=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierarticle',
|
||||||
|
name='price_HT',
|
||||||
|
field=models.DecimalField(null=True, max_digits=7, decimal_places=4, default=None, blank=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierarticle',
|
||||||
|
name='rights',
|
||||||
|
field=models.DecimalField(null=True, max_digits=7, decimal_places=4, default=None, blank=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -376,6 +376,9 @@ class Supplier(models.Model):
|
||||||
phone = models.CharField(max_length = 10)
|
phone = models.CharField(max_length = 10)
|
||||||
comment = models.TextField()
|
comment = models.TextField()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
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)
|
||||||
|
@ -389,11 +392,19 @@ class SupplierArticle(models.Model):
|
||||||
)
|
)
|
||||||
box_type = models.CharField(
|
box_type = models.CharField(
|
||||||
choices = BOX_TYPE_CHOICES,
|
choices = BOX_TYPE_CHOICES,
|
||||||
max_length = choices_length(BOX_TYPE_CHOICES))
|
max_length = choices_length(BOX_TYPE_CHOICES),
|
||||||
box_capacity = models.PositiveSmallIntegerField()
|
blank = True, null = True, default = None)
|
||||||
price_HT = models.DecimalField(max_digits = 7, decimal_places = 4)
|
box_capacity = models.PositiveSmallIntegerField(
|
||||||
TVA = models.DecimalField(max_digits = 4, decimal_places = 2)
|
blank = True, null = True, default = None)
|
||||||
rights = models.DecimalField(max_digits = 7, decimal_places = 4)
|
price_HT = models.DecimalField(
|
||||||
|
max_digits = 7, decimal_places = 4,
|
||||||
|
blank = True, null = True, default = None)
|
||||||
|
TVA = models.DecimalField(
|
||||||
|
max_digits = 4, decimal_places = 2,
|
||||||
|
blank = True, null = True, default = None)
|
||||||
|
rights = models.DecimalField(
|
||||||
|
max_digits = 7, decimal_places = 4,
|
||||||
|
blank = True, null = True, default = None)
|
||||||
|
|
||||||
class Order(models.Model):
|
class Order(models.Model):
|
||||||
supplier = models.ForeignKey(
|
supplier = models.ForeignKey(
|
||||||
|
|
|
@ -79,17 +79,16 @@
|
||||||
padding-left:20px;
|
padding-left:20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#history div.general.ui-selected, #history div.general.ui-selecting,
|
|
||||||
#history div.ope.ui-selected, #history div.ope.ui-selecting {
|
#history div.ope.ui-selected, #history div.ope.ui-selecting {
|
||||||
background-color:rgba(200,16,46,0.6);
|
background-color:rgba(200,16,46,0.6);
|
||||||
color:#FFF;
|
color:#FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
#history .ope.canceled {
|
#history .ope.canceled, #history .transfer.canceled {
|
||||||
color:#444;
|
color:#444;
|
||||||
}
|
}
|
||||||
|
|
||||||
#history .ope.canceled::before {
|
#history .ope.canceled::before, #history.transfer.canceled::before {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
content: ' ';
|
content: ' ';
|
||||||
width:100%;
|
width:100%;
|
||||||
|
@ -97,3 +96,11 @@
|
||||||
top: 12px;
|
top: 12px;
|
||||||
border-top: 1px solid rgba(200,16,46,0.5);
|
border-top: 1px solid rgba(200,16,46,0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#history .transfer .amount {
|
||||||
|
width:80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#history .transfer .from_acc {
|
||||||
|
padding-left:10px;
|
||||||
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
.transfer_form td {
|
.transfer_form td {
|
||||||
height:50px;
|
height:50px;
|
||||||
vertical-align:middle;
|
vertical-align:middle !important;
|
||||||
padding:0 !important;
|
padding:0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@
|
||||||
<span>{{ transfergroup.comment }}</span>
|
<span>{{ transfergroup.comment }}</span>
|
||||||
</div>
|
</div>
|
||||||
{% for transfer in transfergroup.transfers.all %}
|
{% for transfer in transfergroup.transfers.all %}
|
||||||
<div>
|
<div class="ope transfer">
|
||||||
<span>{{ transfer.amount }} €</span>
|
<span class="amount">{{ transfer.amount }} €</span>
|
||||||
<span>{{ transfer.from_acc.trigramme }}</span>
|
<span class="from_acc">{{ transfer.from_acc.trigramme }}</span>
|
||||||
<span>--></span>
|
<span class="glyphicon glyphicon-arrow-right"></span>
|
||||||
<span>{{ transfer.to_acc.trigramme }}</span>
|
<span class="to_acc">{{ transfer.to_acc.trigramme }}</span>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -18,7 +18,7 @@ from django.utils import timezone
|
||||||
from django.utils.crypto import get_random_string
|
from django.utils.crypto import get_random_string
|
||||||
from gestioncof.models import CofProfile, Clipper
|
from gestioncof.models import CofProfile, Clipper
|
||||||
from kfet.models import (Account, Checkout, Article, Settings, AccountNegative,
|
from kfet.models import (Account, Checkout, Article, Settings, AccountNegative,
|
||||||
CheckoutStatement, GenericTeamToken)
|
CheckoutStatement, GenericTeamToken, Supplier, SupplierArticle)
|
||||||
from kfet.forms import *
|
from kfet.forms import *
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from kfet import consumers
|
from kfet import consumers
|
||||||
|
@ -548,6 +548,19 @@ class ArticleCreate(SuccessMessageMixin, CreateView):
|
||||||
form.add_error(None, 'Permission refusée')
|
form.add_error(None, 'Permission refusée')
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
||||||
|
article = form.save()
|
||||||
|
for supplier in form.cleaned_data['suppliers']:
|
||||||
|
SupplierArticle.objects.create(
|
||||||
|
article = article, supplier = supplier)
|
||||||
|
|
||||||
|
supplier_new = form.cleaned_data['supplier_new'].strip()
|
||||||
|
if supplier_new:
|
||||||
|
supplier, created = Supplier.objects.get_or_create(
|
||||||
|
name=supplier_new)
|
||||||
|
if created:
|
||||||
|
SupplierArticle.objects.create(
|
||||||
|
article = article, supplier = supplier)
|
||||||
|
|
||||||
# Creating
|
# Creating
|
||||||
return super(ArticleCreate, self).form_valid(form)
|
return super(ArticleCreate, self).form_valid(form)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue