跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

  1. 主页
  2. 版块
  3. Odoo 开发与实施交流
  4. Onchange 里面传入的 one2many 的解读

Onchange 里面传入的 one2many 的解读

已定时 已固定 已锁定 已移动 Odoo 开发与实施交流
4 帖子 2 发布者 3.4k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • C 离线
    C 离线
    ccdos
    写于 最后由 编辑
    #1

    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 离线
      C 离线
      ccdos
      写于 最后由 编辑
      #2

      见笑了

      不过留着吧 。

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

      1 条回复 最后回复
      0
      • mrshellyM 离线
        mrshellyM 离线
        mrshelly
        写于 最后由 编辑
        #3

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

        1 条回复 最后回复
        0

        • 登录

        • 没有帐号? 注册

        • 登录或注册以进行搜索。
        • 第一个帖子
          最后一个帖子
        0
        • 版块
        • 标签
        • 热门
        • 用户
        • 群组