[ADD]Missing files

bzr revid: dle@openerp.com-20121109123808-9a6n4mn5dh6vidkb
This commit is contained in:
Denis Ledoux dle@openerp.com
2012-11-09 13:38:08 +01:00
parent a6d97dccbd
commit 3f034c27a4
2 changed files with 115 additions and 0 deletions
@@ -0,0 +1,81 @@
openerp.account = function (instance) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
instance.web.account = {};
instance.web.views.add('tree_account_move_line_quickadd', 'instance.web.account.QuickAddListView');
instance.web.account.QuickAddListView = instance.web.ListView.extend({
_template: 'ListView',
init: function() {
var self = this;
this._super.apply(this, arguments);
this.journals = [];
this.periods = [];
this.current_journal = null;
this.current_period = null;
},
load_list: function() {
var self = this;
var tmp = this._super.apply(this, arguments);
this.$el.prepend(QWeb.render("AccountMoveLineQuickAdd", {widget: this}));
this.$("#oe_account_select_journal").change(function() {
self.current_journal = parseInt(this.value);
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.$("#oe_account_select_period").change(function() {
self.current_period = parseInt(this.value);
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
return tmp;
},
do_search: function(domain, context, group_by) {
var self = this;
this.last_domain = domain;
this.last_context = context;
this.last_group_by = group_by;
this.old_search = _.bind(this._super, this);
var mod = new instance.web.Model("account.move.line", context, domain);
var getarray = [];
getarray.push(mod.call("list_journals", []).then(function(result) {
self.journals = result;
}));
getarray.push(mod.call("list_periods", []).then(function(result) {
self.periods = result;
}));
$.when.apply($, getarray).done(function () {
self.current_journal = self.current_journal === null ? self.journals[0][0] : self.current_journal;
self.current_period = self.current_period === null ? self.periods[0][0] :self.current_period;
var tmp = self.search_by_journal_period();
});
},
search_by_journal_period: function() {
var self = this;
compoundDomain = new instance.web.CompoundDomain(self.last_domain,
[
["journal_id", "=", self.current_journal],
["period_id", "=", self.current_period]
]);
self.last_context["journal_id"] = self.current_journal;
self.last_context["period_id"] = self.current_period;
return self.old_search(compoundDomain, self.last_context, self.last_group_by);
},
_next: function (next_record, options) {
next_record = next_record || 'succ';
var self = this;
return this.save_edition().then(function (saveInfo) {
if (saveInfo.created || self.records.at(self.records.length-1).get("id") === saveInfo.record.get("id")) {
return self.start_edition();
}
var record = self.records[next_record](
saveInfo.record, {wraparound: true});
return self.start_edition(record, options);
});
},
});
};
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="AccountMoveLineQuickAdd">
<div class="oe_account_quickadd">
<div>
Journal :
<select id="oe_account_select_journal">
<t t-foreach="widget.journals" t-as="journal">
<option t-if=" journal[0] === widget.current_journal" t-att-value="journal[0]" t-att-selected="'selected'">
<t t-esc="journal[1]"/>
</option>
<option t-if="journal[0] !== widget.current_journal" t-att-value="journal[0]">
<t t-esc="journal[1]"/>
</option>
</t>
</select>
Period :
<select id="oe_account_select_period">
<t t-foreach="widget.periods" t-as="period">
<option t-if=" period[0] === widget.current_period" t-att-value="period[0]" t-att-selected="'selected'">
<t t-esc="period[1]"/>
</option>
<option t-if=" period[0] !== widget.current_period" t-att-value="period[0]">
<t t-esc="period[1]"/>
</option>
</t>
</select>
</div>
</div>
</t>
</templates>