facturation: add a print button for CMPP validated invoicing
This commit is contained in:
parent
b9ecf8c90f
commit
763013dda6
|
@ -124,6 +124,9 @@ class M2MFormMixin(object):
|
|||
form.save_m2m()
|
||||
return res
|
||||
|
||||
class DetailView(M2MFormMixin, AppTemplateFirstMixin, ModelNameMixin, ServiceViewMixin,
|
||||
detail.DetailView):
|
||||
pass
|
||||
|
||||
class CreateView(M2MFormMixin, AppTemplateFirstMixin, ModelNameMixin, ServiceViewMixin,
|
||||
edit.CreateView):
|
||||
|
|
|
@ -30,10 +30,11 @@
|
|||
{% if invoicing.status == "validated" %}
|
||||
<button id="teletrans-btn">Télétransmission à l'assurance maladie</button>
|
||||
<button id="expcompt-btn">Export comptabilité</button>
|
||||
<button onclick="window.location.href=window.location.href+'download/'">Imprimer</button>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if show_validation_btn %}<button id="validate">Valider ce décompte</button>{% endif %}
|
||||
{% if invoicing.status == "validated" %}<button id="print-btn">Imprimer</button>{% endif %}
|
||||
{% if invoicing.status == "validated" %}<button id="print-btn" onclick="">Imprimer</button>{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
from django.conf.urls import patterns, url
|
||||
|
||||
from views import (FacturationHomepageView, FacturationDetailView,
|
||||
ValidationFacturationView, close_form, display_invoicing)
|
||||
ValidationFacturationView, close_form, display_invoicing, FacturationDownloadView)
|
||||
|
||||
urlpatterns = patterns('calebasse.facturation.views',
|
||||
url(r'^$', FacturationHomepageView.as_view()),
|
||||
url(r'^display_invoicing', display_invoicing),
|
||||
url(r'^(?P<pk>\d+)/$', FacturationDetailView.as_view()),
|
||||
url(r'^(?P<pk>\d+)/download/.*$', FacturationDownloadView.as_view()),
|
||||
url(r'^(?P<pk>\d+)/validate/$',
|
||||
ValidationFacturationView.as_view(),
|
||||
name='validate-facturation'),
|
||||
|
|
|
@ -5,13 +5,14 @@ from calebasse.facturation import forms
|
|||
|
||||
from datetime import date, datetime
|
||||
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
from django.core.files import File
|
||||
|
||||
from calebasse.cbv import TemplateView, UpdateView
|
||||
|
||||
from models import Invoicing
|
||||
from calebasse.ressources.models import Service
|
||||
|
||||
from invoice_header import render_invoicing
|
||||
|
||||
def display_invoicing(request, *args, **kwargs):
|
||||
if request.method == 'POST':
|
||||
|
@ -156,3 +157,19 @@ class ValidationFacturationView(UpdateView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super(ValidationFacturationView, self).get_context_data(**kwargs)
|
||||
return context
|
||||
|
||||
class FacturationDownloadView(cbv.DetailView):
|
||||
context_object_name = "invoicing"
|
||||
model = Invoicing
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
invoicing = self.get_object()
|
||||
path = render_invoicing(invoicing, delete=False)
|
||||
content = File(file(path))
|
||||
response = HttpResponse(content,'application/pdf')
|
||||
response['Content-Length'] = content.size
|
||||
response['Content-Disposition'] = 'attachment; filename="facturation-%s.pdf"' % invoicing.seq_id
|
||||
return response
|
||||
|
||||
|
||||
|
||||
|
|
Reference in New Issue