跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • 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. 修改Many2One字段的链接打开方式

修改Many2One字段的链接打开方式

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

    OE 6中, Many2One字段的只读显示方式如下:
    [attachimg=1]

    点击时, 是在本窗口打开这个对象的. 有时候非常的恼人. 很多用户不知道浏览器的前进后退, 所以还要从头找回去.

    想想, 不如改为浮动窗口的好点.

    打开浏览器的开发工具:
    [attachimg=2]

    链接都是"oe_form_uri" class. 在web模块的xml模版里, 发现这个class是 FieldURI.readonly 在使用.
    转而在web模块所带的一大堆js文件里搜索 "FieldURI". 发现一大堆的界面对象在使用这个模版.
    忽然想到, 应该有一个派生类, 名字类似于 many2one, 结果找到 view_page.js, line 171里.
    应该是打开一个新的浮动窗口, target不能是current.
    修改之
    line 171:

    <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var real_set_value = function(rval) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.value = rval;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$element.find(&#039;a&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  .unbind(&#039;click&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  .text(rval ? rval[1] : &#039;&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  .click(function () {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.do_action({<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: &#039;ir.actions.act_window&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res_model: self.field.relation,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res_id: self.value[0],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context: self.build_context(),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; views: [[false, &#039;page&#039;], [false, &#039;form&#039;]],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; target: &#039;new&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  });<br />
    



    打完收工.
    还没有验证是否影响到其他功能.

    微博 @杨振宇_  欢迎交流.

    1 条回复 最后回复
    0
    • J 离线
      J 离线
      jerry79
      写于 最后由 编辑
      #2

      楼主高人,这样的问题虽然小,但是非常影响用户体验。我在官方提了两个bug,都被官方以非block issue拒绝了,实在令人郁闷。
      请问楼主有没有遇到如下类似的问题(6.1版本):
      1、你在form上修改一个字段,改完后保存,视图直接跳到了tree页面,让你根本找不到刚才修改的是哪一个;
      2、你在form的tab上修改一个字段,改完后保存,视图跳到了另外一个tab上(通常是第一个tab),而不是停留在你刚才修改的tab。
      我觉得这两个问题也很影响用户体验啊,但是官方不接受。

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

        据我的体验, 如果你点击tree view列表里最左边的编辑按钮进行编辑(打开一个form view), 保存后,你是返回到列表的, 这个时候你是不知道到底哪条修改过.
        如果你是在form view里点击编辑按钮进行编辑, 保存后你还是返回到form界面的.

        至于tab这个, 我先想想.

        1 条回复 最后回复
        0
        • J 离线
          J 离线
          jerry79
          写于 最后由 编辑
          #4

          谢谢d_yang, 第一个问题出现的几率不多,是有概率的。我先打开form,再编辑,再保存,是有可能跳到tree view的,不过我刚才又测试,又没出现,这个几率现在不好碰到。先不管了。

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

            赞.谢谢分享.. 要是给贴子加点标签 就更完美老...:)

            1 条回复 最后回复
            0

            • 登录

            • 没有帐号? 注册

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