Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

[已解决]使用mass edit v11时报错,ERROR: relation "mass_object_id_seq" does not exist,



  • odoo11下mass edit点击保存时报错如下。在pgsql中还有一个区别就是:能使用mass edit的id显示的类型是serial,不能使用mass edit的id显示的是integer,如下图。
    这个怎么解决?

    2018-07-17 07:50:36,908 26191 ERROR 0711_v11 odoo.sql_db: bad query: b'INSERT INTO "mass_object" ("id", "model_id", "model_list", "name", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval(\'mass_object_id_seq\'), 77, \'[77]\', \'q\', 1, 1, (now() at time zone \'UTC\'), (now() at time zone \'UTC\')) RETURNING id'
    ERROR: relation "mass_object_id_seq" does not exist
    LINE 1: ...uid", "create_date", "write_date") VALUES(nextval('mass_obje...
                                                                 ^
    
    2018-07-17 07:50:36,909 26191 ERROR 0711_v11 odoo.http: Exception during JSON request handling.
    Traceback (most recent call last):
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/http.py", line 650, in _handle_exception
        return super(JsonRequest, self)._handle_exception(exception)
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/http.py", line 310, in _handle_exception
        raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/tools/pycompat.py", line 87, in reraise
        raise value
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/http.py", line 692, in dispatch
        result = self._call_function(**self.params)
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/http.py", line 342, in _call_function
        return checked_call(self.db, *args, **kwargs)
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/service/model.py", line 97, in wrapper
        return f(dbname, *args, **kwargs)
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/http.py", line 335, in checked_call
        result = self.endpoint(*a, **kw)
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/http.py", line 936, in __call__
        return self.method(*args, **kw)
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/http.py", line 515, in response_wrap
        response = f(*args, **kw)
      File "/home/hui/odoo-dev/odoo11/odoo11/addons/web/controllers/main.py", line 931, in call_kw
        return self._call_kw(model, method, args, kwargs)
      File "/home/hui/odoo-dev/odoo11/odoo11/addons/web/controllers/main.py", line 923, in _call_kw
        return call_kw(request.env[model], method, args, kwargs)
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/api.py", line 687, in call_kw
        return call_kw_model(method, model, args, kwargs)
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/api.py", line 672, in call_kw_model
        result = method(recs, *args, **kwargs)
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/models.py", line 3373, in create
        record = self.browse(self._create(old_vals))
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/models.py", line 3466, in _create
        cr.execute(query, tuple(u[2] for u in updates if len(u) > 2))
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/sql_db.py", line 155, in wrapper
        return f(self, *args, **kwargs)
      File "/home/hui/odoo-dev/odoo11/odoo11/odoo/sql_db.py", line 232, in execute
        res = self._obj.execute(query, params)
    psycopg2.ProgrammingError: relation "mass_object_id_seq" does not exist
    LINE 1: ...uid", "create_date", "write_date") VALUES(nextval('mass_obje...
                                                                 ^
    

    正常使用mass edit的数据库样子:0_1531817754241_serial.png
    报错使用mass edit的数据库的样子:0_1531817777565_int.png



  • @hui
    问题就出在这个id上,应该是数据库中所有的id都是通过序列自增实现的。都是通过nextval函数生成的,而且类型应该是serial才对的。
    但是安装了mass edit后,不知道怎么就生成integer类型的id了,所以使用的时候报错了。

    改正的方法:
    1、卸载掉mass edit模块,
    2、删除数据库的表mass_object,
    3、重新安装mass edit模块。
    检查数据库表中的mass_object,发现id的类型变为了serial。可以正常使用了。

    不知道第一次安装的时候,为啥就不能生成正确的id的类型?



  • @hui[已解决]ERROR: relation "mass_object_id_seq" does not exist 中说:

    删除数据库的表mass_object,
    上次我也遇到使用这个模块报错,不过是后台代码报错,目前也没有具体看了。



  • 现在就是不知道 字段类型 错的 那张表 是如何创建出来的,
    试着在原虚拟机环境下,出问题的那个数据库里:ubuntu 18.04装了下最原始的那个mass_edit_v11,发现表也是正常的,
    注意,官网的那个mass_edit_v11,有4个坑要填:
    1:目录名要修改为mass_edit,
    2:unlink_action 需要注释掉一行(感谢-石家庄老刘),

            # see line 27
            #self.mapped('ref_ir_value_id').sudo().unlink()
    

    3:就是model_domain那里要修改下,python3 map 取出来的是 object, 2.7取出来是list,改下xml文件比较好 (感谢小张)

      domain="[('ttype', 'not in', ['reference', 'function']), ('model_id', '=', model_id)]"/>
    

    4:mass_object.py中 keys = active_model_obj._inherits.keys() 下增加一行,这样就能正确用在那些 _inherits 继承的对象上了,比如 res.user用户(感谢小张):

    keys = list(keys) 
    

    改好的模块 我放github了: https://github.com/zykj/mass_edit_v11




Log in to reply