[REF] account: update to the new module system

This commit is contained in:
Géry Debongnie
2015-03-18 09:01:50 +01:00
parent b960f8ad52
commit 97f4ba3e3d
7 changed files with 2156 additions and 2123 deletions
@@ -1,101 +0,0 @@
openerp.account.quickadd = function (instance) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
instance.web.account = instance.web.account || {};
instance.web.views.add('tree_account_move_line_quickadd', 'instance.web.account.QuickAddListView');
instance.web.account.QuickAddListView = instance.web.ListView.extend({
init: function() {
this._super.apply(this, arguments);
this.journals = [];
this.periods = [];
this.current_journal = null;
this.current_period = null;
this.default_period = null;
this.default_journal = null;
this.current_journal_type = null;
this.current_journal_currency = null;
this.current_journal_analytic = null;
},
start:function(){
var tmp = this._super.apply(this, arguments);
var self = this;
var defs = [];
this.$el.parent().prepend(QWeb.render("AccountMoveLineQuickAdd", {widget: this}));
this.$el.parent().find('.oe_account_select_journal').change(function() {
self.current_journal = this.value === '' ? null : parseInt(this.value);
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.$el.parent().find('.oe_account_select_period').change(function() {
self.current_period = this.value === '' ? null : parseInt(this.value);
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.on('edit:after', this, function () {
self.$el.parent().find('.oe_account_select_journal').attr('disabled', 'disabled');
self.$el.parent().find('.oe_account_select_period').attr('disabled', 'disabled');
});
this.on('save:after cancel:after', this, function () {
self.$el.parent().find('.oe_account_select_journal').removeAttr('disabled');
self.$el.parent().find('.oe_account_select_period').removeAttr('disabled');
});
var mod = new instance.web.Model("account.move.line", self.dataset.context, self.dataset.domain);
defs.push(mod.call("default_get", [['journal_id','period_id'],self.dataset.context]).then(function(result) {
self.current_period = result['period_id'];
self.current_journal = result['journal_id'];
}));
defs.push(mod.call("list_journals", []).then(function(result) {
self.journals = result;
}));
defs.push(mod.call("list_periods", []).then(function(result) {
self.periods = result;
}));
return $.when(tmp, defs);
},
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 o;
self.$el.parent().find('.oe_account_select_journal').children().remove().end();
self.$el.parent().find('.oe_account_select_journal').append(new Option('', ''));
for (var i = 0;i < self.journals.length;i++){
o = new Option(self.journals[i][1], self.journals[i][0]);
if (self.journals[i][0] === self.current_journal){
self.current_journal_type = self.journals[i][2];
self.current_journal_currency = self.journals[i][3];
self.current_journal_analytic = self.journals[i][4];
$(o).attr('selected',true);
}
self.$el.parent().find('.oe_account_select_journal').append(o);
}
self.$el.parent().find('.oe_account_select_period').children().remove().end();
self.$el.parent().find('.oe_account_select_period').append(new Option('', ''));
for (var i = 0;i < self.periods.length;i++){
o = new Option(self.periods[i][1], self.periods[i][0]);
self.$el.parent().find('.oe_account_select_period').append(o);
}
self.$el.parent().find('.oe_account_select_period').val(self.current_period).attr('selected',true);
return self.search_by_journal_period();
},
search_by_journal_period: function() {
var self = this;
var domain = [];
if (self.current_journal !== null) domain.push(["journal_id", "=", self.current_journal]);
if (self.current_period !== null) domain.push(["period_id", "=", self.current_period]);
self.last_context["journal_id"] = self.current_journal === null ? false : self.current_journal;
if (self.current_period === null) delete self.last_context["period_id"];
else self.last_context["period_id"] = self.current_period;
self.last_context["journal_type"] = self.current_journal_type;
self.last_context["currency"] = self.current_journal_currency;
self.last_context["analytic_journal_id"] = self.current_journal_analytic;
var compound_domain = new instance.web.CompoundDomain(self.last_domain, domain);
self.dataset.domain = compound_domain.eval();
return self.old_search(compound_domain, self.last_context, self.last_group_by);
},
});
};
@@ -1,147 +0,0 @@
(function () {
'use strict';
var _t = openerp._t;
openerp.Tour.register({
id: 'bank_statement_reconciliation',
name: _t("Reconcile the demo bank statement"),
path: '/web',
mode: 'test',
// TODO : identify menu by data-menu attr or text node ?
steps: [
// Go to the first statement reconciliation
{
title: "go to accounting",
element: '.oe_menu_toggler:contains("Accounting"):visible',
},
{
title: "go to bank statements",
element: '.oe_menu_leaf:contains("Bank Statement"):visible',
},
{
title: "select first bank statement",
element: '.oe_list_content tbody tr:contains("BNK/2014/001")',
},
{
title: "click the reconcile button",
element: '.oe_form_container header button:contains("Reconcile")',
},
// Check mutual exclusion of move lines
{
title: "set second reconciliation in match mode",
element: '.oe_bank_statement_reconciliation_line:nth-child(2) .initial_line'
},
{
title: "deselect SAJ/2014/002 from second reconciliation",
element: '.oe_bank_statement_reconciliation_line:nth-child(2) .accounting_view .mv_line:contains("SAJ/2014/002")'
},
{
title: "check it appeared in first reconciliation's matches list and select SAJ/2014/002 in second reconciliation",
waitNot: '.oe_bank_statement_reconciliation_line:nth-child(2) .accounting_view .mv_line:contains("SAJ/2014/002")',
waitFor: '.oe_bank_statement_reconciliation_line:first-child .mv_line:contains("SAJ/2014/002")',
element: '.oe_bank_statement_reconciliation_line:nth-child(2) .mv_line:contains("SAJ/2014/002")'
},
// Make a partial reconciliation
{
title: "select SAJ/2014/001",
element: '.oe_bank_statement_reconciliation_line:first-child .mv_line:contains("SAJ/2014/001")'
},
{
title: "click on the partial reconciliation button",
element: '.oe_bank_statement_reconciliation_line:first-child .mv_line:contains("SAJ/2014/001") .do_partial_reconcile_button'
},
{
title: "click on the OK button",
element: '.oe_bank_statement_reconciliation_line:first-child .button_ok.oe_highlight'
},
// Test changing the partner
{
title: "change the partner (1)",
waitNot: '.oe_bank_statement_reconciliation_line:nth-child(4)', // wait for the reconciliation to be processed
element: '.oe_bank_statement_reconciliation_line:first-child .partner_name'
},
{
title: "change the partner (2)",
element: '.oe_bank_statement_reconciliation_line:first-child .change_partner_container input',
sampleText: 'Vauxoo',
},
{
title: "change the partner (3)",
element: '.ui-autocomplete .ui-menu-item:contains("Vauxoo")'
},
{
title: "check the reconciliation is reloaded and has no match",
element: '.oe_bank_statement_reconciliation_line:first-child.no_match',
},
{
title: "change the partner back (1)",
element: '.oe_bank_statement_reconciliation_line:first-child .partner_name'
},
{
title: "change the partner back (2)",
element: '.oe_bank_statement_reconciliation_line:first-child .change_partner_container input',
sampleText: 'Best Designers',
},
{
title: "change the partner back (3)",
element: '.ui-autocomplete .ui-menu-item:contains("Best Designers")'
},
{
title: "select SAJ/2014/002",
element: '.oe_bank_statement_reconciliation_line:first-child .mv_line:contains("SAJ/2014/002")'
},
{
title: "click on the OK button",
element: '.oe_bank_statement_reconciliation_line:first-child .button_ok.oe_highlight'
},
// Create a new move line in first reconciliation and validate it
{
title: "check following reconciliation passes in mode create",
waitNot: '.oe_bank_statement_reconciliation_line:nth-child(3)', // wait for the reconciliation to be processed
element: '.oe_bank_statement_reconciliation_line:first-child[data-mode="create"]'
},
{
title: "click the Profit/Loss preset",
element: '.oe_bank_statement_reconciliation_line:first-child button:contains("Profit / Loss")'
},
{
title: "click on the OK button",
element: '.oe_bank_statement_reconciliation_line:first-child .button_ok.oe_highlight'
},
// Leave an open balance
{
title: "select SAJ/2014/003",
waitNot: '.oe_bank_statement_reconciliation_line:nth-child(2)', // wait for the reconciliation to be processed
element: '.oe_bank_statement_reconciliation_line:first-child .mv_line:contains("SAJ/2014/003")'
},
{
title: "click on the Keep Open button",
element: '.oe_bank_statement_reconciliation_line:first-child .button_ok:not(.oe_highlight)'
},
// Be done
{
title: "check 'finish screen' and close the statement",
waitFor: '.done_message',
element: '.button_close_statement'
},
{
title: "check the statement is closed",
element: '.oe_form_container header .label:contains("Closed")'
},
]
});
}());
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,105 @@
odoo.define('account.move_line_quickadd', ['web.core', 'web.data', 'web.ListView', 'web.Model'], function (require) {
"use strict";
var core = require('web.core');
var data = require('web.data');
var ListView = require('web.ListView');
var Model = require('web.Model');
var QWeb = core.qweb;
var QuickAddListView = ListView.extend({
init: function() {
this._super.apply(this, arguments);
this.journals = [];
this.periods = [];
this.current_journal = null;
this.current_period = null;
this.default_period = null;
this.default_journal = null;
this.current_journal_type = null;
this.current_journal_currency = null;
this.current_journal_analytic = null;
},
start:function(){
var tmp = this._super.apply(this, arguments);
var self = this;
var defs = [];
this.$el.parent().prepend(QWeb.render("AccountMoveLineQuickAdd", {widget: this}));
this.$el.parent().find('.oe_account_select_journal').change(function() {
self.current_journal = this.value === '' ? null : parseInt(this.value);
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.$el.parent().find('.oe_account_select_period').change(function() {
self.current_period = this.value === '' ? null : parseInt(this.value);
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.on('edit:after', this, function () {
self.$el.parent().find('.oe_account_select_journal').attr('disabled', 'disabled');
self.$el.parent().find('.oe_account_select_period').attr('disabled', 'disabled');
});
this.on('save:after cancel:after', this, function () {
self.$el.parent().find('.oe_account_select_journal').removeAttr('disabled');
self.$el.parent().find('.oe_account_select_period').removeAttr('disabled');
});
var mod = new Model("account.move.line", self.dataset.context, self.dataset.domain);
defs.push(mod.call("default_get", [['journal_id','period_id'],self.dataset.context]).then(function(result) {
self.current_period = result['period_id'];
self.current_journal = result['journal_id'];
}));
defs.push(mod.call("list_journals", []).then(function(result) {
self.journals = result;
}));
defs.push(mod.call("list_periods", []).then(function(result) {
self.periods = result;
}));
return $.when(tmp, defs);
},
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 o;
self.$el.parent().find('.oe_account_select_journal').children().remove().end();
self.$el.parent().find('.oe_account_select_journal').append(new Option('', ''));
for (var i = 0;i < self.journals.length;i++){
o = new Option(self.journals[i][1], self.journals[i][0]);
if (self.journals[i][0] === self.current_journal){
self.current_journal_type = self.journals[i][2];
self.current_journal_currency = self.journals[i][3];
self.current_journal_analytic = self.journals[i][4];
$(o).attr('selected',true);
}
self.$el.parent().find('.oe_account_select_journal').append(o);
}
self.$el.parent().find('.oe_account_select_period').children().remove().end();
self.$el.parent().find('.oe_account_select_period').append(new Option('', ''));
for (var i = 0;i < self.periods.length;i++){
o = new Option(self.periods[i][1], self.periods[i][0]);
self.$el.parent().find('.oe_account_select_period').append(o);
}
self.$el.parent().find('.oe_account_select_period').val(self.current_period).attr('selected',true);
return self.search_by_journal_period();
},
search_by_journal_period: function() {
var self = this;
var domain = [];
if (self.current_journal !== null) domain.push(["journal_id", "=", self.current_journal]);
if (self.current_period !== null) domain.push(["period_id", "=", self.current_period]);
self.last_context["journal_id"] = self.current_journal === null ? false : self.current_journal;
if (self.current_period === null) delete self.last_context["period_id"];
else self.last_context["period_id"] = self.current_period;
self.last_context["journal_type"] = self.current_journal_type;
self.last_context["currency"] = self.current_journal_currency;
self.last_context["analytic_journal_id"] = self.current_journal_analytic;
var compound_domain = new data.CompoundDomain(self.last_domain, domain);
self.dataset.domain = compound_domain.eval();
return self.old_search(compound_domain, self.last_context, self.last_group_by);
},
});
core.view_registry.add('tree_account_move_line_quickadd', QuickAddListView);
});
@@ -0,0 +1,150 @@
odoo.define('account.tour_bank_statement_reconciliation', ['web.core', 'web.Tour'], function(require) {
'use strict';
var core = require('web.core');
var Tour = require('web.Tour');
var _t = core._t;
Tour.register({
id: 'bank_statement_reconciliation',
name: _t("Reconcile the demo bank statement"),
path: '/web',
mode: 'test',
// TODO : identify menu by data-menu attr or text node ?
steps: [
// Go to the first statement reconciliation
{
title: "go to accounting",
element: '.oe_menu_toggler:contains("Accounting"):visible',
},
{
title: "go to bank statements",
element: '.oe_menu_leaf:contains("Bank Statement"):visible',
},
{
title: "select first bank statement",
element: '.oe_list_content tbody tr:contains("BNK/2014/001")',
},
{
title: "click the reconcile button",
element: '.oe_form_container header button:contains("Reconcile")',
},
// Check mutual exclusion of move lines
{
title: "set second reconciliation in match mode",
element: '.oe_bank_statement_reconciliation_line:nth-child(2) .initial_line'
},
{
title: "deselect SAJ/2014/002 from second reconciliation",
element: '.oe_bank_statement_reconciliation_line:nth-child(2) .accounting_view .mv_line:contains("SAJ/2014/002")'
},
{
title: "check it appeared in first reconciliation's matches list and select SAJ/2014/002 in second reconciliation",
waitNot: '.oe_bank_statement_reconciliation_line:nth-child(2) .accounting_view .mv_line:contains("SAJ/2014/002")',
waitFor: '.oe_bank_statement_reconciliation_line:first-child .mv_line:contains("SAJ/2014/002")',
element: '.oe_bank_statement_reconciliation_line:nth-child(2) .mv_line:contains("SAJ/2014/002")'
},
// Make a partial reconciliation
{
title: "select SAJ/2014/001",
element: '.oe_bank_statement_reconciliation_line:first-child .mv_line:contains("SAJ/2014/001")'
},
{
title: "click on the partial reconciliation button",
element: '.oe_bank_statement_reconciliation_line:first-child .mv_line:contains("SAJ/2014/001") .do_partial_reconcile_button'
},
{
title: "click on the OK button",
element: '.oe_bank_statement_reconciliation_line:first-child .button_ok.oe_highlight'
},
// Test changing the partner
{
title: "change the partner (1)",
waitNot: '.oe_bank_statement_reconciliation_line:nth-child(4)', // wait for the reconciliation to be processed
element: '.oe_bank_statement_reconciliation_line:first-child .partner_name'
},
{
title: "change the partner (2)",
element: '.oe_bank_statement_reconciliation_line:first-child .change_partner_container input',
sampleText: 'Vauxoo',
},
{
title: "change the partner (3)",
element: '.ui-autocomplete .ui-menu-item:contains("Vauxoo")'
},
{
title: "check the reconciliation is reloaded and has no match",
element: '.oe_bank_statement_reconciliation_line:first-child.no_match',
},
{
title: "change the partner back (1)",
element: '.oe_bank_statement_reconciliation_line:first-child .partner_name'
},
{
title: "change the partner back (2)",
element: '.oe_bank_statement_reconciliation_line:first-child .change_partner_container input',
sampleText: 'Best Designers',
},
{
title: "change the partner back (3)",
element: '.ui-autocomplete .ui-menu-item:contains("Best Designers")'
},
{
title: "select SAJ/2014/002",
element: '.oe_bank_statement_reconciliation_line:first-child .mv_line:contains("SAJ/2014/002")'
},
{
title: "click on the OK button",
element: '.oe_bank_statement_reconciliation_line:first-child .button_ok.oe_highlight'
},
// Create a new move line in first reconciliation and validate it
{
title: "check following reconciliation passes in mode create",
waitNot: '.oe_bank_statement_reconciliation_line:nth-child(3)', // wait for the reconciliation to be processed
element: '.oe_bank_statement_reconciliation_line:first-child[data-mode="create"]'
},
{
title: "click the Profit/Loss preset",
element: '.oe_bank_statement_reconciliation_line:first-child button:contains("Profit / Loss")'
},
{
title: "click on the OK button",
element: '.oe_bank_statement_reconciliation_line:first-child .button_ok.oe_highlight'
},
// Leave an open balance
{
title: "select SAJ/2014/003",
waitNot: '.oe_bank_statement_reconciliation_line:nth-child(2)', // wait for the reconciliation to be processed
element: '.oe_bank_statement_reconciliation_line:first-child .mv_line:contains("SAJ/2014/003")'
},
{
title: "click on the Keep Open button",
element: '.oe_bank_statement_reconciliation_line:first-child .button_ok:not(.oe_highlight)'
},
// Be done
{
title: "check 'finish screen' and close the statement",
waitFor: '.done_message',
element: '.button_close_statement'
},
{
title: "check the statement is closed",
element: '.oe_form_container header .label:contains("Closed")'
},
]
});
});
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -7,9 +7,9 @@
<link rel="stylesheet" href="/account/static/src/css/account_move_line_quickadd.css"/>
<link rel="stylesheet" href="/account/static/src/css/account_bank_and_cash.css"/>
<link rel="stylesheet" href="/account/static/src/css/account_bank_statement_reconciliation.css"/>
<script type="text/javascript" src="/account/static/src/js/account_widgets.js"></script>
<script type="text/javascript" src="/account/static/src/js/account_move_line_quickadd.js"></script>
<script type="text/javascript" src="/account/static/src/js/account_tour_bank_statement_reconciliation.js"></script>
<script type="text/javascript" src="/account/static/src/js/widgets.js"></script>
<script type="text/javascript" src="/account/static/src/js/move_line_quickadd.js"></script>
<script type="text/javascript" src="/account/static/src/js/tour_bank_statement_reconciliation.js"></script>
</xpath>
</template>
</data>