Postgresql ValueError:字符串文字不能包含nul(0x00)字符
我在尝试导入用户时遇到此错误 NB: 该模块运行良好:我可以使用Odoo10和Postgres9.3Ubuntu14导入用户 但这里我使用的是Postgres9.5Odoo10Ubuntu16Postgresql ValueError:字符串文字不能包含nul(0x00)字符,postgresql,odoo-10,Postgresql,Odoo 10,我在尝试导入用户时遇到此错误 NB: 该模块运行良好:我可以使用Odoo10和Postgres9.3Ubuntu14导入用户 但这里我使用的是Postgres9.5Odoo10Ubuntu16 File "/home/belazar/Documents/addons_odoo10/hr_biometric_machine/models/biometric_machine.py", line 113, in create_user 'biometric_device': self.id
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.
该问题通过在
/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)
#从工具导入解析版本为pv
#如果pv(psycopg2.版本)
通过在/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)
#从工具导入解析版本为pv
#如果pv(psycopg2.版本)
错误有哪些地方不清楚?错误有哪些地方不清楚?