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

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

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

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

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

关于一些界面元素



  • 想问一下,如附图中的下拉选项框,在openerp中是怎么调用出来的呢?



  • [quote author=janden link=topic=5789.msg14367#msg14367 date=1362479849]
    想问一下,如附图中的下拉选项框,在openerp中是怎么调用出来的呢?
    [/quote]


    这个截图应该是在会计莫款的“会计凭证明细”里。
    Tree view的定义很简单,但是view的类型是“tree_account_move_line_quickadd”。
    很显然是在js里扩展了(参看 tree_account_move_line_quickadd.js )。

    我就灌个水,都贴过来:

    <br /><br />openerp.account.quickadd = function (instance) {<br />&nbsp; &nbsp; var _t = instance.web._t,<br />&nbsp; &nbsp; &nbsp; &nbsp; _lt = instance.web._lt;<br />&nbsp; &nbsp; var QWeb = instance.web.qweb;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; instance.web.account = instance.web.account || {};<br /><br />&nbsp; &nbsp; instance.web.views.add(&#039;tree_account_move_line_quickadd&#039;, &#039;instance.web.account.QuickAddListView&#039;);<br />&nbsp; &nbsp; instance.web.account.QuickAddListView = instance.web.ListView.extend({<br />&nbsp; &nbsp; &nbsp; &nbsp; init: function() {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this._super.apply(this, arguments);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.journals = &#91;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.periods = &#91;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.current_journal = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.current_period = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.default_period = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.default_journal = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.current_journal_type = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.current_journal_currency = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.current_journal_analytic = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; },<br />&nbsp; &nbsp; &nbsp; &nbsp; start:function(){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var tmp = this._super.apply(this, arguments);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var self = this;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.$el.parent().prepend(QWeb.render(&quot;AccountMoveLineQuickAdd&quot;, {widget: this}));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.$el.parent().find(&#039;.oe_account_select_journal&#039;).change(function() {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.current_journal = this.value === &#039;&#039; ? null : parseInt(this.value);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.do_search(self.last_domain, self.last_context, self.last_group_by);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.$el.parent().find(&#039;.oe_account_select_period&#039;).change(function() {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.current_period = this.value === &#039;&#039; ? null : parseInt(this.value);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.do_search(self.last_domain, self.last_context, self.last_group_by);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.on(&#039;edit:after&#039;, this, function () {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_journal&#039;).attr(&#039;disabled&#039;, &#039;disabled&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_period&#039;).attr(&#039;disabled&#039;, &#039;disabled&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.on(&#039;save:after cancel:after&#039;, this, function () {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_journal&#039;).removeAttr(&#039;disabled&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_period&#039;).removeAttr(&#039;disabled&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var mod = new instance.web.Model(&quot;account.move.line&quot;, self.dataset.context, self.dataset.domain);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mod.call(&quot;default_get&quot;, [&#91;&#039;journal_id&#039;,&#039;period_id&#039;],self.dataset.context]).then(function(result) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.current_period = result&#91;&#039;period_id&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.current_journal = result&#91;&#039;journal_id&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return tmp;<br />&nbsp; &nbsp; &nbsp; &nbsp; },<br />&nbsp; &nbsp; &nbsp; &nbsp; do_search: function(domain, context, group_by) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var self = this;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.last_domain = domain;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.last_context = context;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.last_group_by = group_by;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.old_search = _.bind(this._super, this);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var mod = new instance.web.Model(&quot;account.move.line&quot;, context, domain);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $.when(mod.call(&quot;list_journals&quot;, &#91;]).then(function(result) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.journals = result;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }),mod.call(&quot;list_periods&quot;, &#91;]).then(function(result) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.periods = result;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })).then(function () {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var o;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_journal&#039;).children().remove().end();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_journal&#039;).append(new Option(&#039;&#039;, &#039;&#039;));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (var i = 0;i &lt; self.journals.length;i++){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; o = new Option(self.journals[i][1], self.journals[i][0]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (self.journals[i][0] === self.current_journal){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.current_journal_type = self.journals[i][2];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.current_journal_currency = self.journals[i][3];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.current_journal_analytic = self.journals[i][4];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(o).attr(&#039;selected&#039;,true);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_journal&#039;).append(o);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_period&#039;).children().remove().end();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_period&#039;).append(new Option(&#039;&#039;, &#039;&#039;));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (var i = 0;i &lt; self.periods.length;i++){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; o = new Option(self.periods[i][1], self.periods[i][0]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_period&#039;).append(o);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.parent().find(&#039;.oe_account_select_period&#039;).val(self.current_period).attr(&#039;selected&#039;,true);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return self.search_by_journal_period();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; &nbsp; &nbsp; },<br />&nbsp; &nbsp; &nbsp; &nbsp; search_by_journal_period: function() {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var self = this;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var domain = &#91;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (self.current_journal !== null) domain.push([&quot;journal_id&quot;, &quot;=&quot;, self.current_journal]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (self.current_period !== null) domain.push([&quot;period_id&quot;, &quot;=&quot;, self.current_period]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.last_context[&quot;journal_id&quot;] = self.current_journal === null ? false : self.current_journal;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (self.current_period === null) delete self.last_context[&quot;period_id&quot;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else self.last_context[&quot;period_id&quot;] =&nbsp; self.current_period;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.last_context[&quot;journal_type&quot;] = self.current_journal_type;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.last_context[&quot;currency&quot;] = self.current_journal_currency;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.last_context[&quot;analytic_journal_id&quot;] = self.current_journal_analytic;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return self.old_search(new instance.web.CompoundDomain(self.last_domain, domain), self.last_context, self.last_group_by);<br />&nbsp; &nbsp; &nbsp; &nbsp; },<br />&nbsp; &nbsp; });<br />};<br /><br /><br />
    



    模版:

    <br />&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br /><br />&lt;templates id=&quot;template&quot; xml:space=&quot;preserve&quot;&gt;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &lt;t t-name=&quot;AccountMoveLineQuickAdd&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;div class=&quot;oe_account_quickadd ui-toolbar&quot; style=&quot;margin-bottom:0px;&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class=&quot;oe_form_dropdown_section&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h4&gt;Period :&lt;/h4&gt; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;select class=&quot;oe_account_select_period&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/select&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class=&quot;oe_form_dropdown_section&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h4&gt;Journal :&lt;/h4&gt; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;select class=&quot;oe_account_select_journal&quot; &gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/select&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br />&nbsp; &nbsp; &lt;/t&gt;<br /><br />&lt;/templates&gt;<br /><br />
    




    别忘记,还有css的定义。



  • OpenERP的这个视图用了很多特殊的实现方式,真是费尽心机啊。可是仍然无法给出类似国内明细账的结果。



  • 不得不说,国内非常特殊。
    更特殊的是,每个公司都特殊。
    😕 😕 😕


Log in to reply