Created
January 25, 2013 12:42
-
-
Save ren23/4634170 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class feuille_de_route(models.Model): | |
''' | |
cree commande : en_route == True reste False | |
construction : en_route == True + instrument_set==1 reste False | |
testfinal : en_route == True + instrument_set==1 testfinal == True reste False | |
a partir : en_route == True + instrument_set==1 testfinal == False a_partir == True reste False | |
chez client : all False | |
''' | |
code = models.CharField( max_length = 100, unique = True) | |
sn_instrument = models.CharField( max_length = 100, null = True, blank=True) | |
commande = models.ForeignKey(confirmation_commande) | |
id_instrument = models.CharField( max_length = 5, blank = True) | |
upgrade = models.BooleanField() | |
a_partir = models.BooleanField() | |
cancel = models.BooleanField() | |
en_route = models.BooleanField() | |
final_customer = models.ForeignKey(Company, blank = True, null = True) | |
town = models.CharField( max_length = 200, blank = True, null = True) | |
pays = models.ForeignKey(Pays, blank = True, null = True) | |
description = models.TextField(blank = True) | |
special = models.BooleanField() | |
testfinal = models.BooleanField() | |
specialdescription = models.TextField(blank = True) | |
responsable = models.CharField(max_length = 150, blank = True, null = True) | |
accepted = models.BooleanField() | |
notwithstanding = models.TextField(blank = True, null = True) | |
missing = models.TextField(blank = True, null = True) | |
installer = models.CharField(max_length = 150, blank = True, null = True) | |
install_date = models.DateField(blank = True, null = True) | |
accepter = models.CharField(max_length = 150, blank = True, null = True) | |
warranty_date = models.DateField(blank = True, null = True) | |
recalibration_date = models.DateField(blank = True, null = True) | |
accept_date = models.DateField(blank = True, null = True) | |
ai_date = models.DateField(blank = True, null = True) | |
install_done = models.BooleanField() | |
class Meta: | |
ordering = ['code'] | |
def __unicode__(self): | |
return self.code | |
def get_instrument(self): | |
try: | |
Instrument = instrument.objects.get(id = int(self.id_instrument)) | |
return Instrument | |
except Exception,e: | |
print 'error get instrument', e | |
return None | |
# if self.id_instrument == '': | |
# return '' | |
#return get_object_or_404(instrument, id = int(self.id_instrument)) | |
@models.permalink | |
def get_instrument_url(self): | |
try: | |
return ('instrument_view', [str(self.id_instrument)]) | |
except Exception, e: | |
print e | |
return 'ici' | |
def get_nom_instrument(self): | |
Instrument = self.get_instrument() | |
if not Instrument: | |
return '' | |
if Instrument.sn: | |
return Instrument.nom+' '+Instrument.sn | |
else: | |
return Instrument.nom+' '+Instrument.feuille_route.cutnumber() | |
def pret_test(self): | |
instruments = self.instrument_set.all() | |
if not self.a_partir and self.en_route and not self.testfinal: | |
if len(instruments)==1: | |
#print len(element.objects.filter(groupe__instrument__id = instruments[0].id))>0, len(element.objects.filter(groupe__instrument__id = instruments[0].id, sn='False' ))==0, len(instruments[0].groupe_set.all())>0 | |
if len(element.objects.filter(groupe__instrument__id = instruments[0].id))>0 and len(element.objects.filter(groupe__instrument__id = instruments[0].id, sn='False' ))==0 and len(instruments[0].groupe_set.all())>0: | |
return True | |
return False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{%extends "inst/non_generees/base.html"%} | |
{%block importcss%} | |
{%endblock%} | |
{%block titre%} | |
{%include 'inst/titre/titre.html'%} | |
{%endblock%} | |
{%block log%} | |
{%include 'inst/log/log.html'%} | |
{%endblock%} | |
{%block sidebarmenu%} | |
{%include 'inst/message.html'%} | |
{%endblock%} | |
{% load instrackr_filter %} | |
{%block content%} | |
{% load i18n %} | |
<h2>{% trans 'Production'%}</h1> | |
{%if production%} | |
<table> | |
<thead> | |
<tr> | |
<th>{%trans 'Tracking sheet'%}</th> | |
<th>{%trans 'Order'%}</th> | |
<th>{%trans 'Date'%}</th> | |
<th>{%trans 'Customer'%}</th> | |
<th>{%trans 'Upgrade'%}</th> | |
<th>{%trans 'description'%}</th> | |
<th></th> | |
</tr> | |
</thead> | |
<tbody> | |
{% for feuille in production %} | |
<tr> | |
<td> | |
<a href='{{feuille.id}}/'> | |
{{feuille.code}}</a> | |
</td> | |
<td>{{feuille.commande.code}}</td> | |
<td>{{feuille.commande.date|date:"d/m/Y"}}</td> | |
<td> | |
<a href='{%url customer_view feuille.commande.client.id%}'>{{feuille.commande.client.nom}}</a> | |
</td> | |
<td> | |
{%if feuille.upgrade%} | |
<a href='{{feuille.get_instrument_url}}'>{{feuille.get_nom_instrument}}</a> | |
{%endif%} | |
</td> | |
<td>{{feuille.description|textareatohmtl}}</td> | |
<td> | |
{%if perms.instrackr_app.SAV%} | |
<a href='{{feuille.id}}/delete'><img src='{{MEDIA_URL}}/img/cancel.png' border='0' title="{% trans 'cancel tracking sheet'%}" /></a> | |
<br/> | |
{%endif%} | |
{%if feuille.pret_test%} | |
{% trans 'all elements are choosen'%} | |
{%if perms.instrackr_app.SAV or perms.instrackr_app.stock%} | |
<a href='{{feuille.id}}/sheet_validate'>{% trans 'Test final'%}</a> | |
{%endif%} | |
{%endif%} | |
</td> | |
</tr> | |
{%endfor%} | |
</tbody> | |
</table> | |
{%else%} | |
<p>{% trans 'there are no command'%}</p> | |
{%endif%} | |
<h2>{% trans 'Final tests'%}</h1> | |
{%if final_tests%} | |
<table> | |
<thead> | |
<tr> | |
<th>{%trans 'Tracking sheet'%}</th> | |
<th>{%trans 'Order'%}</th> | |
<th>{%trans 'Date'%}</th> | |
<th>{%trans 'Customer'%}</th> | |
<th>{%trans 'Upgrade'%}</th> | |
<th>{%trans 'description'%}</th> | |
<th></th> | |
</tr> | |
</thead> | |
<tbody> | |
{% for feuille in final_tests %} | |
<tr> | |
<td> | |
<a href='{{feuille.id}}/'>{{feuille.code}}</a> | |
</td> | |
<td>{{feuille.commande.code}}</td> | |
<td>{{feuille.commande.date|date:"d/m/Y"}}</td> | |
<td> | |
<a href='{%url customer_view feuille.commande.client.id%}'>{{feuille.commande.client.nom}}</a> | |
</td> | |
<td> | |
{%if feuille.upgrade%} | |
<a href='{{feuille.get_instrument_url}}'>{{feuille.get_nom_instrument}}</a> | |
{%endif%} | |
</td> | |
<td>{{feuille.description|textareatohmtl}}</td> | |
<td> | |
{%if perms.instrackr_app.SAV or perms.instrackr_app.stock%} | |
<a href='{{feuille.id}}/delete'><img src='{{MEDIA_URL}}/img/cancel.png' border='0' title="{% trans 'cancel tracking sheet'%}" /></a> | |
{%endif%} | |
{%if perms.instrackr_app.SAV or perms.instrackr_app.stock%} | |
<a href='http://{{url}}/client/{{feuille.id}}/go'>{% trans 'Validate final test'%}</a> | |
{%endif%} | |
</td> | |
</tr> | |
{%endfor%} | |
</tbody> | |
</table> | |
{%else%} | |
<p>{% trans 'there are no command'%}</p> | |
{%endif%} | |
<h2>{% trans 'Installations'%}</h1> | |
{%if installation_to_do%} | |
<table> | |
<thead> | |
<tr> | |
<th>{%trans 'Tracking sheet'%}</th> | |
<th>{%trans 'Order'%}</th> | |
<th>{%trans 'Date'%}</th> | |
<th>{%trans 'Customer'%}</th> | |
<th>{%trans 'Upgrade'%}</th> | |
<th>{%trans 'description'%}</th> | |
<th></th> | |
</tr> | |
</thead> | |
<tbody> | |
{% for feuille in installation_to_do %} | |
<tr> | |
<td> | |
<a href='{{feuille.id}}/'> | |
{{feuille.code}}</a> | |
</td> | |
<td>{{feuille.commande.code}}</td> | |
<td>{{feuille.commande.date|date:"d/m/Y"}}</td> | |
<td> | |
<a href='{%url customer_view feuille.commande.client.id%}'>{{feuille.commande.client.nom}}</a> | |
</td> | |
<td> | |
{%if feuille.upgrade%} | |
<a href='{{feuille.get_instrument_url}}'>{{feuille.get_nom_instrument}}</a> | |
{%endif%} | |
</td> | |
<td>{{feuille.description|textareatohmtl}}</td> | |
<td> | |
{%if perms.instrackr_app.SAV or perms.instrackr_app.stock%} | |
<a href='{{feuille.id}}/delete'><img src='{{MEDIA_URL}}/img/cancel.png' border='0' title="{% trans 'cancel tracking sheet'%}" /></a> | |
{%endif%} | |
{%if perms.instrackr_app.SAV or perms.instrackr_app.stock%} | |
<a href='http://{{url}}/client/{{feuille.id}}/to_customer/'>{% trans 'Installation'%}</a> | |
{%endif%} | |
</td> | |
</tr> | |
{%endfor%} | |
</tbody> | |
</table> | |
{%else%} | |
<p>{% trans 'there are no command'%}</p> | |
{%endif%} | |
{%endblock%} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def instrument_creation_view(request): | |
'''affichage des systemes en construction | |
''' | |
installation_to_do = feuille_de_route.objects.filter(en_route = True, a_partir = True).select_related() | |
final_tests = feuille_de_route.objects.filter(en_route = True, testfinal = True).select_related() | |
production = feuille_de_route.objects.annotate(count_inst = models.Count('instrument')).filter(en_route = True, a_partir= False, testfinal = False, count_inst__gt=0).select_related() | |
return render_to_response('sys/feuille_creation_view.html',{'installation_to_do' : installation_to_do, 'final_tests' : final_tests, 'production':production, 'onglet':'sys','url':url}, context_instance=RequestContext(request)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment