跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • 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. 6.1中 xml里面的js代码的问题

6.1中 xml里面的js代码的问题

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

    请教一个问题,不知道我问的对不对,因为我对JS代码不是很懂。
    A模块的XML代码构建了一个form,tree用来显示图片。在另一B模块的py文件中定义一个one2many型字段,同时在xml中定义显示。现在的问题是,下面的代码在6.0中没有问题,正确的显示是,在xml中默认显示form。但是到了6.1,却变成了xml中默认显示是tree。
    我将<field name="web_gallery_image_ids"/>改成<field name="web_gallery_image_ids" mode="form"/>,虽然显示了form,但是与6.0中还不一样。
    在6.0中,form中的file,Category,Commentary三个字段并没有显示,而是显示的是extention字段(我估计这个是js代码控制的),但是到了6.1中,却显示除了file,Category,Commentary这三个字段,如果我的估计没错,那么就是那段js代码没有执行。
    请大家帮忙看下这段js代码的用处,以及为何没有工作(如果我估计没错的话),非常非常感谢。

    #B模块中的调用代码

    <br />&nbsp; &#039;web_gallery_image_ids&#039;: fields.one2many(&#039;web.gallery.images&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;product_id&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;Images&#039;),<br /><br /> &lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;notebook position=&quot;inside&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;page string=&quot;Gallery&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;web_gallery_image_ids&quot;/&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/page&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/notebook&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/field&gt;<br />
    


    #A模块中定义视图xml代码

    <br />&lt;record id=&quot;web_gallery_images_form&quot; model=&quot;ir.ui.view&quot;&gt;<br />			&lt;field name=&quot;name&quot;&gt;web.gallery.images.form&lt;/field&gt;<br />			&lt;field name=&quot;model&quot;&gt;web.gallery.images&lt;/field&gt;<br />			&lt;field name=&quot;type&quot;&gt;form&lt;/field&gt;<br />			&lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt;<br />				&lt;form string=&quot;Image&quot;&gt;<br />					&lt;field name=&quot;extention&quot; invisible=&quot;1&quot; /&gt;<br />					&lt;field string=&quot;File&quot; name=&quot;file&quot; /&gt;<br />					&lt;newline /&gt;<br />					&lt;field string=&quot;Category&quot; name=&quot;category&quot;<br />						widget=&quot;selection&quot; /&gt;<br />					&lt;newline /&gt;<br />					&lt;field string=&quot;Commentary&quot; name=&quot;comment&quot; /&gt;<br />					&lt;html&gt;<br />						&lt;script type=&quot;text/javascript&quot;&gt;<br />							jQuery(&#039;form&#039;).submit(function () {<br />									var fileName = jQuery(&quot;input.binary&quot;).val();<br />									var fileSplit = fileName.split(&#039;.&#039;);<br />									var fileExt = fileSplit[fileSplit.length -1];<br />									jQuery(&#039;input[id*=web_gallery_image_ids/extention]&#039;).val(fileExt);<br />								});<br /><br />							var buttons = jQuery(&quot;button&quot;);<br />							jQuery(buttons[0]).hide();<br />							jQuery(buttons[1]).text(&quot;Save&quot;);<br />						&lt;/script&gt;<br />					&lt;/html&gt;<br />				&lt;/form&gt;<br />			&lt;/field&gt;<br />&lt;/record&gt;<br /><br />&lt;record id=&quot;web_gallery_images_tree&quot; model=&quot;ir.ui.view&quot;&gt;<br />			&lt;field name=&quot;name&quot;&gt;web.gallery.images.tree&lt;/field&gt;<br />			&lt;field name=&quot;model&quot;&gt;web.gallery.images&lt;/field&gt;<br />			&lt;field name=&quot;type&quot;&gt;tree&lt;/field&gt;<br />			&lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt;<br />				&lt;tree string=&quot;Image&quot;&gt;<br />					&lt;field string=&quot;Category&quot; name=&quot;category&quot; /&gt;<br />					&lt;field string=&quot;File URL&quot; name=&quot;url&quot; /&gt;<br />					&lt;field string=&quot;Commentary&quot; name=&quot;comment&quot; /&gt;<br />				&lt;/tree&gt;<br />			&lt;/field&gt;<br />		&lt;/record&gt;<br />
    
    1 条回复 最后回复
    0
    • mrshellyM 离线
      mrshellyM 离线
      mrshelly
      写于 最后由 编辑
      #2

      谁教你这样用的?

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

        这个模块我写的,主站的模块,6.0下用的没有问题,6.1就不行了。这个模块是一个保存并显示图片的模块,对我来说用处很大,因此想搞清楚是怎么回事。

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

          嗯. 没有玩过这样高级的....
          Mark 一下. 后面学习....

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

            这种写法在ie9里完全不行,不知道有没有什么解决办法。js可以从外部调用。

            1 条回复 最后回复
            0

            • 登录

            • 没有帐号? 注册

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