summaryrefslogtreecommitdiff
path: root/addons/account/static
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2018-02-26 10:14:00 +0100
committerChristophe Matthieu <chm@odoo.com>2018-02-27 15:35:23 +0100
commitbdfd1ebf0cd1bb391044602664aec80c6dbc116a (patch)
tree48c5779b1907d409edc3142f5a99432fe4eed877 /addons/account/static
parent39780b503744197fc86d14a40126d0dd144f42b1 (diff)
[REF] account: create 'account.reconciliation.widget' model
Contains widget reconciliation methods. This refactoring does not modify the feature, some errors have been notified in the code but not modified.
Diffstat (limited to 'addons/account/static')
-rw-r--r--addons/account/static/src/js/reconciliation/reconciliation_action.js2
-rw-r--r--addons/account/static/src/js/reconciliation/reconciliation_model.js50
-rw-r--r--addons/account/static/src/js/reconciliation/reconciliation_renderer.js5
-rw-r--r--addons/account/static/src/js/reconciliation/tour_reconciliation.js135
-rw-r--r--addons/account/static/src/js/tour_bank_statement_reconciliation.js149
-rw-r--r--addons/account/static/tests/reconciliation_tests.js127
6 files changed, 229 insertions, 239 deletions
diff --git a/addons/account/static/src/js/reconciliation/reconciliation_action.js b/addons/account/static/src/js/reconciliation/reconciliation_action.js
index 4102780c5c0..b047ed8cdaf 100644
--- a/addons/account/static/src/js/reconciliation/reconciliation_action.js
+++ b/addons/account/static/src/js/reconciliation/reconciliation_action.js
@@ -57,7 +57,7 @@ var StatementAction = Widget.extend(ControlPanelMixin, {
this.action_manager = parent;
this.params = params;
this.model = new this.config.Model(this, {
- modelName: "account.bank.statement.line",
+ modelName: "account.reconciliation.widget",
limitMoveLines: params.params && params.params.limitMoveLines || this.config.limitMoveLines,
});
this.widgets = [];
diff --git a/addons/account/static/src/js/reconciliation/reconciliation_model.js b/addons/account/static/src/js/reconciliation/reconciliation_model.js
index 9894dc6a9b4..570e111cbe6 100644
--- a/addons/account/static/src/js/reconciliation/reconciliation_model.js
+++ b/addons/account/static/src/js/reconciliation/reconciliation_model.js
@@ -11,8 +11,8 @@ var _t = core._t;
/**
- * Model use to fetch, format and update 'account.bank.statement' and
- * 'account.bank.statement.line' datas allowing reconciliation
+ * Model use to fetch, format and update 'account.reconciliation.widget',
+ * datas allowing reconciliation
*
* The statement internal structure::
*
@@ -133,8 +133,8 @@ var StatementModel = BasicModel.extend({
return $.when(this._computeLine(line), this._performMoveLine(handle));
},
/**
- * send information 'account.bank.statement.line' model to reconciliate
- * lines, call rpc to 'reconciliation_widget_auto_reconcile'
+ * send information 'account.reconciliation.widget' model to reconciliate
+ * lines, call rpc to 'auto_reconcile'
* Update the number of validated line
*
* @returns {Deferred<Object>} resolved with an object who contains
@@ -144,8 +144,8 @@ var StatementModel = BasicModel.extend({
var self = this;
var ids = _.pluck(_.filter(this.lines, {'reconciled': false}), 'id');
return this._rpc({
- model: 'account.bank.statement.line',
- method: 'reconciliation_widget_auto_reconcile',
+ model: 'account.reconciliation.widget',
+ method: 'auto_reconcile',
args: [ids, self.valuenow],
})
.then(function (result) {
@@ -342,7 +342,7 @@ var StatementModel = BasicModel.extend({
* - 'account.bank.statement' fetch the line id and bank_statement_id info
* - 'account.reconcile.model' fetch all reconcile model (for quick add)
* - 'account.account' fetch all account code
- * - 'account.bank.statement.line' fetch each line data
+ * - 'account.reconciliation.widget' fetch each line data
*
* @param {Object} context
* @param {number[]} context.statement_ids
@@ -357,8 +357,8 @@ var StatementModel = BasicModel.extend({
this.context = context;
var def_statement = this._rpc({
- model: 'account.bank.statement',
- method: 'reconciliation_widget_preprocess',
+ model: 'account.reconciliation.widget',
+ method: 'get_bank_statement_data',
args: [statement_ids],
})
.then(function (statement) {
@@ -430,8 +430,8 @@ var StatementModel = BasicModel.extend({
loadData: function(ids, excluded_ids) {
var self = this;
return self._rpc({
- model: 'account.bank.statement.line',
- method: 'get_data_for_reconciliation_widget',
+ model: 'account.reconciliation.widget',
+ method: 'get_bank_statement_line_data',
args: [ids, excluded_ids],
})
.then(self._formatLine.bind(self));
@@ -619,7 +619,7 @@ var StatementModel = BasicModel.extend({
return this._computeLine(line);
},
/**
- * Format the value and send it to 'account.bank.statement.line' model
+ * Format the value and send it to 'account.reconciliation.widget' model
* Update the number of validated lines
*
* @param {(string|string[])} handle
@@ -688,8 +688,8 @@ var StatementModel = BasicModel.extend({
});
return this._rpc({
- model: 'account.bank.statement.line',
- method: 'process_reconciliations',
+ model: 'account.reconciliation.widget',
+ method: 'process_bank_statement_line',
args: [ids, values],
})
.then(function () {
@@ -1062,7 +1062,7 @@ var StatementModel = BasicModel.extend({
return !isNaN(prop.id) || prop.account_id && prop.amount && prop.label && !!prop.label.length;
},
/**
- * Fetch 'account.bank.statement.line' propositions.
+ * Fetch 'account.reconciliation.widget' propositions.
*
* @see '_formatMoveLine'
*
@@ -1081,8 +1081,8 @@ var StatementModel = BasicModel.extend({
var offset = line.offset;
var limit = this.limitMoveLines+1;
return this._rpc({
- model: 'account.bank.statement.line',
- method: 'get_move_lines_for_reconciliation_widget',
+ model: 'account.reconciliation.widget',
+ method: 'get_move_lines_for_bank_statement_line',
args: [line.id, line.st_line.partner_id, excluded_ids, filter, offset, limit],
})
.then(this._formatMoveLine.bind(this, handle));
@@ -1141,7 +1141,7 @@ var ManualModel = StatementModel.extend({
/**
* load data from
- * - 'account.move.line' fetch the lines to reconciliate
+ * - 'account.reconciliation.widget' fetch the lines to reconciliate
* - 'account.account' fetch all account code
*
* @param {Object} context
@@ -1177,7 +1177,7 @@ var ManualModel = StatementModel.extend({
var mode = context.mode === 'customers' ? 'receivable' : 'payable';
var args = ['partner', context.partner_ids || null, mode];
return self._rpc({
- model: 'account.move.line',
+ model: 'account.reconciliation.widget',
method: 'get_data_for_manual_reconciliation',
args: args,
context: context,
@@ -1190,7 +1190,7 @@ var ManualModel = StatementModel.extend({
});
case 'accounts':
return self._rpc({
- model: 'account.move.line',
+ model: 'account.reconciliation.widget',
method: 'get_data_for_manual_reconciliation',
args: ['account', context.account_ids || self.account_ids],
context: context,
@@ -1209,8 +1209,8 @@ var ManualModel = StatementModel.extend({
account_ids = null; // TOFIX: REMOVE ME
partner_ids = null; // TOFIX: REMOVE ME
return self._rpc({
- model: 'account.move.line',
- method: 'get_data_for_manual_reconciliation_widget',
+ model: 'account.reconciliation.widget',
+ method: 'get_all_data_for_manual_reconciliation',
args: [partner_ids, account_ids],
context: context,
})
@@ -1278,8 +1278,8 @@ var ManualModel = StatementModel.extend({
if (process_reconciliations.length) {
def = self._rpc({
- model: 'account.move.line',
- method: 'process_reconciliations',
+ model: 'account.reconciliation.widget',
+ method: 'process_move_lines',
args: [process_reconciliations],
});
}
@@ -1440,7 +1440,7 @@ var ManualModel = StatementModel.extend({
var limit = this.limitMoveLines+1;
var args = [line.account_id.id, line.partner_id, excluded_ids, filter, offset, limit];
return this._rpc({
- model: 'account.move.line',
+ model: 'account.reconciliation.widget',
method: 'get_move_lines_for_manual_reconciliation',
args: args,
})
diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js
index 189304b6747..d68d4e9d693 100644
--- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js
+++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js
@@ -637,6 +637,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
},
/**
* @private
+ * @param {input event} event
*/
_onFilterChange: function (event) {
this.trigger_up('change_filter', {'data': _.str.strip($(event.target).val())});
@@ -688,7 +689,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
* @param {MouseEvent} event
*/
_onSelectMoveLine: function (event) {
- var $el = $(event.target)
+ var $el = $(event.target);
this._destroyPopover($el);
var moveLineId = $el.closest('.mv_line').data('line-id');
this.trigger_up('add_proposition', {'data': moveLineId});
@@ -698,7 +699,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
* @param {MouseEvent} event
*/
_onSelectProposition: function (event) {
- var $el = $(event.target)
+ var $el = $(event.target);
this._destroyPopover($el);
var moveLineId = $el.closest('.mv_line').data('line-id');
this.trigger_up('remove_proposition', {'data': moveLineId});
diff --git a/addons/account/static/src/js/reconciliation/tour_reconciliation.js b/addons/account/static/src/js/reconciliation/tour_reconciliation.js
new file mode 100644
index 00000000000..76a5bfdc65b
--- /dev/null
+++ b/addons/account/static/src/js/reconciliation/tour_reconciliation.js
@@ -0,0 +1,135 @@
+odoo.define('account.tour_bank_statement_reconciliation', function(require) {
+'use strict';
+
+var core = require('web.core');
+var rpc = require('web.rpc');
+var Tour = require('web_tour.tour');
+
+Tour.register('bank_statement_reconciliation', {
+ test: true,
+ // Go to the reconciliation page of the statement: "BNK/2014/001"
+ }, [
+ {
+ content: "wait web client",
+ extra_trigger: 'body:not(:has(.o_reconciliation))',
+ trigger: '.o_web_client',
+ run: function () {
+ console.log("looking for 'bank_statement_reconciliation' url");
+ rpc.query({
+ model: 'account.bank.statement',
+ method: 'search',
+ args: [[['name', '=', 'BNK/2014/001']]], // account in l10n_generic_coa
+ }).then(function(ids) {
+ var path = "/web#statement_ids=" + ids[0] + "&action=bank_statement_reconciliation_view";
+ console.log("'bank_statement_reconciliation' url is: '" + path + "'");
+ window.location.href = path;
+ }).fail(function () {
+ throw new Error("'account.bank.statement' named 'BNK/2014/001' not found");
+ });
+ },
+ timeout: 5000
+ },
+ {
+ content: "wait reconciliation page",
+ trigger: '.o_reconciliation',
+ run: function () {},
+ },
+
+ // open a line and reconcile a line proposed by the server
+
+ {
+ content: "open the last line in match mode to test the reconcile button",
+ extra_trigger: '.o_reconciliation_line:last .o_reconcile:visible',
+ trigger: '.o_reconciliation_line:last .accounting_view thead .cell_label:contains("/002")',
+ },
+ {
+ content: "deselect the proposed line",
+ extra_trigger: '.o_reconciliation_line:last[data-mode="match"]',
+ trigger: '.o_reconciliation_line:last .accounting_view .cell_label:contains("/0002")'
+ },
+ {
+ content: "re-select the line",
+ extra_trigger: '.o_reconciliation_line:last .o_no_valid:visible', // the user can't validate the line and display the write-off line
+ trigger: '.o_reconciliation_line:last .match .cell_label:contains("/0002")'
+ },
+ {
+ content: "reconcile the line",
+ trigger: '.o_reconciliation_line:last .o_reconcile:visible',
+ },
+
+ // Make a partial reconciliation
+
+ {
+ content: "open the last line in match mode to test the partial reconciliation",
+ extra_trigger: '.o_reconciliation_line:first[data-mode="match"]',
+ trigger: '.o_reconciliation_line:last .cell_label:contains("First")'
+ },
+ {
+ content: "select a line with with a higher amount",
+ trigger: '.o_reconciliation_line:last .match .cell_right:contains($ 4,610.00)'
+ },
+ {
+ content: "click on partial reconcile",
+ trigger: '.o_reconciliation_line:last .accounting_view .do_partial_reconcile_true'
+ },
+ {
+ content: "reconcile the line",
+ trigger: '.o_reconciliation_line:last .o_reconcile:visible',
+ },
+
+ // Test changing the partner
+
+ {
+ content: "change the partner of the second line",
+ trigger: '.o_reconciliation_line:nth-child(2) .o_field_many2one input',
+ run: 'text Agro'
+ },
+ {
+ content: "select Agrolait",
+ extra_trigger: '.ui-autocomplete:visible li:eq(1):contains(Create "Agro")',
+ trigger: '.ui-autocomplete:visible li:contains(Agrolait)',
+ },
+ {
+ content: "use filter",
+ extra_trigger: '.o_reconciliation_line:nth-child(2) .match:not(:has(tr:eq(2))) tr:eq(1)',
+ trigger: '.o_reconciliation_line:nth-child(2) .match .match_controls .filter',
+ run: 'text 4610'
+ },
+ {
+ content: "select a line linked to Agrolait",
+ extra_trigger: '.o_reconciliation_line:nth-child(2) .match:not(:has(tr:eq(1)))',
+ trigger: '.o_reconciliation_line:nth-child(2) .match .line_info_button[data-content*=Agrolait]'
+ },
+ {
+ content: "deselect the line",
+ trigger: '.o_reconciliation_line:nth-child(2) .accounting_view tbody .cell_label:first'
+ },
+ {
+ content: "create a write-off",
+ extra_trigger: '.o_reconciliation_line:nth-child(2) .accounting_view tbody:not(:has(.cell_label))',
+ trigger: '.o_reconciliation_line:nth-child(2) .accounting_view tfoot .cell_label'
+ },
+ {
+ content: "enter an account",
+ trigger: '.o_reconciliation_line:nth-child(2) .o_field_many2one[name="account_id"] input',
+ run: 'text 100000'
+ },
+ {
+ content: "select the first account",
+ extra_trigger: '.ui-autocomplete:visible li:eq(1):contains(Create "100000")',
+ trigger: '.ui-autocomplete:visible li:contains(100000)',
+ },
+ {
+ content: "reconcile the line with the write-off",
+ trigger: '.o_reconciliation_line:nth-child(2) .o_reconcile:visible',
+ },
+
+ // Be done
+ {
+ content: "check the number off validate lines",
+ trigger: '.o_reconciliation .progress-text:contains(3 / 5)'
+ },
+ ]
+);
+
+});
diff --git a/addons/account/static/src/js/tour_bank_statement_reconciliation.js b/addons/account/static/src/js/tour_bank_statement_reconciliation.js
deleted file mode 100644
index b56b8747f1f..00000000000
--- a/addons/account/static/src/js/tour_bank_statement_reconciliation.js
+++ /dev/null
@@ -1,149 +0,0 @@
-odoo.define('account.tour_bank_statement_reconciliation', 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',
- 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")'
- },
- ]
-});
-
-});
diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js
index 5331fb09c0f..809830b09fd 100644
--- a/addons/account/static/tests/reconciliation_tests.js
+++ b/addons/account/static/tests/reconciliation_tests.js
@@ -111,9 +111,6 @@ var db = {
},
'account.bank.statement': {
fields: {},
- reconciliation_widget_preprocess: function () {
- return $.when(Datas.used.data_preprocess);
- },
},
'account.bank.statement.line': {
fields: {
@@ -127,25 +124,45 @@ var db = {
{id: 7, display_name: "Prepayment"},
{id: 8, display_name: "First 2000 \u20ac of SAJ/2014/001"},
],
- get_move_lines_for_reconciliation_widget: function (args) {
- var partner_id = args.splice(1, 1)[0];
- var excluded_ids = args.splice(1, 1)[0];
- var key = JSON.stringify(args);
- if (!Datas.used.mv_lines[key]) {
- throw new Error("Unknown parameters for get_move_lines_for_reconciliation_widget: '"+ key + "'");
- }
- return $.when(_.filter(Datas.used.mv_lines[key], function (line) {
- return excluded_ids.indexOf(line.id) === -1 && (!partner_id || partner_id === line.partner_id);
- }));
- },
- get_data_for_reconciliation_widget: function (args) {
- var ids = args[0];
- return $.when(_.filter(Datas.used.data_widget, function (w) {return _.contains(ids, w.st_line.id);}));
+ },
+ 'account.move.line': {
+ fields: {},
+ },
+ 'account.reconcile.model': {
+ fields: {
+ id: {string: "ID", type: 'integer'},
+ name: {string: "Button Label", type: 'char'},
+ has_second_line: {string: "Add a second line", type: 'boolean'},
+ account_id: {string: "Account", type: 'many2one', relation:'account.account'},
+ journal_id: {string: "Journal", type: 'many2one', relation:'account.journal'},
+ label: {string: "Journal Item Label", type: 'char'},
+ amount_type: {string: 'amount_type', type: 'selection', selection: [['fixed', 'Fixed'], ['percentage', 'Percentage of balance']], default:'percentage'},
+ amount: {string: "Amount", type: 'float', digits:0, help:"Fixed amount will count as a debit if it is negative, as a credit if it is positive.", default:100.0},
+ tax_id: {string: "Tax", type: 'many2one', relation:'account.tax', domain:[('type_tax_use', '=', 'purchase')]},
+ analytic_account_id: {string: "Analytic Account", type: 'many2one', relation:'account.analytic.account'},
+ second_account_id: {string: "Second Account", type: 'many2one', relation:'account.account', domain:[('deprecated', '=', false)]},
+ second_journal_id: {string: "Second Journal", type: 'many2one', relation:'account.journal', help:"This field is ignored in a bank statement reconciliation."},
+ second_label: {string: "Second Journal Item Label", type: 'char'},
+ second_amount_type: {string: "Second amount_type", type: 'selection', selection: [['fixed', 'Fixed'], ['percentage', 'Percentage of balance']], default:'percentage'},
+ second_amount: {string: "Second Amount", type: 'float', digits:0, help:"Fixed amount will count as a debit if it is negative, as a credit if it is positive.", default:100.0},
+ second_tax_id: {string: "Second Tax", type: 'many2one', relation:'account.tax', domain:[('type_tax_use', '=', 'purchase')]},
+ second_analytic_account_id: {string: "Second Analytic Account", type: 'many2one', relation:'account.analytic.account'},
},
- reconciliation_widget_auto_reconcile: function () {
+ records: [
+ {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 4, 'analytic_account_id': false, 'display_name': "Int\u00e9rrets", 'second_tax_id': false, 'has_second_line': false, 'journal_id': false, 'label': false, 'second_label': false, 'second_account_id': false, 'account_id': 282, 'company_id': [1, "Demo SPRL"], 'tax_id': false, 'amount_type': "fixed", 'name': "Int\u00e9rrets", 'amount': 0.0, 'second_amount': 100.0},
+ {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 2, 'analytic_account_id': false, 'display_name': "Perte et Profit", 'second_tax_id': false, 'has_second_line': false, 'journal_id': false, 'label': false, 'second_label': false, 'second_account_id': false, 'account_id': 283, 'company_id': [1, "Demo SPRL"], 'tax_id': false, 'amount_type': "percentage", 'name': "Perte et Profit", 'amount': 100.0, 'second_amount': 100.0},
+ {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 5, 'analytic_account_id': false, 'display_name': "Fs bank", 'second_tax_id': false, 'has_second_line': false, 'journal_id': false, 'label': false, 'second_label': false, 'second_account_id': false, 'account_id': 284, 'company_id': [1, "Demo SPRL"], 'tax_id': false, 'amount_type': "percentage", 'name': "Fs bank", 'amount': 100.0, 'second_amount': 100.0},
+ {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 8, 'analytic_account_id': false, 'display_name': "Caisse Sand.", 'second_tax_id': false, 'has_second_line': false, 'journal_id': false, 'label': "Caisse Sand.", 'second_label': false, 'second_account_id': false, 'account_id': 308, 'company_id': [1, "Demo SPRL"], 'tax_id': false, 'amount_type': "percentage", 'name': "Caisse Sand.", 'amount': 100.0, 'second_amount': 100.0},
+ {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 3, 'analytic_account_id': false, 'display_name': "ATOS", 'second_tax_id': 7, 'has_second_line': true, 'journal_id': false, 'label': "ATOS Banque", 'second_label': "ATOS Frais", 'second_account_id': 286, 'account_id': 285, 'company_id': [1, "Demo SPRL"], 'tax_id': 6, 'amount_type': "percentage", 'name': "ATOS", 'amount': 97.5, 'second_amount': 2.5},
+ {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 10, 'analytic_account_id': false, 'display_name': "Double", 'second_tax_id': false, 'has_second_line': true, 'journal_id': false, 'label': "Double Banque", 'second_label': "Double Frais", 'second_account_id': 286, 'account_id': 285, 'company_id': [1, "Demo SPRL"], 'tax_id': false, 'amount_type': "percentage", 'name': "Double", 'amount': 97.5, 'second_amount': 2.5},
+ ]
+ },
+ 'account.reconciliation.widget': {
+ fields: {},
+ auto_reconcile: function () {
return $.when(Datas.used.auto_reconciliation);
},
- process_reconciliations: function (args) {
+ process_bank_statement_line: function (args) {
var datas = args[1];
var ids = _.flatten(_.pluck(_.pluck(datas, 'counterpart_aml_dicts'), 'counterpart_aml_id'));
ids = ids.concat(_.flatten(_.pluck(datas, 'payment_aml_ids')));
@@ -158,15 +175,23 @@ var db = {
}
return $.when();
},
- },
- 'account.move.line': {
- fields: {},
- get_data_for_manual_reconciliation_widget: function (args) {
+ get_move_lines_for_bank_statement_line: function (args) {
+ var partner_id = args.splice(1, 1)[0];
+ var excluded_ids = args.splice(1, 1)[0];
var key = JSON.stringify(args);
- if (!Datas.used.data_for_manual_reconciliation_widget[key]) {
- throw new Error("Unknown parameters for get_data_for_manual_reconciliation_widget: '"+ key + "'");
+ if (!Datas.used.mv_lines[key]) {
+ throw new Error("Unknown parameters for get_move_lines_for_bank_statement_line: '"+ key + "'");
}
- return $.when(Datas.used.data_for_manual_reconciliation_widget[key]);
+ return $.when(_.filter(Datas.used.mv_lines[key], function (line) {
+ return excluded_ids.indexOf(line.id) === -1 && (!partner_id || partner_id === line.partner_id);
+ }));
+ },
+ get_bank_statement_line_data: function (args) {
+ var ids = args[0];
+ return $.when(_.filter(Datas.used.data_widget, function (w) {return _.contains(ids, w.st_line.id);}));
+ },
+ get_bank_statement_data: function () {
+ return $.when(Datas.used.data_preprocess);
},
get_move_lines_for_manual_reconciliation: function (args) {
var excluded_ids = args.splice(2, 1)[0];
@@ -178,8 +203,14 @@ var db = {
return excluded_ids.indexOf(line.id) === -1;
}));
},
- // for manual reconciliation
- process_reconciliations: function (args) {
+ get_all_data_for_manual_reconciliation: function (args) {
+ var key = JSON.stringify(args);
+ if (!Datas.used.data_for_manual_reconciliation_widget[key]) {
+ throw new Error("Unknown parameters for get_all_data_for_manual_reconciliation: '"+ key + "'");
+ }
+ return $.when(Datas.used.data_for_manual_reconciliation_widget[key]);
+ },
+ process_move_lines: function (args) {
var datas = args[0];
for (var i in datas) {
var data = datas[i];
@@ -191,35 +222,6 @@ var db = {
}
return $.when();
},
- },
- 'account.reconcile.model': {
- fields: {
- id: {string: "ID", type: 'integer'},
- name: {string: "Button Label", type: 'char'},
- has_second_line: {string: "Add a second line", type: 'boolean'},
- account_id: {string: "Account", type: 'many2one', relation:'account.account'},
- journal_id: {string: "Journal", type: 'many2one', relation:'account.journal'},
- label: {string: "Journal Item Label", type: 'char'},
- amount_type: {string: 'amount_type', type: 'selection', selection: [['fixed', 'Fixed'], ['percentage', 'Percentage of balance']], default:'percentage'},
- amount: {string: "Amount", type: 'float', digits:0, help:"Fixed amount will count as a debit if it is negative, as a credit if it is positive.", default:100.0},
- tax_id: {string: "Tax", type: 'many2one', relation:'account.tax', domain:[('type_tax_use', '=', 'purchase')]},
- analytic_account_id: {string: "Analytic Account", type: 'many2one', relation:'account.analytic.account'},
- second_account_id: {string: "Second Account", type: 'many2one', relation:'account.account', domain:[('deprecated', '=', false)]},
- second_journal_id: {string: "Second Journal", type: 'many2one', relation:'account.journal', help:"This field is ignored in a bank statement reconciliation."},
- second_label: {string: "Second Journal Item Label", type: 'char'},
- second_amount_type: {string: "Second amount_type", type: 'selection', selection: [['fixed', 'Fixed'], ['percentage', 'Percentage of balance']], default:'percentage'},
- second_amount: {string: "Second Amount", type: 'float', digits:0, help:"Fixed amount will count as a debit if it is negative, as a credit if it is positive.", default:100.0},
- second_tax_id: {string: "Second Tax", type: 'many2one', relation:'account.tax', domain:[('type_tax_use', '=', 'purchase')]},
- second_analytic_account_id: {string: "Second Analytic Account", type: 'many2one', relation:'account.analytic.account'},
- },
- records: [
- {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 4, 'analytic_account_id': false, 'display_name': "Int\u00e9rrets", 'second_tax_id': false, 'has_second_line': false, 'journal_id': false, 'label': false, 'second_label': false, 'second_account_id': false, 'account_id': 282, 'company_id': [1, "Demo SPRL"], 'tax_id': false, 'amount_type': "fixed", 'name': "Int\u00e9rrets", 'amount': 0.0, 'second_amount': 100.0},
- {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 2, 'analytic_account_id': false, 'display_name': "Perte et Profit", 'second_tax_id': false, 'has_second_line': false, 'journal_id': false, 'label': false, 'second_label': false, 'second_account_id': false, 'account_id': 283, 'company_id': [1, "Demo SPRL"], 'tax_id': false, 'amount_type': "percentage", 'name': "Perte et Profit", 'amount': 100.0, 'second_amount': 100.0},
- {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 5, 'analytic_account_id': false, 'display_name': "Fs bank", 'second_tax_id': false, 'has_second_line': false, 'journal_id': false, 'label': false, 'second_label': false, 'second_account_id': false, 'account_id': 284, 'company_id': [1, "Demo SPRL"], 'tax_id': false, 'amount_type': "percentage", 'name': "Fs bank", 'amount': 100.0, 'second_amount': 100.0},
- {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 8, 'analytic_account_id': false, 'display_name': "Caisse Sand.", 'second_tax_id': false, 'has_second_line': false, 'journal_id': false, 'label': "Caisse Sand.", 'second_label': false, 'second_account_id': false, 'account_id': 308, 'company_id': [1, "Demo SPRL"], 'tax_id': false, 'amount_type': "percentage", 'name': "Caisse Sand.", 'amount': 100.0, 'second_amount': 100.0},
- {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 3, 'analytic_account_id': false, 'display_name': "ATOS", 'second_tax_id': 7, 'has_second_line': true, 'journal_id': false, 'label': "ATOS Banque", 'second_label': "ATOS Frais", 'second_account_id': 286, 'account_id': 285, 'company_id': [1, "Demo SPRL"], 'tax_id': 6, 'amount_type': "percentage", 'name': "ATOS", 'amount': 97.5, 'second_amount': 2.5},
- {'second_analytic_account_id': false, 'second_amount_type': "percentage", 'second_journal_id': false, 'id': 10, 'analytic_account_id': false, 'display_name': "Double", 'second_tax_id': false, 'has_second_line': true, 'journal_id': false, 'label': "Double Banque", 'second_label': "Double Frais", 'second_account_id': 286, 'account_id': 285, 'company_id': [1, "Demo SPRL"], 'tax_id': false, 'amount_type': "percentage", 'name': "Double", 'amount': 97.5, 'second_amount': 2.5},
- ]
}
};
@@ -659,7 +661,7 @@ QUnit.module('account', {
"analytic_tag_ids": [[6, null, []]]
}],
payment_aml_ids: [], new_aml_dicts: []}]],
- "Should call process_reconciliations with ids");
+ "Should call process_bank_statement_line with ids");
});
// click on reconcile button
@@ -701,7 +703,7 @@ QUnit.module('account', {
name: 'SAJ/2014/002 and SAJ/2014/003',
analytic_tag_ids: [[6, null, []]]
}]}]],
- "Should call process_reconciliations with ids");
+ "Should call process_bank_statement_line with ids");
});
// click on validate button
@@ -754,7 +756,7 @@ QUnit.module('account', {
debit: 0,
name: 'SAJ/2014/002 and SAJ/2014/003 : Open balance'
}]}]],
- "Should call process_reconciliations with ids");
+ "Should call process_bank_statement_line with ids");
});
// click on validate button
@@ -769,7 +771,8 @@ QUnit.module('account', {
testUtils.addMockEnvironment(clientAction, {
data: this.params.data,
mockRPC: function (route, args) {
- if (args.method === 'process_reconciliations') {
+ console.log(args.method);
+ if (args.method === 'process_bank_statement_line') {
assert.deepEqual(args.args, [
[6],
[{
@@ -778,7 +781,7 @@ QUnit.module('account', {
payment_aml_ids: [392],
new_aml_dicts: [],
}]
- ], "should call process_reconciliations with partial reconcile values");
+ ], "should call process_bank_statement_line with partial reconcile values");
}
return this._super(route, args);
},