Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:无法将字典更新序列元素#0转换为序列_Python_Postgresql_Odoo 8 - Fatal编程技术网

Python TypeError:无法将字典更新序列元素#0转换为序列

Python TypeError:无法将字典更新序列元素#0转换为序列,python,postgresql,odoo-8,Python,Postgresql,Odoo 8,我正在尝试选择具有特定代码值的“fleet_vehicle”对象的Id class fleet_inventory_line(osv.osv): . . . def find_vehicle_id(self, cr, uid, ids, args, field_name, context=None): cr.execute("""SELECT l.id

我正在尝试选择具有特定代码值的“fleet_vehicle”对象的Id

        class fleet_inventory_line(osv.osv):
    .
    .
    .

        def find_vehicle_id(self, cr, uid, ids, args, field_name, context=None):
            cr.execute("""SELECT
                          l.id
                        FROM
                          fleet_vehicle l
                        WHERE
                          code = 'MR444' """)
            res = cr.fetchone()
            return res
.
.
.
    _columns = {
        'x_vehicle_id': fields.function(find_vehicle_id, type='integer', string='vehicle id'),
    }
我有以下错误:

TypeError:无法将字典更新序列元素#0转换为 序列

我认为问题在于:

res = cr.fetchone()
因为我试图返回一个整数,但我没有找到解决方案,所以我很乐意提供任何帮助

编辑:回溯

回溯(最近一次呼叫最后一次):

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\http.py“,第537行,在异常处理中

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\http.py“,第574行,调度中

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\http.py“,第310行,在调用函数中

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\service\model.py“,第118行,包装中

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\http.py“,第307行,在checked_调用中

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\http.py“,第803行,在调用中

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\http.py“,第403行,作为回应

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server\openerp\addons\web\controllers\main.py“,第944行,在call\u kw中

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server\openerp\addons\web\controllers\main.py”,第936行,输入

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\api.py“,包装中的第268行

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\models.py“,第3145行,已读

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\api.py“,包装中第266行

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\models.py“,第3180行,已读

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\api.py“,包装中第266行

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\models.py“,第3367行,从数据库读取

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\osv\fields.py“,get中第1478行

文件“D:\MesDocuments\Les\u prog\Odoo 8.0-20160118\server.\openerp\osv\fields.py“,第1439行,在后处理批处理中

TypeError:无法将字典更新序列元素#0转换为 序列


答案是我必须使用

res=cr.dictfetchone()

而不是

res=cr.fetchone()


你认为问题出在那条线上?什么是回溯?您知道什么对象
cr.fetchone()
实际返回,以及它的类型吗?如果不是,你应该调查一下。