Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when non-unicode char un "name" field of ir.actions.report.xml with parser #55

Open
alexis-via opened this issue Apr 30, 2015 · 0 comments
Assignees
Labels

Comments

@alexis-via
Copy link
Contributor

If you define in an XML file an aeroo report with a "name" field that has a non-ASCII character, you will get this error message in the logs when you install the module:

report_aeroo: Error loading report parser: 'ascii' codec can't encode character u'\xe7' in position 33: ordinal not in range(128)

Example of a file report.xml that fails:

<record id="pos_receipt_invoice_style" model="ir.actions.report.xml">
    <field name="name">Reçu style facture</field>
    <field name="model">pos.order</field>
    <field name="report_name">pos.order.invoice.style</field>
    <field name="report_type">aeroo</field>
    <field name="in_format">oo-odt</field>
    <field name="report_rml">bug_encoding/report/receipt_invoice_style.odt</field>
    <field name="parser_state">loc</field>
    <field name="parser_loc">bug_encoding/report/receipt_invoice_style.py</field>
    <field name="tml_source">file</field>
    <field name="multi" eval="0"/>
    <field name="attachment_use" eval="0"/>
    <field name="out_format" ref="report_aeroo.report_mimetypes_pdf_odt"/>
    <field name="fallback_false" eval="0"/>
    <field name="styles_mode">default</field>
</record>

Code analysis:
The crash happens in report_aeroo/report_xml.py line 124 on:

py_mod = imp.load_source(mod_name, filepath)

the variable mod_name contains "o8_test1_receipt_invoice_style_reçu_style_facture" that has a non-ascii char and it fails.
This comes from the "key" variable, which is an argument of the method load_from_file(). This method is called from the create() method line 537 of report_xml.py:

parser=self.load_from_file(vals['parser_loc'], vals['name'].lower().replace(' ','_')) or parser

vals['name'] is the "name" field of the object ir.actions.report.xml, which may contains non-ascii characters.

It don't know what is the proper solution to solve this. Could we use vals['report_name'] ? Should we use unidecode() to remove the non-ascii chars ?

@sraps sraps added the bug label Sep 29, 2015
@sraps sraps self-assigned this Sep 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants