adhoc-dev / odoo-addons

DEPRECEATED, see README
GNU Affero General Public License v3.0
71 stars 124 forks source link

UTF-8 Compatibility in res_partner function def build_name #266

Closed lieblinger closed 8 years ago

lieblinger commented 8 years ago

Hi all,

thanks for your great Plugin we are really like to use it! But we have one Problem with the encoding of "ä ü ö", we alwys get this error:

Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 537, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 574, in dispatch result = self._call_function(_self.params) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 310, in _call_function return checked_call(self.db, args, _kwargs) File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 118, in wrapper return f(dbname, _args, _kwargs) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 307, in checked_call return self.endpoint(_a, _kw) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 803, in call return self.method(_args, _kw) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 403, in response_wrap response = f(_args, _kw) File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 944, in call_kw return self._call_kw(model, method, args, kwargs) File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 936, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, _args, _kwargs) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 256, in wrapper return old_api(self, _args, _kwargs) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 387, in old_api result = method(recs, _args, _kwargs) File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 5957, in onchange record._onchange_eval(name, field_onchange[name], result) File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 5815, in _onchange_eval method_res = method(self) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 254, in wrapper return new_api(self, _args, _kwargs) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 431, in new_api result = [method(rec, _args, _kwargs) for rec in self] File "/var/lib/odoo/.local/share/Odoo/addons/8.0/partner_person/res_partner.py", line 153, in build_name print 'name', self.name UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 18: ordinal not in range(128)

And we are only able to fix it if we add the following to the build_name function:

@api.one @api.onchange('firstname', 'lastname') @api.constrains('firstname', 'lastname') def build_name(self): print 'build_name' if self.lastname and self.firstname: self.name = '%s %s' % ( self.lastname or '', self.firstname or '') print 'name', self.name.encode('utf8')

Can you update your module for utf8 compatibility?

Would be really nice to hearing from you in the near future!

Regards Yannik

jjscarafia commented 8 years ago

Hi Yannik, can you please make a PR? But please make it against https://github.com/ingadhoc/partner This repository has been depreceated as you can see herehttps://github.com/ingadhoc/odoo-addons/blob/8.0/README.md