New document generation system

#43 Merged at ea3df13
  1. Simone Deponti

New document generation system (bills, packing slips, etc). Currently generates HTML pages by default (the templates need to be fixed/extended) but also has capabilities to create PDF files either via trml2pdf or wkhtmltopdf. Capabilities exists to make the generation of pdf using other technologies such as xhtml2pdf trivial, or even to generate documents in any format (e.g. DOC, DOCX, ODT).

Comments (8)

  1. Chris Moffitt repo owner


    This looks pretty good. I merged it locally and noticed a couple of things.

    • The HTML file names shouldn't have a dash in them. They need to be packingslip.html and shippinglabel.html to work
    • The basic HTML files could use just a little more HTML styling. I don't need them to be really fancy but I do think they need to be useable out of the box. I think some of the <table> tags got missed somehow.
    • Can you add a documentation note to configuration.txt that outlines that SATCHMO_SETTINGS to put in place for TRML or WKHTML?
    • The reference to iconuri in the templates should be removed because I don't think it's defined in the default store.

    This is looking good and I'm really looking forward to including it in Satchmo once we get these things cleaned up.

    1. Simone Deponti author

      I did polish the template quite a bit and added documentation. I also removed the requirements of trml2pdf and Reportlab in the documentation, as they are not needed with the default HTML converter (they are still listed when the doc talks about enabling trml2pdf).

      While I was at it, I also did a complete check of the Italian translations, which were in a unmaintained state: they're now up to speed with the rest. As a side effect (I'm too used to git to get the hang on mercurial) I ended up including a lot of .mo files for other translations, which, however, shouldn't create problems (./ compilemessages did it).

  2. marconius

    I like it. It's definitely an improvement over being stuck with the ol' rml2pdf. And it's all class-based and nice. For now though, would it be better to have ``'DOCUMENT_CONVERTER'`` default to ``'shipping.views.TRMLDocument'``? This way current users upgrading will not be surprised by the different-looking order docs. Maybe insert a DeprecationWarning somewhere?

    Also, I think this fixes an ommition in the code:

    --- a/satchmo/apps/shipping/	Thu May 17 17:56:27 2012 +0200
    +++ b/satchmo/apps/shipping/	Fri Jun 29 12:58:45 2012 -0400
    @@ -96,7 +96,7 @@
         def get_filename(self, request, context):
             return '%s-%s-%d.%s' % (
    -            context['shopDetails'].domain,
    +            context['shopDetails'].site.domain,
    1. Simone Deponti author

      It's okay for me.

      I would restore the default to go to trml2pdf but, in the project skeleton, I would force it to be the HTML generator.

      In this way:

      • New users get the "cool way" up from the beginning
      • Old users don't get any surprise

      The deprecation warning is mostly related to how trml2pdf evolves but, seeing it's practically unmaintaned, it might be okay to raise it once (although I have no idea of when).

    1. Chris Moffitt repo owner

      I will try to take a look at it and make sure I can pull it in cleanly. I'll encourage others to test it out but I think it's shaping up nicely.

      1. Simone Deponti author

        I've modified slightly how wkhtml works because subprocess sometimes hangs if the data is quite big and pipes are being used, therefore I have switched to a tempfile-based approach.

        Also the LOGO_URI might need some rework because right now, if you put in a filename (file:) it won't work with the HTMLDocument (because it can't load such resource except when on localhost). Inversely, TRML and WKHTML might have problems when it is not a file: URI.

        It's probably best to have a default setting of '%(static)s/logo.png' and then the various document converters can fill that in either with settings.STATIC_ROOT or settings.STATIC_URL. This is not exactly critical (right now, changing the setting accordingly to one's setup makes everything work) but it might make things easier for newcomers.