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

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

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

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

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

第一次用代码 创建 产品 遇挫



  • 第一次用代码 创建 产品,失败了
    现象是 OE 拼起来的SQL 中 缺少了一个关键字段少了name 字段:

    2013-01-31 08:54:06,545 7400 ERROR t72 openerp.sql_db: Programming error: can't adapt type 'instancemethod', in query insert into "product_template" (id,"supply_method","uos_id","list_price","description","standard_price","mes_type","uom_id","categ_id","cost_method","name","uos_coeff","volume","sale_delay","procure_method","sale_ok","purchase_ok","company_id","produce_delay","uom_po_id","rental","type",create_uid,create_date,write_uid,write_date) values (3261,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,(now() at time zone 'UTC'),%s,(now() at time zone 'UTC'))
    2013-01-31 08:54:10,292 7400 ERROR t72 openerp.osv.osv: Uncaught exception


    mrshelly 帮指了路,先减少字段,
    果然,减少到只有几个 字段后,
    create 就OK 了


    <br /><br />&nbsp; &nbsp; &nbsp; &nbsp; ## 下一步,创建一个 模版 制品,需要的参数从该 模版产品 中复制<br />&nbsp; &nbsp; &nbsp; &nbsp; vals = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;name&#039;: &#039;gsgcp&#039; , #+ mmold.stand_name<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;description&#039;: &#039;auto create&#039;, #&nbsp; 队<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;type&#039;: &#039;product&#039;, # 产品类型 <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  #&nbsp; &nbsp; &nbsp; &nbsp;  &#039;active&#039;: True, # 生效<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;categ_id&#039;: categ_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;list_price&#039;: 120.8,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;standard_price&#039;: 99.8,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;volume&#039;: mmold.m3_per_ctn, # 成品的体积是 箱立方<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;uom_id&#039;: self._get_uom_id, # 单位<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;uom_po_id&#039;: self._get_uom_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;uos_id&#039;: self._get_uom_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;seller_ids&#039;: uid , # 销售员<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;sale_ok&#039;:True, # 可以销售<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;default_code&#039;: &#039;gcp-&#039; + mmold.gsgcode ,<br /> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />&nbsp; &nbsp; &nbsp;  # vals&#91;&#039;default_code&#039;] = &#039;gcp-&#039; + mmold.gsgcode # 另外一种赋值的方法<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; # 用&nbsp; vals 中指定的数据, 创建一个 产品&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; new_id = product_obj.create(cr, uid, vals, context=context)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
    






    另外还有些 稀奇的错误


    UnboundLocalError: local variable 'bool_fields' referenced before assignment

    经总监mrshelly 指出,问题在

    <br />&#039;sale_ok&#039;: True, 不正雀...<br />
    



    必须是

    <br />1 ok<br /><br />0 ok<br />false ok<br />False ok<br />off ok<br />超出这些, 就not ok<br /><br />
    






  • 继续,开始一个个字段加回去,

    OE 让我爱来 让我恨呐



  • 不错... 添加点 tag 吧. 以方便检索...

    经历了哄雨, 才得见彩虹...


  • 管理员

    @ccdos 能不能发一下完整的代码,总感觉这么写没问题,如果错误了难道是bug?


Log in to reply