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并没有跟着删除
    附修复记录的脚本,请在执行时先做好备份,本人不对该脚本产生的任何后果负责。

    <br /># -*- encoding: utf-8 -*-<br />#修复删除产品后product.template记录没有删除的数据<br /><br />import xmlrpclib&nbsp; #导入xmlrpc库,这个库是python的标准库。<br />#dbname = raw_input(u&quot;输入帐套:\n&quot;)<br />dbname = &#039;xxxxxx&#039;<br />username =&#039;admin&#039; #用户登录名<br />pwd = &#039;xxxxxxx&#039; #用户的登录密码,测试时请换成自己的密码<br /><br /># 第一步,取得uid<br />sock_common = xmlrpclib.ServerProxy (&#039;http://127.0.0.1:8069/xmlrpc/common&#039;)<br />uid = sock_common.login(dbname, username, pwd)<br />sock = xmlrpclib.ServerProxy(&#039;http://127.0.0.1:8069/xmlrpc/object&#039;)<br /><br />p_ids = sock.execute(dbname, uid, pwd, &#039;product.product&#039;, &#039;search&#039;,&#91;],0,20000,&#039;id&#039;)<br />print p_ids<br />vals = sock.execute(dbname, uid, pwd,&#039;product.product&#039;, &#039;read&#039;, p_ids,&#91;&#039;id&#039;,&#039;name&#039;,&#039;product_tmpl_id&#039;])<br />t_idok=&#91;]<br />for v in vals:<br />&nbsp; &nbsp; t_idok.append(v&#91;&#039;product_tmpl_id&#039;][0])<br />print u&#039;product_tmpl_id 列表&#039;<br />print t_idok<br /><br />del_t=sock.execute(dbname, uid, pwd, &#039;product.template&#039;, &#039;search&#039;,[(&#039;id&#039;,&#039;not in&#039;,t_idok)])<br />ok_t=sock.execute(dbname, uid, pwd, &#039;product.template&#039;, &#039;search&#039;,[(&#039;id&#039;,&#039;in&#039;,t_idok)])<br />print &#039;正常的 product_tmpl_id 列表&#039;<br />print ok_t<br />print &#039;不存在的 product_tmpl_id 列表-&#039;<br />print del_t<br />sock.execute(dbname, uid, pwd, &#039;product.template&#039;, &#039;unlink&#039;,del_t)<br />print u&quot;设置完成&quot;<br /><br />
    



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



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

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



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



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