Navigation

    Odoo 中文社区

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

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

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

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

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

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

    前车之鉴,one2many的widget

    Odoo 开发与实施交流
    3
    4
    4718
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      coldfire last edited by

      假如自己加了两个表进去,a对b是many2one,b对a是one2many,那么b的view里面如果要加入一个one2many的widget,那么必须在其后指定要使用的view。因为自己定义的表没有单独的view可用。系统找不到view就会出错。

      举例说明:
      表product.product:
      [code]
      _columns = {
      'tb_picture': fields.binary('图片'),
      'tb_dimension': fields.char('规格尺寸', size=100),
      'tb_material': fields.char('材质', size=100),
      'tb_itemid': fields.char('淘宝产品ID', size=100),
      'tb_description': fields.text('产品描述'),
      'tb_online': fields.boolean('上线'),
      'tb_onshelf': fields.boolean('上架'),
      'tb_synchronized': fields.boolean('已同步'),
      'tb_picture_urls': fields.one2many('product.picture.url', 'product_id', '图片地址'),
      }
      [/code]

      表product.picture.url:
      [code] _columns = {
      'product_id': fields.many2one('product.product', '产品ID', select=1, ondelete='cascade', required=True),
      'picture_url': fields.char('图片地址', size=200),
      }
      [/code]

      表product.product的view里面要加one2many,就要这么写才能显示出来:
      [code]
      <field name="tb_picture_urls" mode="tree" colspan="4" nolabel="1" >
      <tree string="图片地址">
      <field name="picture_url" />
      </tree>
      <form string="图片地址">
      <field name="picture_url" />
      </form>
      </field>
      [/code]

      另一个值得注意问题是:表名不能用大写。因为pqsql区分大小写,而openerp不区分大小写,所有的大写最后都变成小写了,就会导致找不到表,也会出错的。

      1 Reply Last reply Reply Quote 0
      • C
        CnBoYer last edited by

        谢谢冷火的分享 先收藏备用 应该是我下一步用的着的

        1 Reply Last reply Reply Quote 0
        • L
          linyaohui last edited by

          果然猛火,谢谢

          1 Reply Last reply Reply Quote 0
          • First post
            Last post