Browse Source

Fix locale bug in invoices PDF. Now locale is forced before rendring PDF

Fabs 10 years ago
parent
commit
3bd784ec5b
1 changed files with 4 additions and 0 deletions
  1. 4 0
      coin/html2pdf.py

+ 4 - 0
coin/html2pdf.py

@@ -9,6 +9,7 @@ from tempfile import NamedTemporaryFile
 from django.conf import settings
 from django.template import loader, Context
 from django.core.files import File
+from django.utils import translation
 
 
 def link_callback(uri, rel):
@@ -51,6 +52,9 @@ def render_as_pdf(template, context):
     converti en PDF via le module xhtml2pdf.
     Renvoi un objet de type File
     """
+    # Force locale, because isn't done when launched from managment command
+    translation.activate(settings.LANGUAGE_CODE)
+    
     template = loader.get_template(template)
     html = template.render(Context(context))
     file = NamedTemporaryFile()