【问题标题】:ValueError: a string literal cannot contain nul (0x00) characters odooValueError:字符串文字不能包含 nul (0x00) 字符 odoo
【发布时间】:2017-07-12 11:16:41
【问题描述】:

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

注意:

该模块运行良好:我可以使用 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.

【问题讨论】:

  • 错误有什么不清楚的地方?

标签: postgresql odoo-10


【解决方案1】:

问题通过/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)

【讨论】:

    猜你喜欢
    • 2019-12-13
    • 1970-01-01
    • 2012-02-06
    • 1970-01-01
    • 1970-01-01
    • 2020-09-05
    • 1970-01-01
    • 2018-02-25
    • 2021-11-16
    相关资源
    最近更新 更多