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

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

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

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

产品类别不能删除的Bug



  • 产品类别下的所有产品已经删除,但该类别不能删除,错误日志:
    Traceback (most recent call last):
      File "modules\gui\main.pyo", line 1334, in _sig_child_call
      File "modules\gui\window\form.pyo", line 263, in sig_remove
      File "widget\screen\screen.pyo", line 522, in remove
      File "rpc.pyo", line 349, in call
      File "rpc.pyo", line 170, in rpc_exec_auth
      File "rpc.pyo", line 113, in exec_auth
      File "rpc.pyo", line 119, in execute
      File "tiny_socket.pyo", line 81, in myreceive
    tiny_socket.Myexception: ('warning -- Integrity Error\n\nnull value in column "categ_id" violates not-null constraint\nCONTEXT:  SQL statement "UPDATE ONLY "public"."product_template" SET "categ_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "categ_id""\n', 'Traceback (most recent call last):\n  File "netsvc.pyo", line 256, in dispatch\n  File "netsvc.pyo", line 76, in call\n  File "service\web_services.pyo", line 577, in execute\n  File "osv\osv.pyo", line 70, in wrapper\n  File "netsvc.pyo", line 61, in abortResponse\nException: warning -- Integrity Error\n\nnull value in column "categ_id" violates not-null constraint\nCONTEXT:  SQL statement "UPDATE ONLY "public"."product_template" SET "categ_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "categ_id""\n\n')

    原因是当product.product记录删除后,product.template并没有跟着删除
    附修复记录的脚本,请在执行时先做好备份,本人不对该脚本产生的任何后果负责。

    [code]
    # -- encoding: utf-8 --
    #修复删除产品后product.template记录没有删除的数据

    import xmlrpclib  #导入xmlrpc库,这个库是python的标准库。
    #dbname = raw_input(u"输入帐套:\n")
    dbname = 'xxxxxx'
    username ='admin' #用户登录名
    pwd = 'xxxxxxx' #用户的登录密码,测试时请换成自己的密码

    # 第一步,取得uid
    sock_common = xmlrpclib.ServerProxy ('http://127.0.0.1:8069/xmlrpc/common')
    uid = sock_common.login(dbname, username, pwd)
    sock = xmlrpclib.ServerProxy('http://127.0.0.1:8069/xmlrpc/object')

    p_ids = sock.execute(dbname, uid, pwd, 'product.product', 'search',[],0,20000,'id')
    print p_ids
    vals = sock.execute(dbname, uid, pwd,'product.product', 'read', p_ids,['id','name','product_tmpl_id'])
    t_idok=[]
    for v in vals:
        t_idok.append(v['product_tmpl_id'][0])
    print u'product_tmpl_id 列表'
    print t_idok

    del_t=sock.execute(dbname, uid, pwd, 'product.template', 'search',[('id','not in',t_idok)])
    ok_t=sock.execute(dbname, uid, pwd, 'product.template', 'search',[('id','in',t_idok)])
    print '正常的 product_tmpl_id 列表'
    print ok_t
    print '不存在的 product_tmpl_id 列表-'
    print del_t
    sock.execute(dbname, uid, pwd, 'product.template', 'unlink',del_t)
    print u"设置完成"

    [/code]

    修复记录不是最终的解决方案,请哪位大虾提供下修复的方案!!!



  • 产品类别下的所有产品已经删除,但该类别不能删除,错误日志:
    Traceback (most recent call last):
      File "modules\gui\main.pyo", line 1334, in _sig_child_call
      File "modules\gui\window\form.pyo", line 263, in sig_remove
      File "widget\screen\screen.pyo", line 522, in remove
      File "rpc.pyo", line 349, in call
      File "rpc.pyo", line 170, in rpc_exec_auth
      File "rpc.pyo", line 113, in exec_auth
      File "rpc.pyo", line 119, in execute
      File "tiny_socket.pyo", line 81, in myreceive
    tiny_socket.Myexception: ('warning -- Integrity Error\n\nnull value in column "categ_id" violates not-null constraint\nCONTEXT:  SQL statement "UPDATE ONLY "public"."product_template" SET "categ_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "categ_id""\n', 'Traceback (most recent call last):\n  File "netsvc.pyo", line 256, in dispatch\n  File "netsvc.pyo", line 76, in call\n  File "service\web_services.pyo", line 577, in execute\n  File "osv\osv.pyo", line 70, in wrapper\n  File "netsvc.pyo", line 61, in abortResponse\nException: warning -- Integrity Error\n\nnull value in column "categ_id" violates not-null constraint\nCONTEXT:  SQL statement "UPDATE ONLY "public"."product_template" SET "categ_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "categ_id""\n\n')

    原因是当product.product记录删除后,product.template并没有跟着删除
    附修复记录的脚本,请在执行时先做好备份,本人不对该脚本产生的任何后果负责。

    [code]
    # -- encoding: utf-8 --
    #修复删除产品后product.template记录没有删除的数据

    import xmlrpclib  #导入xmlrpc库,这个库是python的标准库。
    #dbname = raw_input(u"输入帐套:\n")
    dbname = 'xxxxxx'
    username ='admin' #用户登录名
    pwd = 'xxxxxxx' #用户的登录密码,测试时请换成自己的密码

    # 第一步,取得uid
    sock_common = xmlrpclib.ServerProxy ('http://127.0.0.1:8069/xmlrpc/common')
    uid = sock_common.login(dbname, username, pwd)
    sock = xmlrpclib.ServerProxy('http://127.0.0.1:8069/xmlrpc/object')

    p_ids = sock.execute(dbname, uid, pwd, 'product.product', 'search',[],0,20000,'id')
    print p_ids
    vals = sock.execute(dbname, uid, pwd,'product.product', 'read', p_ids,['id','name','product_tmpl_id'])
    t_idok=[]
    for v in vals:
        t_idok.append(v['product_tmpl_id'][0])
    print u'product_tmpl_id 列表'
    print t_idok

    del_t=sock.execute(dbname, uid, pwd, 'product.template', 'search',[('id','not in',t_idok)])
    ok_t=sock.execute(dbname, uid, pwd, 'product.template', 'search',[('id','in',t_idok)])
    print '正常的 product_tmpl_id 列表'
    print ok_t
    print '不存在的 product_tmpl_id 列表-'
    print del_t
    sock.execute(dbname, uid, pwd, 'product.template', 'unlink',del_t)
    print u"设置完成"

    [/code]

    修复记录不是最终的解决方案,请哪位大虾提供下修复的方案!!!



  • 最简单的莫过于 去数据库里, 修改  product_template 表结构 中的 categ_id 字段 把"非空"的勾选去掉...

    或者修改  addons\product\product.py 文件中 product.template 对象的 categ_id 字段的 required="True" 去掉, 或者改为 "False" 然后 重新更新模块(是否更新有效, 需要小白鼠测试")



  • 为什么OE在删除product.product的记录时不一起删掉product.template中的记录,难道product.template中的记录要永久保存?



  • 嗯. 这个应该是系统BUG了... 不知道官方有没有人报出来


登录后回复
 

与 Odoo 中文社区 的连接断开,我们正在尝试重连,请耐心等待