[trunk] base_contact module error

Bug #919982 reported by Paul Korotkov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Incomplete
Undecided
Unassigned

Bug Description

openobject-addons trunk base_contact, openerp-web
Error when try to create new contact.

Traceback (most recent call last):
  File "/home/prospwro/openerp/server/openerp/osv/osv.py", line 120, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/prospwro/openerp/server/openerp/osv/osv.py", line 175, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/prospwro/openerp/server/openerp/osv/osv.py", line 163, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/prospwro/openerp/server/openerp/osv/orm.py", line 4154, in create
    cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2))
  File "/home/prospwro/openerp/server/openerp/sql_db.py", line 152, in wrapper
    return f(self, *args, **kwargs)
  File "/home/prospwro/openerp/server/openerp/sql_db.py", line 214, in execute
    res = self._obj.execute(query, params)
TypeError: can't escape unicode to binary

Revision history for this message
Vishal Parmar(Open ERP) (vpa-openerp) wrote :

Hello Paul Korotkov,

I have checked your issue with latest updated code of trunk with web(6.1) but I didn't face any problem at my end.

Following revision of Trunk :

server - 3976
Gtk - 2035
New web(6.1) - 2025
addons - 6370

Would you please try again with updated code. See attached video and informed us where you faced the problem.

Thanks and waiting for your reply.

Revision history for this message
Vishal Parmar(Open ERP) (vpa-openerp) wrote :
Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Paul Korotkov (korotkov-paul) wrote :
Download full text (4.2 KiB)

Hello Vishal.
I saw video. you recorded. Actions i made to reproduce bug are following
latest trunk of server,web, addons
i connect to server via web localhost:8069
create new database with no demo data , english language.
After creation of new database i setup module base_contact, dont do any changes in access rights (partner manager, extended etc.)
i go to 'purchases' menu, select contacts, press new button, fill first name, second name, then click save
result - error
SERVER LOG:
[2012-01-23 13:40:38,305][?] ERROR:db.cursor:bad query: insert into "res_partner_contact" (id,"website","first_name","last_name","title","mobile","photo","country_id","birthdate","email","lang_id","active","comment",create_uid,create_date) values (3,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,now())
Traceback (most recent call last):
  File "/home/prospwro/openerp/server/openerp/sql_db.py", line 214, in execute
    res = self._obj.execute(query, params)
TypeError: can't escape unicode to binary
[2012-01-23 13:40:38,306][?] ERROR:web-services:Uncaught exception
Traceback (most recent call last):
  File "/home/prospwro/openerp/server/openerp/osv/osv.py", line 120, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/prospwro/openerp/server/openerp/osv/osv.py", line 175, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/prospwro/openerp/server/openerp/osv/osv.py", line 163, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/prospwro/openerp/server/openerp/osv/orm.py", line 4154, in create
    cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2))
  File "/home/prospwro/openerp/server/openerp/sql_db.py", line 152, in wrapper
    return f(self, *args, **kwargs)
  File "/home/prospwro/openerp/server/openerp/sql_db.py", line 214, in execute
    res = self._obj.execute(query, params)
TypeError: can't escape unicode to binary

POPUP SCREEN IN WEB CLIENT:

Client Traceback (most recent call last):
  File "/home/prospwro/openerp/server/openerp/addons/web/common/http.py", line 180, in dispatch
    response["result"] = method(controller, self, **self.params)
  File "/home/prospwro/openerp/server/openerp/addons/web/controllers/main.py", line 820, in create
    r = m.create(data, req.session.eval_context(req.context))
  File "/home/prospwro/openerp/server/openerp/addons/web/common/openerplib/main.py", line 250, in proxy
    args, kw)
  File "/home/prospwro/openerp/server/openerp/addons/web/common/openerplib/main.py", line 117, in proxy
    result = self.connector.send(self.service_name, method, *args)
  File "/home/prospwro/openerp/server/openerp/addons/web/common/http.py", line 609, in send
    raise fault

Server Traceback (most recent call last):
  File "/home/prospwro/openerp/server/openerp/addons/web/common/http.py", line 590, in send
    result = openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/prospwro/openerp/server/openerp/netsvc.py", line 324, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/prospwro/openerp/server/openerp/service/web_services.py", line 583, in dispa...

Read more...

Revision history for this message
Vishal Parmar(Open ERP) (vpa-openerp) wrote :

Hello Paul Korotkov,

Thanks for your reply.

I have applied same scenario as per you have describe in #3 but It's working normally at end with latest trunk.
See attached video for it and informed us still you faced the same problem ? would you please give your end
video what you did ?.

Thanks and waiting for your reply.

Revision history for this message
Vishal Parmar(Open ERP) (vpa-openerp) wrote :
Revision history for this message
Paul Korotkov (korotkov-paul) wrote :

Hello Vishal Parmar,

Thanks for video. But i still didnt fix problem. Here is my video. (recent update from trunk 2 hours ago)

Revision history for this message
Paul Korotkov (korotkov-paul) wrote :

Maybe bug https://bugs.launchpad.net/bugs/899794 has the same roots, but problem which i found is something different.
Maybe problem connected with specific package versions of postgresql, psycopg and some other packages. I use archlinux with latest package versions and maybe this doesnt allow reproduce bug in other more conservative distributions.
But i find next features. Bug is reproducible on all my machines under archlinux with latest packages and not random but constant. after some research i found that bug is in saving image field into database. Hence addons that are affected are base_contact, hr, product. When i drop image - all works in all modules - all new records are saved. But when i choose default or any other image as contact photo employee photo or product image - saving fails.

Revision history for this message
Rui Barreiros (rbarreiros) wrote :

Hi,

I'm using Ubuntu 10.04 with Postgresql 8.4.10, psycopg 2.4.4, Openerp 6.1 RC1 and got struck with this error too. All forms with binary fields in the model were causing this error.

After fiddling in google, I found this bug report http://psycopg.lighthouseapp.com/projects/62710/tickets/51-typeerror-cant-escape-unicode-to-binary-writing-unicode-into-bytea which made me suspicious that openerp was trying to convert to binary the form field as unicode, thus psycopg threw the error.

I have no idea if this is the right fix, but what I did to sort it out was to cast the form field content as a string before the binary conversion by psycopg in osv/fields.py the end result is:

_symbol_f = lambda symb: symb and Binary(str(symb)) or None

on line 296 of osv/fields.py

Again, I have no idea whatsoever if this is the right fix, I'm sure this is where the problem is caused though.

Best regards,

Revision history for this message
Paul Korotkov (korotkov-paul) wrote :

Thanks, Rui it works

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.