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

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

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

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

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

更改Editable Form里的快捷键(更新v 7.0)



  • 经常听到用户在抱怨OE的回车不好用。原来国产的很多软件里,总是把回车当成TAB用。唉。迎合用户,改。
    打开:
    \addons\web\static\src\js\view_list_editable.js

    找到(大约line169):

    <br />on_row_keyup: function (e) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var self = this;<br />......<br />
    



    动手。
    首先要支持这个:用户在一个输入框回车,跳转到本行的下一个输入框。要考虑输入框的readonly,invisible...
    思路:先数本行总共有多少个可以输入的input, 然后向后select一个。

    <br /><br />on_row_keyup: function (e) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var self = this;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (e.which) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case KEY_RETURN:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputs = self.edition_form.$element.find(&#039;input:visible:not(disabled):not([readonly])&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; idx = $.inArray(e.target, inputs);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(idx &lt; inputs.length-1){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(&#039;#&#039;+inputs[idx+1].id).select();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.save_row().then(function (result) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (result.created) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.new_record();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br /><br />......<br /><br />
    




    当然,如果到了本行最后一个输入框了,那就执行系统的快捷键,保存本行,跳到下一行吧。

    打完收工。


    以下是为7.0做的改变。

    为了维持用户体验,我还是需要把v7版本的回车快捷键修改一下,使之和v 6.1中一致:

    还是那个文件,line 489,
    (BTW:这个版本支持很多的快捷键,确实提高了用户体验。)

    我们主要修改keyup_ENTER方法:

    <br /><br />keyup_ENTER: function (e) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //return this._next();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var form = this.editor.form;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //找最后一个field<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var last_field = _(form.fields_order).chain()<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .map(function (name) { return form.fields[name]; })<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .filter(function (field) { return field.$el.is(&#039;:visible&#039;); })<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .last()<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .value();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // tabbed from last field in form<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 判断是否换行<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (last_field &amp;&amp; last_field.$el.has(e.target).length) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.preventDefault();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return this._next();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //如果不需要换行,转向下一个输入框。<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var source_field = $(e.target).closest(&#039;[data-fieldname]&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .attr(&#039;data-fieldname&#039;);<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var fields_order = form.fields_order;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var field_index = _(fields_order).indexOf(source_field);<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var fields = form.fields;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var field;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (++field_index &gt;= fields_order.length) { return $.when(); }<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field = fields[fields_order[field_index]];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } while (!field.$el.is(&#039;:visible&#039;));<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field.focus();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $.when();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; },<br />
    


  • Good , 鼠标点击事件是哪个呢?

    我发现个问题. 在 6.1 中, 如果一个 tree view 过宽的话,  点击某行的 最后某列的话. 焦点会定位到第一列.



  • 高!
    OE 这个输入也让我头疼,我都想用原来的dephi通过xmlrpc 接口做输入了



  • 这个可以提交到官方作为一个patch吧



  • [quote author=mrshelly link=topic=4205.msg11348#msg11348 date=1339491922]
    Good , 鼠标点击事件是哪个呢?

    我发现个问题. 在 6.1 中, 如果一个 tree view 过宽的话,  点击某行的 最后某列的话. 焦点会定位到第一列.
    [/quote]

    应该是点击什么位置,就编辑什么. 不过估计有点困难. 可以看看这个函数:  render_row_as_form.

    不过想想, 到第一列也没有什么坏处. 😉



  • 这个牛B



  • 强人,再顶.

    其实 回车跳到下个字段, 还有一个 很有用的需求
    ,

    就是实现 tabstop


Log in to reply