Problem statement

Since OpenERP 5.x from 2009 I’ve never got working “Trial balance” financial report. The very important fact is that I use “Swiss localization” (l18ch) from camp2camp. Swiss localization allows to create Swiss chart of accounts. However, for unknown reasons, many standard reports doesn’t work.

In this article I provide a simple fix for the “Trial balance” report, I have found after many hours of debugging and code studying…

Symptoms:

Unfortunately, OpenERP is very poor written system. It fails in different places, providing misleading error. I hope that after my explanation you will see why I use the term “poor written”. In my opinion, the company invites programmers with “basic” knowledge of programming style and it never follows or even create a sort of “good programming practice”.

Well, in my case, every time when I started the “Trial balance”, the system just reports about internal server error without any details at client side. Well, if I run server in terminal, I can finally found that system caught a bug as follows:

  • OpenERP server error log

    ERROR ? openerp.service.web_services: Exception: list index out of rangeparagraph text u'<para>(d&#233;biteurs-clients)</font></para>' caused exception Traceback (most recent call last):

      File "/usr/share/openerp/service/web_services.py", line 727, in go     (result, format) = obj.create(cr, uid, ids, datas, context)

      File "/usr/share/openerp/report/report_sxw.py", line 440, in create     fnct_ret = fnct(cr, uid, ids, data, report_xml, context)

      File "/usr/share/openerp/report/report_sxw.py", line 509, in create_source_pdf     return self.create_single_pdf(cr, uid, ids, data, report_xml, context)

      File "/usr/share/openerp/report/report_sxw.py", line 531, in create_single_pdf     pdf = create_doc(etree.tostring(processed_rml),rml_parser.localcontext,logo,title.encode('utf8'))

      File "/usr/share/openerp/report/interface.py", line 207, in create_pdf

        obj.render()

      File "/usr/share/openerp/report/render/render.py", line 59, in render

        self._result = self._render()

      File "/usr/share/openerp/report/render/rml.py", line 41, in _render

        return rml2pdf.parseNode(self.rml, self.localcontext, images=self.bin_datas, path=self.path,title=self.title)

      File "/usr/share/openerp/report/render/rml2pdf/trml2pdf.py", line 1007, in parseNode

        r.render(fp)

      File "/usr/share/openerp/report/render/rml2pdf/trml2pdf.py", line 314, in render

        pt_obj.render(el)

      File "/usr/share/openerp/report/render/rml2pdf/trml2pdf.py", line 983, in render

        fis += r.render(node_story)

      File "/usr/share/openerp/report/render/rml2pdf/trml2pdf.py", line 877, in render

        return process_story(node_story)

      File "/usr/share/openerp/report/render/rml2pdf/trml2pdf.py", line 870, in process_story

        flow = self._flowable(node)

      File "/usr/share/openerp/report/render/rml2pdf/trml2pdf.py", line 793, in _flowable

        return  self._table(node)

      File "/usr/share/openerp/report/render/rml2pdf/trml2pdf.py", line 677, in _table

        fl = self._flowable(n, extra_style=paraStyle)

      File "/usr/share/openerp/report/render/rml2pdf/trml2pdf.py", line 746, in _flowable

        result.append(platypus.Paragraph(i, style, **(utils.attr_get(node, [], {'bulletText':'str'}))))

      File "/usr/lib/python2.7/dist-packages/reportlab/platypus/paragraph.py", line 988, in __init__

        self._setup(text, style, bulletText or getattr(style,'bulletText',None), frags, cleanBlockQuotedText)

      File "/usr/lib/python2.7/dist-packages/reportlab/platypus/paragraph.py", line 1010, in _setup

        style, frags, bulletTextFrags = _parser.parse(text,style)

      File "/usr/lib/python2.7/dist-packages/reportlab/platypus/paraparser.py", line 1147, in parse

        annotateException('paragraph text %s caused exception' % ascii(text))

      File "/usr/lib/python2.7/dist-packages/reportlab/lib/utils.py", line 1337, in annotateException

        rl_reraise(t,v,b)

      File "/usr/lib/python2.7/dist-packages/reportlab/platypus/paraparser.py", line 1145, in parse

        self.feed(text)

      File "/usr/lib/python2.7/HTMLParser.py", line 117, in feed

        self.goahead(0)

      File "/usr/lib/python2.7/HTMLParser.py", line 163, in goahead

        k = self.parse_endtag(i)

      File "/usr/lib/python2.7/HTMLParser.py", line 401, in parse_endtag

        self.handle_endtag(elem)

      File "/usr/lib/python2.7/dist-packages/reportlab/platypus/paraparser.py", line 1181, in handle_endtag

        end()

      File "/usr/lib/python2.7/dist-packages/reportlab/platypus/paraparser.py", line 834, in end_para

        self._pop()

      File "/usr/lib/python2.7/dist-packages/reportlab/platypus/paraparser.py", line 985, in _pop

        frag = self._stack[-1]

    IndexError: list index out of rangeparagraph text u'<para>(clients-debtors)</font></para>' caused exception

    769 15542 ERROR ? openerp.netsvc: list index out of rangeparagraph text u'<para>(d&#233;biteurs-clients)</font></para>' caused exception

    (<type 'exceptions.IndexError'>, IndexError("list index out of rangeparagraph text u'<para>(d&#233;biteurs-clients)</font></para>' caused exception",), <traceback object at 0x7f9a408f04d0>)

    770 15542 ERROR ? openerp.service.netrpc_server: netrpc: cannot deliver exception message to client

    Traceback (most recent call last):

      File "/usr/share/openerp/service/netrpc_server.py", line 71, in run

        valid_exception = Exception(netrpc_handle_exception_legacy(e))

      File "/usr/share/openerp/service/netrpc_server.py", line 93, in netrpc_handle_exception_legacy

        return 'warning -- ' + e.name + '\n\n' + e.value

    TypeError: coercing to Unicode: need string or buffer, tuple found

Well, you can see, that at the beginning there are many possible reasons why it can not working. The message is completely unclear…

On the client side one gets the error as follows:

image    and    image

So, those messages give no clue, what the problem might be.

Analysis:

I started from thinking that the problem causes by a special character in the string as follows: <strong>&#233;</strong> and I spent considerable amount of time to find out that it doesn’t help. I fixed a potential Unicode bug in reportlib here, I fixed another very annoyed bug with pywebdav which exists since my migration on Ubunut 14.04 which is described here, I checked many as I thought related issues like this one or another one.

But when I installed WinpDb on Ubuntu computer as it described here and debugged the code of the report generation, I start thinking that the bug might be created by content.

Well, this assumption was really got, the only question was to find which content can produce a bug. Having hundreds accounts don’t allow to do so in an easy way.

Finally, search by string in the error server log, pointed me onto multilingual name of Financial account with the code 110.0 in OpenERP->Accounting->Configuration->Financial Accounting->Accounts->Accounts.

Receivables from sales and services
            (débiteurs-clients)

As you can see here, the name has 2 row but in the OpenERP GUI it shows as a string… so you have no idea that it contains break line character and thus this character is the root of the problem!

Fix:

Well, as soon as I changed the name of the account by replacing the original name by anything else from scratch or if I remove everything between services and (débiteurs words, and put there space or any others characters, it works.

What is a miracle!!! That is why OpenERP developers never accept such a problem as a bug and ask their client to find the problem by themselves!

So, the reason of the bug was a symbol in the name of account!

Final words

As I wrote before - it looks like the company for programmers, who create OpenERP code, must create and apply a programming style guidelines, which force them to check strings in such places of the system for prohibited characters and thus avoid such problems in the future!

Hope, this article can help someone else from Switzerland to fix the unavailability of standard financial OpenERP reports.

About Us

Out Mission

Our mission is to fill the gap between modern technologies and real life experience.

Our Goal

Together with our customers gain in revenue and business efficiency by using cutting-edge technologies.

Payment Methods

We are using secure Paypal & Money-bookers payment method as well as wire transfer. You can pay directly form your Credit Card via Moneybookers or Paypal and NEVER store your card information on our site

Contact Us

Address : Chemin Vert 9, 1804 Corsier-sur-Vevey, Canton Vaud, Switzerland
Phone : +41 (21) 522.07.20