ValueError:字符串文字不能包含nul(0x00)个字符odoo

时间:2017-07-12 11:16:42

标签: postgresql odoo-10

我尝试导入用户时收到此错误

NB:

该模块工作正常:我可以使用odoo 10和postgres 9.3 ubuntu 14导入用户

但是我在这里使用postgres 9.5 odoo 10 ubuntu 16

  File "/home/belazar/Documents/addons_odoo10/hr_biometric_machine/models/biometric_machine.py", line 113, in create_user
    'biometric_device': self.id, }
  File "/opt/odoo/odoo/models.py", line 3830, in create
    record = self.browse(self._create(old_vals))
  File "/opt/odoo/odoo/models.py", line 3925, in _create
    cr.execute(query, tuple(u[2] for u in updates if len(u) > 2))
  File "/opt/odoo/odoo/sql_db.py", line 154, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/odoo/odoo/sql_db.py", line 231, in execute
    res = self._obj.execute(query, params)
ValueError: A string literal cannot contain NUL (0x00) characters.

1 个答案:

答案 0 :(得分:-2)

通过/opt/odoo/odoo/sql_db.py对这些行进行评论来解决问题:

#from tools import parse_version as pv
#if pv(psycopg2.__version__) < pv('2.7'):
#   from psycopg2._psycopg import QuotedString
  #  def adapt_string(adapted):
   #     """Python implementation of psycopg/psycopg2#459 from v2.7"""
    #    if '\x00' in adapted:
     #       raise ValueError("A string literal cannot contain NUL (0x00) characters.")
      #  return QuotedString(adapted)

    #psycopg2.extensions.register_adapter(str, adapt_string)
    #psycopg2.extensions.register_adapter(unicode, adapt_string)