Odoo 中文社区

    • 注册
    • 登录
    • 搜索
    • 版块
    • 标签
    • 热门
    • 用户
    • 群组

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

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

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

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

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

    Onchange 里面传入的 one2many 的解读

    Odoo 开发与实施交流
    2
    4
    3296
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • C
      ccdos 最后由 编辑

      onchange 里面 就是把 传入的参数 print 出来

      <br />&nbsp; &nbsp; def onchange_sale_order_contract_lines(self, cr, uid, ids,sale_order_contract_lines, context=None ):<br />&nbsp; &nbsp; &nbsp; #&nbsp; res = {&#039;value&#039;:{}}<br />&nbsp; &nbsp; &nbsp; #&nbsp; return res<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; if sale_order_contract_lines:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for contract_line in sale_order_contract_lines:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print contract_line<br />&nbsp; &nbsp; &nbsp; &nbsp; return res<br />
      




      运行若干次,结果如下:


      下面 1,2 两行是 之前已经输入,修改了

      3,4,5 行是新输入的,尚未保存

      [1, 1, {u&#039;notes&#039;: u&#039;bbbb &#039;, u&#039;metric_spec&#039;: u&#039;aaaaaaaaaaaa&#039;}]<br />[1, 2, {u&#039;notes&#039;: u&#039; &#039;, u&#039;metric_spec&#039;: u&#039;bbbbbbbbbbbbbb&#039;}]<br />[0, False, {u&#039;input_value&#039;: 0, u&#039;input_type&#039;: u&#039;1&#039;, u&#039;notes&#039;: u&#039;ccc&#039;, u&#039;stratify_base&#039;: 100, u&#039;active&#039;: 1, u&#039;metric_spec&#039;: u&#039;ccccc&#039;}]<br />[0, False, {u&#039;input_value&#039;: 0, u&#039;input_type&#039;: u&#039;1&#039;, u&#039;notes&#039;: u&#039;dd&#039;, u&#039;stratify_base&#039;: 100, u&#039;active&#039;: 1, u&#039;metric_spec&#039;: u&#039;ddddddddddd&#039;}]<br />[0, False, {u&#039;input_value&#039;: 0, u&#039;input_type&#039;: u&#039;1&#039;, u&#039;notes&#039;: u&#039;ee&#039;, u&#039;stratify_base&#039;: 100, u&#039;active&#039;: 1, u&#039;metric_spec&#039;: u&#039;eeeeeee&#039;}]<br />
      



      下面修改了 第三行

      [4, 1, False]<br />[4, 2, False]<br />[1, 3, {u&#039;notes&#039;: u&#039;ccccccccccc&#039;, u&#039;metric_spec&#039;: u&#039;cccccccccccccccccccccccccccccc&#039;}]<br />[4, 4, False]<br />[4, 5, False]
      



      单独修改 第三行 的  metric_spec

      [4, 1, False]<br />[4, 2, False]<br />[1, 3, {u&#039;metric_spec&#039;: u&#039;ccccccccccccccc&#039;}]<br />[4, 4, False]<br />[4, 5, False]
      





      [attachimg=1]

       

      大概解读一下,修改后传入的  sale_order_contract_lines是一个  list ,
      一行数据对应 一个元素

      每个元素(行),又是一个列表,

      此列表 为三个元素,
      第一个  不明,
      第二个 序号
      第三个  如果 为 Fasle,说明改行没有修改,
          如果是一个字典,就是 被修改的字段名称,以及修改后 值

      ~~~~~~~~~~~~~~~~~~~



      突然反映过来了,
      我还煞有其事的 分析半天,这就是  接触过多次的东西,文档中有



      0, 0,  { values })    link to a new record that needs to be created with the given values dictionary
      (1, ID, { values })    update the linked record with id = ID (write values on it)
      (2, ID)                remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
      (3, ID)                cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
      (4, ID)                link to existing record with id = ID (adds a relationship)
      (5)                    unlink all (like using (3,ID) for all linked records)
      (6, 0, [IDs])          replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

      1 条回复 最后回复 回复 引用 0
      • C
        ccdos 最后由 编辑

        见笑了

        不过留着吧 。

        这次 之后,估计再也不会忘记了

        1 条回复 最后回复 回复 引用 0
        • mrshelly
          mrshelly 最后由 编辑

          嗯. 文档有这块儿的东西, 多留着吧...

          1 条回复 最后回复 回复 引用 0
          • First post
            Last post