l10n_be crash when saving xml partner vat listing

Bug #367813 reported by Fabien Lydoire @ Taktik
2
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Undecided
Jay Vora (Serpent Consulting Services)

Bug Description

v5.0.0-3 and trunk

Traceback (most recent call last):
  File "/Users/flydoire/Downloads/openerp/server/bin/netsvc.py", line 235, in dispatch
    result = LocalService(service_name)(method, *params)
  File "/Users/flydoire/Downloads/openerp/server/bin/netsvc.py", line 74, in __call__
    return getattr(self, method)(*params)
  File "/Users/flydoire/Downloads/openerp/server/bin/service/web_services.py", line 553, in execute
    return self._execute(db, uid, wiz_id, datas, action, context)
  File "/Users/flydoire/Downloads/openerp/server/bin/service/web_services.py", line 533, in _execute
    return wiz.execute(db, uid, self.wiz_datas[wiz_id], action, context)
  File "/Users/flydoire/Downloads/openerp/server/bin/wizard/__init__.py", line 178, in execute
    res = self.execute_cr(cr, uid, data, state, context)
  File "/Users/flydoire/Downloads/openerp/server/bin/wizard/__init__.py", line 74, in execute_cr
    action_res = action(self, cr, uid, data, context)
  File "/Users/flydoire/Downloads/openerp/server/bin/addons/l10n_be/wizard/partner_vat_listing.py", line 106, in _create_xml
    data_file +='\n<AgentRepr DecNumber="1">\n\t<CompanyInfo>\n\t\t<VATNum>'+str(company_vat)+'</VATNum>\n\t\t<Name>'+str(obj_cmpny.name)+'</Name>\n\t\t<Street>'+ str(street) +'</Street>\n\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>'
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

Proposed patch
--- bin/addons/l10n_be/wizard/partner_vat_listing.py (revision 6806)
+++ bin/addons/l10n_be/wizard/partner_vat_listing.py (working copy)
@@ -177,7 +177,7 @@
         data_file += str(data_decl) + str(data_comp) + str(data_period) + str(data_clientinfo) + '\n</VatList>'

         data['form']['msg']='Save the File with '".xml"' extension.'
- data['form']['file_save']=base64.encodestring(data_file)
+ data['form']['file_save']=base64.b64encode(data_file)
         return data['form']

     states = {

Related branches

Changed in openobject-addons:
status: New → Confirmed
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Are you French language pack?

I think this error comes with any non-English characters.

Thanks a ton for reporting.

Changed in openobject-addons:
assignee: nobody → jvo-openerp
status: Confirmed → In Progress
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Are you using French language pack?

I think this error comes with any non-English characters.

Thanks a ton for reporting.

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Fixed in revision 2304(addons/5.0).

Kindly check it and notify us.
Thanks.

Changed in openobject-addons:
status: In Progress → Fix Released
Revision history for this message
Fabien Lydoire @ Taktik (fl-taktik) wrote :

I'm working in Belgium where we use characters outside the ASCII-128 range.
Basically, we wish OpenERP would works with unicode correctly...
Thanks !

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Welcome,
Is it working fine at your end now?

Revision history for this message
Fabien Lydoire @ Taktik (fl-taktik) wrote :

Working with rev 2304.
I propose a patch for <MandataireId> though since I don't know if there could be accents there.

--- l10n_be/wizard/partner_vat_listing.py 2009-04-27 12:41:16 +0000
+++ l10n_be/wizard/partner_vat_listing.py 2009-04-27 13:41:14 +0000
@@ -100,7 +100,7 @@
         sender_date = time.strftime('%Y-%m-%d')

         data_file = '<?xml version="1.0"?>\n<VatList xmlns="http://www.minfin.fgov.be/VatList" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.minfin.fgov.be/VatList VatList.xml" RecipientId="VAT-ADMIN" SenderId="'+ str(company_vat) + '"'
- data_file +=' ControlRef="'+ cref + '" MandataireId="'+ data['form']['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"'
+ data_file +=' ControlRef="'+ cref + '" MandataireId="'+ tools.ustr(data['form']['mand_id']) + '" SenderDate="'+ str(sender_date)+ '"'
         if data['form']['test_xml']:
             data_file += ' Test="0"'
         data_file += ' VersionTech="1.2">'

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

I guess you are right.
We should leave no place where this can happen anymore.

Thank you for your response.

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Re-Corrected by revision 2822 <email address hidden>.

Changed in openobject-addons:
milestone: none → 5.0.13
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.