[REF] account: adapt code after jQuery update
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
This commit is contained in:
committed by
Aaron Bohy
co-authored by
Aaron Bohy
Christophe Matthieu
Mathieu Duckerts-Antoine
David Monjoie
Martin Geubelle
svs-odoo
parent
99836c1be6
commit
a217936144
@@ -105,7 +105,7 @@ var StatementAction = AbstractAction.extend({
|
||||
var self = this;
|
||||
_.each(this.widgets, function(widget) {
|
||||
widget.destroy();
|
||||
})
|
||||
});
|
||||
this.widgets = [];
|
||||
this.model.reload()
|
||||
.then(function() {
|
||||
@@ -122,23 +122,26 @@ var StatementAction = AbstractAction.extend({
|
||||
*/
|
||||
start: function () {
|
||||
var self = this;
|
||||
var args = arguments;
|
||||
var sup = this._super;
|
||||
|
||||
this.renderer.prependTo(self.$('.o_form_sheet'));
|
||||
this._renderLines();
|
||||
return this.renderer.prependTo(self.$('.o_form_sheet')).then(function() {
|
||||
return self._renderLines().then(function() {
|
||||
// No more lines to reconcile, trigger the rainbowman.
|
||||
var initialState = self.renderer._initialState;
|
||||
if(initialState.valuenow === initialState.valuemax){
|
||||
initialState.context = self.model.getContext();
|
||||
self.renderer.showRainbowMan(initialState);
|
||||
}else{
|
||||
// Create a notification if some lines has been reconciled automatically.
|
||||
if(initialState.valuenow > 0)
|
||||
self.renderer._renderNotifications(self.model.statement.notifications);
|
||||
self._openFirstLine();
|
||||
}
|
||||
|
||||
// No more lines to reconcile, trigger the rainbowman.
|
||||
var initialState = this.renderer._initialState;
|
||||
if(initialState.valuenow === initialState.valuemax){
|
||||
initialState.context = this.model.getContext();
|
||||
this.renderer.showRainbowMan(initialState);
|
||||
}else{
|
||||
// Create a notification if some lines has been reconciled automatically.
|
||||
if(initialState.valuenow > 0)
|
||||
this.renderer._renderNotifications(this.model.statement.notifications);
|
||||
this._openFirstLine();
|
||||
}
|
||||
|
||||
return this._super.apply(this, arguments);
|
||||
return sup.apply(self, args);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -176,7 +179,7 @@ var StatementAction = AbstractAction.extend({
|
||||
_loadMore: function(qty) {
|
||||
var self = this;
|
||||
return this.model.loadMore(qty).then(function () {
|
||||
self._renderLines();
|
||||
return self._renderLines();
|
||||
});
|
||||
},
|
||||
/**
|
||||
@@ -192,7 +195,9 @@ var StatementAction = AbstractAction.extend({
|
||||
}))[0];
|
||||
if (handle) {
|
||||
var line = this.model.getLine(handle);
|
||||
this.model.changeMode(handle, 'match').always(function () {
|
||||
this.model.changeMode(handle, 'match').then(function () {
|
||||
self._getWidget(handle).update(line);
|
||||
}).guardedCatch(function(){
|
||||
self._getWidget(handle).update(line);
|
||||
});
|
||||
}
|
||||
@@ -206,11 +211,12 @@ var StatementAction = AbstractAction.extend({
|
||||
_renderLines: function () {
|
||||
var self = this;
|
||||
var linesToDisplay = this.model.getStatementLines();
|
||||
var linePromises = [];
|
||||
_.each(linesToDisplay, function (line, handle) {
|
||||
var widget = new self.config.LineRenderer(self, self.model, line);
|
||||
widget.handle = handle;
|
||||
self.widgets.push(widget);
|
||||
widget.appendTo(self.$('.o_reconciliation_lines'));
|
||||
linePromises.push(widget.appendTo(self.$('.o_reconciliation_lines')));
|
||||
});
|
||||
if (this.model.hasMoreLines() === false) {
|
||||
this.renderer.hideLoadMoreButton(true);
|
||||
@@ -218,6 +224,7 @@ var StatementAction = AbstractAction.extend({
|
||||
else {
|
||||
this.renderer.hideLoadMoreButton(false);
|
||||
}
|
||||
return Promise.all(linePromises);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -237,7 +244,7 @@ var StatementAction = AbstractAction.extend({
|
||||
var handle = event.target.handle;
|
||||
var line = this.model.getLine(handle);
|
||||
var mode = line.mode;
|
||||
this.model[_.str.camelize(event.name)](handle, event.data.data).always(function () {
|
||||
this.model[_.str.camelize(event.name)](handle, event.data.data).then(function () {
|
||||
self._getWidget(handle).update(line);
|
||||
if (mode === 'inactive' && line.mode !== 'inactive') {
|
||||
_.each(self.model.lines, function (line, _handle) {
|
||||
@@ -320,7 +327,7 @@ var StatementAction = AbstractAction.extend({
|
||||
},
|
||||
/**
|
||||
* call 'validate' model method then destroy the
|
||||
* validated lines and update the action renderer with the new status bar
|
||||
* validated lines and update the action renderer with the new status bar
|
||||
* values and notifications then open the first available line
|
||||
*
|
||||
* @private
|
||||
@@ -329,8 +336,7 @@ var StatementAction = AbstractAction.extend({
|
||||
_onValidate: function (event) {
|
||||
var self = this;
|
||||
var handle = event.target.handle;
|
||||
var method = 'validate';
|
||||
this.model[method](handle).then(function (result) {
|
||||
this.model.validate(handle).then(function (result) {
|
||||
self.renderer.update({
|
||||
'valuenow': self.model.valuenow,
|
||||
'valuemax': self.model.valuemax,
|
||||
@@ -345,7 +351,7 @@ var StatementAction = AbstractAction.extend({
|
||||
self.widgets.splice(index, 1);
|
||||
});
|
||||
// Get number of widget and if less than constant and if there are more to laod, load until constant
|
||||
if (self.widgets.length < self.model.defaultDisplayQty
|
||||
if (self.widgets.length < self.model.defaultDisplayQty
|
||||
&& self.model.valuemax - self.model.valuenow >= self.model.defaultDisplayQty) {
|
||||
var toLoad = self.model.defaultDisplayQty - self.widgets.length;
|
||||
self._loadMore(toLoad);
|
||||
|
||||
@@ -125,7 +125,7 @@ var StatementModel = BasicModel.extend({
|
||||
*
|
||||
* @param {string} handle
|
||||
* @param {number} mv_line_id
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
addProposition: function (handle, mv_line_id) {
|
||||
var self = this;
|
||||
@@ -138,19 +138,19 @@ var StatementModel = BasicModel.extend({
|
||||
if(!line.st_line.partner_id && line.reconciliation_proposition
|
||||
&& line.reconciliation_proposition.length == 1 && prop.partner_id && line.type === undefined){
|
||||
return this.changePartner(handle, {'id': prop.partner_id, 'display_name': prop.partner_name}, true)
|
||||
.then(function (result) {
|
||||
return $.when(self._computeLine(line), self._performMoveLine(handle));
|
||||
.then(function () {
|
||||
return Promise.all([self._computeLine(line), self._performMoveLine(handle)]);
|
||||
});
|
||||
}
|
||||
|
||||
return $.when(this._computeLine(line), this._performMoveLine(handle));
|
||||
return Promise.all([this._computeLine(line), this._performMoveLine(handle)]);
|
||||
},
|
||||
/**
|
||||
* change the filter for the target line and fetch the new matched lines
|
||||
*
|
||||
* @param {string} handle
|
||||
* @param {string} filter
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
changeFilter: function (handle, filter) {
|
||||
var line = this.getLine(handle);
|
||||
@@ -171,7 +171,7 @@ var StatementModel = BasicModel.extend({
|
||||
*
|
||||
* @param {string} handle
|
||||
* @param {'inactive' | 'match' | 'create'} mode
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
changeMode: function (handle, mode) {
|
||||
var line = this.getLine(handle);
|
||||
@@ -189,13 +189,13 @@ var StatementModel = BasicModel.extend({
|
||||
if (line.mode === 'create') {
|
||||
return this.createProposition(handle);
|
||||
}
|
||||
return $.when();
|
||||
return Promise.resolve();
|
||||
},
|
||||
/**
|
||||
* call 'write' method on the 'account.bank.statement'
|
||||
*
|
||||
* @param {string} name
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
changeName: function (name) {
|
||||
return this._rpc({
|
||||
@@ -209,7 +209,7 @@ var StatementModel = BasicModel.extend({
|
||||
*
|
||||
* @param {string} handle
|
||||
* @param {number} offset
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
changeOffset: function (handle, offset) {
|
||||
this.getLine(handle).offset += (offset > 0 ? 1 : -1) * this.limitMoveLines;
|
||||
@@ -223,14 +223,14 @@ var StatementModel = BasicModel.extend({
|
||||
* @param {Object} partner
|
||||
* @param {string} partner.display_name
|
||||
* @param {number} partner.id
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
changePartner: function (handle, partner, preserveMode) {
|
||||
var self = this;
|
||||
var line = this.getLine(handle);
|
||||
line.st_line.partner_id = partner && partner.id;
|
||||
line.st_line.partner_name = partner && partner.display_name || '';
|
||||
return $.when(partner && this._changePartner(handle, partner.id))
|
||||
return Promise.resolve(partner && this._changePartner(handle, partner.id))
|
||||
.then(function() {
|
||||
if(line.st_line.partner_id){
|
||||
_.each(line.reconciliation_proposition, function(prop){
|
||||
@@ -238,7 +238,7 @@ var StatementModel = BasicModel.extend({
|
||||
line.reconciliation_proposition = [];
|
||||
return false;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
return self._computeLine(line);
|
||||
})
|
||||
@@ -249,12 +249,12 @@ var StatementModel = BasicModel.extend({
|
||||
})
|
||||
.then(function () {
|
||||
return line.mode === 'create' ? self.createProposition(handle) : false;
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
/**
|
||||
* close the statement
|
||||
* @returns {Deferred<number>} resolves to the res_id of the closed statements
|
||||
* @returns {Promise<number>} resolves to the res_id of the closed statements
|
||||
*/
|
||||
closeStatement: function () {
|
||||
var self = this;
|
||||
@@ -272,14 +272,14 @@ var StatementModel = BasicModel.extend({
|
||||
* then open the first available line
|
||||
*
|
||||
* @param {string} handle
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
createProposition: function (handle) {
|
||||
var line = this.getLine(handle);
|
||||
var prop = _.filter(line.reconciliation_proposition, '__focus');
|
||||
var last = prop[prop.length-1];
|
||||
if (last && !this._isValid(last)) {
|
||||
return $.Deferred().resolve(false);
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
prop = this._formatQuickCreate(line);
|
||||
@@ -301,7 +301,7 @@ var StatementModel = BasicModel.extend({
|
||||
*/
|
||||
getStatementLines: function () {
|
||||
var self = this;
|
||||
var linesToDisplay = _.pick(this.lines, function(value, key, object) {
|
||||
var linesToDisplay = _.pick(this.lines, function(value, key, object) {
|
||||
if (value.visible === true && self.alreadyDisplayed.indexOf(key) === -1) {
|
||||
self.alreadyDisplayed.push(key);
|
||||
return object;
|
||||
@@ -315,7 +315,6 @@ var StatementModel = BasicModel.extend({
|
||||
* @returns {boolean} true if load more button needs to be displayed
|
||||
*/
|
||||
hasMoreLines: function () {
|
||||
var self = this;
|
||||
var notDisplayed = _.filter(this.lines, function(line) { return !line.visible; });
|
||||
if (notDisplayed.length > 0) {
|
||||
return true;
|
||||
@@ -341,23 +340,23 @@ var StatementModel = BasicModel.extend({
|
||||
*
|
||||
* @param {Object} context
|
||||
* @param {number[]} context.statement_line_ids
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
load: function (context) {
|
||||
var self = this;
|
||||
this.statement_line_ids = context.statement_line_ids;
|
||||
if (!this.statement_line_ids) {
|
||||
return $.when();
|
||||
return Promise.resolve();
|
||||
}
|
||||
this.context = context;
|
||||
return self.reload();
|
||||
|
||||
|
||||
},
|
||||
/**
|
||||
* Load more bank statement line
|
||||
*
|
||||
* @param {integer} qty quantity to load
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
loadMore: function(qty) {
|
||||
if (qty === undefined) {
|
||||
@@ -370,10 +369,10 @@ var StatementModel = BasicModel.extend({
|
||||
},
|
||||
/**
|
||||
* RPC method to load informations on lines
|
||||
*
|
||||
*
|
||||
* @param {Array} ids ids of bank statement line passed to rpc call
|
||||
* @param {Array} excluded_ids list of move_line ids that needs to be excluded from search
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
loadData: function(ids, excluded_ids) {
|
||||
var self = this;
|
||||
@@ -393,7 +392,8 @@ var StatementModel = BasicModel.extend({
|
||||
self.alreadyDisplayed = [];
|
||||
self.lines = {};
|
||||
self.pagerIndex = 0;
|
||||
self.search_str = $('.reconciliation_search_input').val()
|
||||
// FIXME: model should not be tied to the DOM !
|
||||
self.search_str = $('.reconciliation_search_input').val();
|
||||
var def_statement = this._rpc({
|
||||
model: 'account.reconciliation.widget',
|
||||
method: 'get_bank_statement_data',
|
||||
@@ -446,7 +446,7 @@ var StatementModel = BasicModel.extend({
|
||||
self.accounts = _.object(_.pluck(accounts, 'id'), _.pluck(accounts, 'code'));
|
||||
});
|
||||
var def_taxes = self._loadTaxes();
|
||||
return $.when(def_statement, def_reconcileModel, def_account, def_taxes).then(function () {
|
||||
return Promise.all([def_statement, def_reconcileModel, def_account, def_taxes]).then(function () {
|
||||
_.each(self.lines, function (line) {
|
||||
line.reconcileModels = self.reconcileModels;
|
||||
});
|
||||
@@ -469,21 +469,21 @@ var StatementModel = BasicModel.extend({
|
||||
self.taxes[tax.id] = {
|
||||
price_include: tax.price_include,
|
||||
amount_type: tax.amount_type,
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Add lines into the propositions from the reconcile model
|
||||
* Can add 2 lines, and each with its taxes. The second line become editable
|
||||
* in the create mode.
|
||||
*
|
||||
*
|
||||
* @see 'updateProposition' method for more informations about the
|
||||
* 'amount_type'
|
||||
*
|
||||
* @param {string} handle
|
||||
* @param {integer} reconcileModelId
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
quickCreateProposition: function (handle, reconcileModelId) {
|
||||
var line = this.getLine(handle);
|
||||
@@ -493,12 +493,12 @@ var StatementModel = BasicModel.extend({
|
||||
|
||||
var focus = this._formatQuickCreate(line, _.pick(reconcileModel, fields));
|
||||
focus.reconcileModelId = reconcileModelId;
|
||||
if (!line.reconciliation_proposition.every(function(prop) {return prop.to_check == focus.to_check})) {
|
||||
if (!line.reconciliation_proposition.every(function(prop) {return prop.to_check == focus.to_check;})) {
|
||||
new CrashManager().show_warning({data: {
|
||||
exception_type: _t("Incorrect Operation"),
|
||||
message: _t("You cannot mix items with and without the 'To Check' checkbox ticked.")
|
||||
}});
|
||||
return $.when();
|
||||
return Promise.resolve();
|
||||
}
|
||||
line.reconciliation_proposition.push(focus);
|
||||
|
||||
@@ -520,7 +520,7 @@ var StatementModel = BasicModel.extend({
|
||||
*
|
||||
* @param {string} handle
|
||||
* @param {number} id (move line id)
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeProposition: function (handle, id) {
|
||||
var self = this;
|
||||
@@ -541,15 +541,15 @@ var StatementModel = BasicModel.extend({
|
||||
line.mode = (id || line.mode !== "create") && isNaN(id) && !this.avoidCreate ? 'create' : 'match';
|
||||
defs.push(this._computeLine(line));
|
||||
if (line.mode === 'create') {
|
||||
return $.when.apply($, defs).then(function () {
|
||||
return Promise.all(defs).then(function () {
|
||||
return self.createProposition(handle);
|
||||
});
|
||||
} else if (line.mode === 'match') {
|
||||
return $.when.apply($, defs).then(function () {
|
||||
return Promise.all(defs).then(function () {
|
||||
return self._performMoveLine(handle);
|
||||
});
|
||||
}
|
||||
return $.when.apply($, defs);
|
||||
return Promise.all(defs);
|
||||
},
|
||||
getPartialReconcileAmount: function(handle, data) {
|
||||
var line = this.getLine(handle);
|
||||
@@ -562,7 +562,7 @@ var StatementModel = BasicModel.extend({
|
||||
return Math.abs(amount);
|
||||
}
|
||||
if (partial <= Math.abs(prop.amount) && partial >= 0) {
|
||||
return partial
|
||||
return partial;
|
||||
}
|
||||
return Math.abs(amount);
|
||||
}
|
||||
@@ -571,7 +571,7 @@ var StatementModel = BasicModel.extend({
|
||||
* Force the partial reconciliation to display the reconciliate button.
|
||||
*
|
||||
* @param {string} handle
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
partialReconcile: function(handle, data) {
|
||||
var line = this.getLine(handle);
|
||||
@@ -607,14 +607,14 @@ var StatementModel = BasicModel.extend({
|
||||
* Change the value of the editable proposition line or create a new one.
|
||||
*
|
||||
* If the editable line comes from a reconcile model with 2 lines
|
||||
* and their 'amount_type' is "percent"
|
||||
* and their 'amount_type' is "percent"
|
||||
* and their total equals 100% (this doesn't take into account the taxes
|
||||
* who can be included or not)
|
||||
* Then the total is recomputed to have 100%.
|
||||
*
|
||||
* @param {string} handle
|
||||
* @param {*} values
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
updateProposition: function (handle, values) {
|
||||
var self = this;
|
||||
@@ -624,13 +624,14 @@ var StatementModel = BasicModel.extend({
|
||||
prop = this._formatQuickCreate(line);
|
||||
line.reconciliation_proposition.push(prop);
|
||||
}
|
||||
if (!line.reconciliation_proposition.slice(0,-1).every(function(prop) {return prop.to_check == values.to_check})) {
|
||||
if (!line.reconciliation_proposition.slice(0,-1).every(function(prop) {return prop.to_check == values.to_check;})) {
|
||||
new CrashManager().show_warning({data: {
|
||||
exception_type: _t("Incorrect Operation"),
|
||||
message: _t("You cannot mix items with and without the 'To Check' checkbox ticked.")
|
||||
}});
|
||||
// FIXME: model should not be tied to the DOM !
|
||||
$('.create_to_check input').click();
|
||||
return $.when();
|
||||
return Promise.resolve();
|
||||
}
|
||||
_.each(values, function (value, fieldName) {
|
||||
if (fieldName === 'analytic_tag_ids') {
|
||||
@@ -682,7 +683,7 @@ var StatementModel = BasicModel.extend({
|
||||
* Update the number of validated lines
|
||||
*
|
||||
* @param {(string|string[])} handle
|
||||
* @returns {Deferred<Object>} resolved with an object who contains
|
||||
* @returns {Promise<Object>} resolved with an object who contains
|
||||
* 'handles' key
|
||||
*/
|
||||
validate: function (handle) {
|
||||
@@ -699,9 +700,11 @@ var StatementModel = BasicModel.extend({
|
||||
}
|
||||
var ids = [];
|
||||
var values = [];
|
||||
var handlesPromises = [];
|
||||
_.each(handles, function (handle) {
|
||||
var line = self.getLine(handle);
|
||||
var props = _.filter(line.reconciliation_proposition, function (prop) {return !prop.invalid;});
|
||||
var computeLinePromise;
|
||||
if (props.length === 0) {
|
||||
// Usability: if user has not choosen any lines and click validate, it has the same behavior
|
||||
// as creating a write-off of the same amount.
|
||||
@@ -710,61 +713,65 @@ var StatementModel = BasicModel.extend({
|
||||
}));
|
||||
// update balance of line otherwise it won't be to zero and another line will be added
|
||||
line.reconciliation_proposition.push(props[0]);
|
||||
self._computeLine(line);
|
||||
computeLinePromise = self._computeLine(line);
|
||||
}
|
||||
ids.push(line.id);
|
||||
var values_dict = {
|
||||
"partner_id": line.st_line.partner_id,
|
||||
"counterpart_aml_dicts": _.map(_.filter(props, function (prop) {
|
||||
return !isNaN(prop.id) && !prop.already_paid;
|
||||
}), self._formatToProcessReconciliation.bind(self, line)),
|
||||
"payment_aml_ids": _.pluck(_.filter(props, function (prop) {
|
||||
return !isNaN(prop.id) && prop.already_paid;
|
||||
}), 'id'),
|
||||
"new_aml_dicts": _.map(_.filter(props, function (prop) {
|
||||
return isNaN(prop.id) && prop.display;
|
||||
}), self._formatToProcessReconciliation.bind(self, line)),
|
||||
};
|
||||
line.reconciliation_proposition.some(function(prop) {
|
||||
if (prop.to_check) {
|
||||
values_dict['to_check'] = true;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
if (line.reconciliation_proposition[0].to_check) {
|
||||
values_dict['to_check'] = true;
|
||||
}
|
||||
|
||||
// If the lines are not fully balanced, create an unreconciled amount.
|
||||
// line.st_line.currency_id is never false here because its equivalent to
|
||||
// statement_line.currency_id or statement_line.journal_id.currency_id or statement_line.journal_id.company_id.currency_id (Python-side).
|
||||
// see: get_statement_line_for_reconciliation_widget method in account/models/account_bank_statement.py for more details
|
||||
var currency = session.get_currency(line.st_line.currency_id);
|
||||
var balance = line.balance.amount;
|
||||
if (!utils.float_is_zero(balance, currency.digits[1])) {
|
||||
var unreconciled_amount_dict = {
|
||||
'account_id': line.st_line.open_balance_account_id,
|
||||
'credit': balance > 0 ? balance : 0,
|
||||
'debit': balance < 0 ? -balance : 0,
|
||||
'name': line.st_line.name + ' : ' + _t("Open balance"),
|
||||
handlesPromises.push(Promise.resolve(computeLinePromise).then(function() {
|
||||
var values_dict = {
|
||||
"partner_id": line.st_line.partner_id,
|
||||
"counterpart_aml_dicts": _.map(_.filter(props, function (prop) {
|
||||
return !isNaN(prop.id) && !prop.already_paid;
|
||||
}), self._formatToProcessReconciliation.bind(self, line)),
|
||||
"payment_aml_ids": _.pluck(_.filter(props, function (prop) {
|
||||
return !isNaN(prop.id) && prop.already_paid;
|
||||
}), 'id'),
|
||||
"new_aml_dicts": _.map(_.filter(props, function (prop) {
|
||||
return isNaN(prop.id) && prop.display;
|
||||
}), self._formatToProcessReconciliation.bind(self, line)),
|
||||
};
|
||||
values_dict['new_aml_dicts'].push(unreconciled_amount_dict);
|
||||
}
|
||||
values.push(values_dict);
|
||||
line.reconciled = true;
|
||||
self.valuenow++;
|
||||
line.reconciliation_proposition.some(function(prop) {
|
||||
if (prop.to_check) {
|
||||
values_dict['to_check'] = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (line.reconciliation_proposition[0].to_check) {
|
||||
values_dict['to_check'] = true;
|
||||
}
|
||||
|
||||
// If the lines are not fully balanced, create an unreconciled amount.
|
||||
// line.st_line.currency_id is never false here because its equivalent to
|
||||
// statement_line.currency_id or statement_line.journal_id.currency_id or statement_line.journal_id.company_id.currency_id (Python-side).
|
||||
// see: get_statement_line_for_reconciliation_widget method in account/models/account_bank_statement.py for more details
|
||||
var currency = session.get_currency(line.st_line.currency_id);
|
||||
var balance = line.balance.amount;
|
||||
if (!utils.float_is_zero(balance, currency.digits[1])) {
|
||||
var unreconciled_amount_dict = {
|
||||
'account_id': line.st_line.open_balance_account_id,
|
||||
'credit': balance > 0 ? balance : 0,
|
||||
'debit': balance < 0 ? -balance : 0,
|
||||
'name': line.st_line.name + ' : ' + _t("Open balance"),
|
||||
};
|
||||
values_dict['new_aml_dicts'].push(unreconciled_amount_dict);
|
||||
}
|
||||
values.push(values_dict);
|
||||
line.reconciled = true;
|
||||
self.valuenow++;
|
||||
}));
|
||||
});
|
||||
|
||||
return this._rpc({
|
||||
model: 'account.reconciliation.widget',
|
||||
method: 'process_bank_statement_line',
|
||||
args: [ids, values],
|
||||
context: self.context,
|
||||
})
|
||||
.then(this._validatePostProcess.bind(this))
|
||||
.then(function () {
|
||||
return {handles: handles};
|
||||
});
|
||||
return Promise.all(handlesPromises).then(function() {
|
||||
return self._rpc({
|
||||
model: 'account.reconciliation.widget',
|
||||
method: 'process_bank_statement_line',
|
||||
args: [ids, values],
|
||||
context: self.context,
|
||||
})
|
||||
.then(self._validatePostProcess.bind(self))
|
||||
.then(function () {
|
||||
return {handles: handles};
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -779,10 +786,6 @@ var StatementModel = BasicModel.extend({
|
||||
* @param {Object} prop
|
||||
*/
|
||||
_addProposition: function (line, prop) {
|
||||
function checkAccountType (r) {
|
||||
return !isNaN(r.id) && r.account_type !== prop.account_type;
|
||||
}
|
||||
|
||||
line.reconciliation_proposition.push(prop);
|
||||
},
|
||||
/**
|
||||
@@ -793,7 +796,7 @@ var StatementModel = BasicModel.extend({
|
||||
*
|
||||
* @private
|
||||
* @param {string} handle
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_blurProposition: function (handle) {
|
||||
var line = this.getLine(handle);
|
||||
@@ -811,7 +814,7 @@ var StatementModel = BasicModel.extend({
|
||||
* @private
|
||||
* @param {string} handle
|
||||
* @param {integer} partner_id
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_changePartner: function (handle, partner_id) {
|
||||
var self = this;
|
||||
@@ -833,7 +836,7 @@ var StatementModel = BasicModel.extend({
|
||||
*
|
||||
* @private
|
||||
* @param {Object} line
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_computeLine: function (line) {
|
||||
//balance_type
|
||||
@@ -886,7 +889,7 @@ var StatementModel = BasicModel.extend({
|
||||
'__focus': false
|
||||
});
|
||||
|
||||
prop.tax_exigible = tax.tax_exigibility === 'on_payment' ? true : undefined
|
||||
prop.tax_exigible = tax.tax_exigibility === 'on_payment' ? true : undefined;
|
||||
prop.amount = tax.base;
|
||||
prop.amount_str = field_utils.format.monetary(Math.abs(prop.amount), {}, formatOptions);
|
||||
prop.invalid = !self._isValid(prop);
|
||||
@@ -904,7 +907,7 @@ var StatementModel = BasicModel.extend({
|
||||
}
|
||||
});
|
||||
|
||||
return $.when.apply($, tax_defs).then(function () {
|
||||
return Promise.all(tax_defs).then(function () {
|
||||
_.each(reconciliation_proposition, function (prop) {
|
||||
prop.__tax_to_recompute = false;
|
||||
});
|
||||
@@ -946,7 +949,7 @@ var StatementModel = BasicModel.extend({
|
||||
});
|
||||
},
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @param {string} handle
|
||||
@@ -1004,7 +1007,7 @@ var StatementModel = BasicModel.extend({
|
||||
*
|
||||
* @private
|
||||
* @param {Object[]} lines
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_formatLine: function (lines) {
|
||||
var self = this;
|
||||
@@ -1028,7 +1031,7 @@ var StatementModel = BasicModel.extend({
|
||||
if(!line.st_line.partner_id && line.reconciliation_proposition.length > 0){
|
||||
var hasDifferentPartners = function(prop){
|
||||
return !prop.partner_id || prop.partner_id != line.reconciliation_proposition[0].partner_id;
|
||||
}
|
||||
};
|
||||
|
||||
if(!_.any(line.reconciliation_proposition, hasDifferentPartners)){
|
||||
return self.changePartner(line.handle, {
|
||||
@@ -1059,7 +1062,7 @@ var StatementModel = BasicModel.extend({
|
||||
})
|
||||
);
|
||||
});
|
||||
return $.when.apply($, defs);
|
||||
return Promise.all(defs);
|
||||
},
|
||||
/**
|
||||
* Format the server value then compute the line
|
||||
@@ -1069,7 +1072,7 @@ var StatementModel = BasicModel.extend({
|
||||
* @private
|
||||
* @param {string} handle
|
||||
* @param {Object[]} mv_lines
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_formatMoveLine: function (handle, mv_lines) {
|
||||
var self = this;
|
||||
@@ -1170,7 +1173,7 @@ var StatementModel = BasicModel.extend({
|
||||
if (parseInt(prop['id'])) {
|
||||
excludedIds.push(prop['id']);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
return excludedIds;
|
||||
@@ -1202,7 +1205,7 @@ var StatementModel = BasicModel.extend({
|
||||
*
|
||||
* @private
|
||||
* @param {string} handle
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_performMoveLine: function (handle) {
|
||||
var line = this.getLine(handle);
|
||||
@@ -1263,7 +1266,7 @@ var StatementModel = BasicModel.extend({
|
||||
if (prop.analytic_account_id) result.analytic_account_id = prop.analytic_account_id.id;
|
||||
if (prop.tax_id && !prop.is_tax) result.tax_ids = [[4, prop.tax_id.id, null]];
|
||||
if (prop.tax_id && prop.is_tax) result.tax_line_id = prop.tax_id.id;
|
||||
if (prop.reconcileModelId) result.reconcile_model_id = prop.reconcileModelId
|
||||
if (prop.reconcileModelId) result.reconcile_model_id = prop.reconcileModelId;
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
@@ -1275,7 +1278,7 @@ var StatementModel = BasicModel.extend({
|
||||
* @returns {Deferred}
|
||||
*/
|
||||
_validatePostProcess: function (data) {
|
||||
return $.when();
|
||||
return Promise.resolve();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1312,7 +1315,7 @@ var ManualModel = StatementModel.extend({
|
||||
* @param {integer[]} [context.company_ids]
|
||||
* @param {integer[]} [context.partner_ids] used for 'customers' and
|
||||
* 'suppliers' mode
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
load: function (context) {
|
||||
var self = this;
|
||||
@@ -1335,7 +1338,7 @@ var ManualModel = StatementModel.extend({
|
||||
});
|
||||
|
||||
var domainReconcile = [];
|
||||
var company_ids = context && context.company_ids || [session.company_id]
|
||||
var company_ids = context && context.company_ids || [session.company_id];
|
||||
if (company_ids) {
|
||||
domainReconcile.push(['company_id', 'in', company_ids]);
|
||||
}
|
||||
@@ -1350,7 +1353,7 @@ var ManualModel = StatementModel.extend({
|
||||
|
||||
var def_taxes = this._loadTaxes();
|
||||
|
||||
return $.when(def_reconcileModel, def_account, def_taxes).then(function () {
|
||||
return Promise.all([def_reconcileModel, def_account, def_taxes]).then(function () {
|
||||
switch(context.mode) {
|
||||
case 'customers':
|
||||
case 'suppliers':
|
||||
@@ -1399,7 +1402,7 @@ var ManualModel = StatementModel.extend({
|
||||
})
|
||||
.then(function (result) {
|
||||
// Flatten the result
|
||||
self.manualLines = [].concat(result.accounts, result.customers, result.suppliers)
|
||||
self.manualLines = [].concat(result.accounts, result.customers, result.suppliers);
|
||||
self.valuenow = 0;
|
||||
self.valuemax = Object.keys(self.manualLines).length;
|
||||
var lines = self.manualLines.splice(0, self.defaultDisplayQty);
|
||||
@@ -1413,7 +1416,7 @@ var ManualModel = StatementModel.extend({
|
||||
* Load more partners/accounts
|
||||
*
|
||||
* @param {integer} qty quantity to load
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
loadMore: function(qty) {
|
||||
if (qty === undefined) {
|
||||
@@ -1427,22 +1430,22 @@ var ManualModel = StatementModel.extend({
|
||||
* Method to load informations on lines
|
||||
*
|
||||
* @param {Array} lines manualLines to load
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
loadData: function(lines) {
|
||||
var self = this;
|
||||
var defs = [];
|
||||
_.each(lines, function (l) {
|
||||
defs.push(self._formatLine(l.mode, l))
|
||||
defs.push(self._formatLine(l.mode, l));
|
||||
});
|
||||
return $.when.apply($, defs);
|
||||
return Promise.all(defs);
|
||||
|
||||
},
|
||||
/**
|
||||
* Mark the account or the partner as reconciled
|
||||
*
|
||||
* @param {(string|string[])} handle
|
||||
* @returns {Deferred<Array>} resolved with the handle array
|
||||
* @returns {Promise<Array>} resolved with the handle array
|
||||
*/
|
||||
validate: function (handle) {
|
||||
var self = this;
|
||||
@@ -1457,7 +1460,7 @@ var ManualModel = StatementModel.extend({
|
||||
});
|
||||
}
|
||||
|
||||
var def = $.when();
|
||||
var def = Promise.resolve();
|
||||
var process_reconciliations = [];
|
||||
var reconciled = [];
|
||||
_.each(handles, function (handle) {
|
||||
@@ -1520,7 +1523,7 @@ var ManualModel = StatementModel.extend({
|
||||
}
|
||||
}));
|
||||
});
|
||||
return $.when.apply($, defs).then(function() {
|
||||
return Promise.all(defs).then(function () {
|
||||
if (partner_ids.length) {
|
||||
self._rpc({
|
||||
model: 'res.partner',
|
||||
@@ -1539,11 +1542,11 @@ var ManualModel = StatementModel.extend({
|
||||
|
||||
/**
|
||||
* override change the balance type to display or not the reconcile button
|
||||
*
|
||||
*
|
||||
* @override
|
||||
* @private
|
||||
* @param {Object} line
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_computeLine: function (line) {
|
||||
return this._super(line).then(function () {
|
||||
@@ -1568,7 +1571,7 @@ var ManualModel = StatementModel.extend({
|
||||
* @private
|
||||
* @param {'customers' | 'suppliers' | 'accounts'} type
|
||||
* @param {Object} data
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_formatLine: function (type, data) {
|
||||
var line = this.lines[_.uniqueId('rline')] = _.extend(data, {
|
||||
@@ -1591,7 +1594,7 @@ var ManualModel = StatementModel.extend({
|
||||
},
|
||||
/**
|
||||
* override to add journal_id
|
||||
*
|
||||
*
|
||||
* @override
|
||||
* @private
|
||||
* @param {Object} line
|
||||
@@ -1619,12 +1622,11 @@ var ManualModel = StatementModel.extend({
|
||||
* @returns {Object}
|
||||
*/
|
||||
_formatQuickCreate: function (line, values) {
|
||||
var self = this;
|
||||
// Add journal to created line
|
||||
if (values && values.journal_id === undefined && line && line.createForm && line.createForm.journal_id) {
|
||||
values.journal_id = line.createForm.journal_id;
|
||||
}
|
||||
return this._super(line, values)
|
||||
return this._super(line, values);
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
@@ -1650,7 +1652,7 @@ var ManualModel = StatementModel.extend({
|
||||
* @override
|
||||
* @private
|
||||
* @param {string} handle
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_performMoveLine: function (handle) {
|
||||
var line = this.getLine(handle);
|
||||
@@ -1675,7 +1677,7 @@ var ManualModel = StatementModel.extend({
|
||||
})
|
||||
.then(this._formatMoveLine.bind(this, handle));
|
||||
},
|
||||
|
||||
|
||||
_formatToProcessReconciliation: function (line, prop) {
|
||||
var result = this._super(line, prop);
|
||||
result['date'] = prop.date;
|
||||
|
||||
@@ -69,7 +69,7 @@ var StatementRenderer = Widget.extend(FieldManagerMixin, {
|
||||
if (this.model.context && this.model.context.args && this.model.context.args.search) {
|
||||
this.$('.reconciliation_search_input').val(self.model.context.args.search);
|
||||
}
|
||||
return $.when.apply($, defs);
|
||||
return Promise.all(defs);
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
@@ -322,7 +322,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
|
||||
'toggle': 'popover'
|
||||
});
|
||||
var def2 = this._super.apply(this, arguments);
|
||||
return $.when(def1, def2);
|
||||
return Promise.all([def1, def2]);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -419,41 +419,44 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
|
||||
|
||||
// create form
|
||||
if (state.createForm) {
|
||||
var createPromise;
|
||||
if (!this.fields.account_id) {
|
||||
this._renderCreate(state);
|
||||
createPromise = this._renderCreate(state);
|
||||
}
|
||||
var data = this.model.get(this.handleCreateRecord).data;
|
||||
this.model.notifyChanges(this.handleCreateRecord, state.createForm).then(function () {
|
||||
// FIXME can't it directly written REPLACE_WITH ids=state.createForm.analytic_tag_ids
|
||||
self.model.notifyChanges(self.handleCreateRecord, {analytic_tag_ids: {operation: 'REPLACE_WITH', ids: []}}).then(function (){
|
||||
var defs = [];
|
||||
_.each(state.createForm.analytic_tag_ids, function (tag) {
|
||||
defs.push(self.model.notifyChanges(self.handleCreateRecord, {analytic_tag_ids: {operation: 'ADD_M2M', ids: tag}}));
|
||||
});
|
||||
$.when.apply($, defs).then(function () {
|
||||
var record = self.model.get(self.handleCreateRecord);
|
||||
_.each(self.fields, function (field, fieldName) {
|
||||
if (self._avoidFieldUpdate[fieldName]) return;
|
||||
if (fieldName === "partner_id") return;
|
||||
if ((data[fieldName] || state.createForm[fieldName]) && !_.isEqual(state.createForm[fieldName], data[fieldName])) {
|
||||
field.reset(record);
|
||||
}
|
||||
if (fieldName === 'tax_id') {
|
||||
if (!state.createForm[fieldName] || state.createForm[fieldName].amount_type === "group") {
|
||||
$('.create_force_tax_included').addClass('d-none');
|
||||
Promise.resolve(createPromise).then(function(){
|
||||
var data = self.model.get(self.handleCreateRecord).data;
|
||||
self.model.notifyChanges(self.handleCreateRecord, state.createForm).then(function () {
|
||||
// FIXME can't it directly written REPLACE_WITH ids=state.createForm.analytic_tag_ids
|
||||
self.model.notifyChanges(self.handleCreateRecord, {analytic_tag_ids: {operation: 'REPLACE_WITH', ids: []}}).then(function (){
|
||||
var defs = [];
|
||||
_.each(state.createForm.analytic_tag_ids, function (tag) {
|
||||
defs.push(self.model.notifyChanges(self.handleCreateRecord, {analytic_tag_ids: {operation: 'ADD_M2M', ids: tag}}));
|
||||
});
|
||||
Promise.all(defs).then(function () {
|
||||
var record = self.model.get(self.handleCreateRecord);
|
||||
_.each(self.fields, function (field, fieldName) {
|
||||
if (self._avoidFieldUpdate[fieldName]) return;
|
||||
if (fieldName === "partner_id") return;
|
||||
if ((data[fieldName] || state.createForm[fieldName]) && !_.isEqual(state.createForm[fieldName], data[fieldName])) {
|
||||
field.reset(record);
|
||||
}
|
||||
else {
|
||||
$('.create_force_tax_included').removeClass('d-none');
|
||||
if (fieldName === 'tax_id') {
|
||||
if (!state.createForm[fieldName] || state.createForm[fieldName].amount_type === "group") {
|
||||
$('.create_force_tax_included').addClass('d-none');
|
||||
}
|
||||
else {
|
||||
$('.create_force_tax_included').removeClass('d-none');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
if(state.createForm.tax_id){
|
||||
// Set the 'Tax Include' field editable or not depending of the 'price_include' value.
|
||||
self.$('.create_force_tax_included input').attr('disabled', state.createForm.tax_id.price_include);
|
||||
}
|
||||
});
|
||||
if(state.createForm.tax_id){
|
||||
// Set the 'Tax Include' field editable or not depending of the 'price_include' value.
|
||||
this.$('.create_force_tax_included input').attr('disabled', state.createForm.tax_id.price_include);
|
||||
}
|
||||
}
|
||||
this.$('.create .add_line').toggle(!!state.balance.amount_currency);
|
||||
},
|
||||
@@ -511,10 +514,11 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
|
||||
*
|
||||
* @private
|
||||
* @param {object} state - statement line
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_renderCreate: function (state) {
|
||||
var self = this;
|
||||
this.model.makeRecord('account.bank.statement.line', [{
|
||||
return this.model.makeRecord('account.bank.statement.line', [{
|
||||
relation: 'account.account',
|
||||
type: 'many2one',
|
||||
name: 'account_id',
|
||||
@@ -583,7 +587,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
|
||||
|
||||
self.fields.amount = new basic_fields.FieldFloat(self,
|
||||
'amount', record, {mode: 'edit'});
|
||||
|
||||
|
||||
self.fields.date = new basic_fields.FieldDate(self,
|
||||
'date', record, {mode: 'edit'});
|
||||
|
||||
@@ -597,13 +601,13 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
|
||||
self.fields.tax_id.appendTo($create.find('.create_tax_id .o_td_field'));
|
||||
self.fields.analytic_account_id.appendTo($create.find('.create_analytic_account_id .o_td_field'));
|
||||
self.fields.analytic_tag_ids.appendTo($create.find('.create_analytic_tag_ids .o_td_field'));
|
||||
self.fields.force_tax_included.appendTo($create.find('.create_force_tax_included .o_td_field'))
|
||||
self.fields.force_tax_included.appendTo($create.find('.create_force_tax_included .o_td_field'));
|
||||
self.fields.label.appendTo($create.find('.create_label .o_td_field'))
|
||||
.then(addRequiredStyle.bind(self, self.fields.label));
|
||||
self.fields.amount.appendTo($create.find('.create_amount .o_td_field'))
|
||||
.then(addRequiredStyle.bind(self, self.fields.amount));
|
||||
self.fields.date.appendTo($create.find('.create_date .o_td_field'))
|
||||
self.fields.to_check.appendTo($create.find('.create_to_check .o_td_field'))
|
||||
self.fields.date.appendTo($create.find('.create_date .o_td_field'));
|
||||
self.fields.to_check.appendTo($create.find('.create_to_check .o_td_field'));
|
||||
self.$('.create').append($create);
|
||||
|
||||
function addRequiredStyle(widget) {
|
||||
@@ -628,7 +632,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
|
||||
res_model: 'account.reconcile.model',
|
||||
views: [[false, 'form']],
|
||||
target: 'current'
|
||||
},
|
||||
},
|
||||
{
|
||||
on_reverse_breadcrumb: function() {self.trigger_up('reload');},
|
||||
});
|
||||
@@ -836,11 +840,11 @@ var ManualLineRenderer = LineRenderer.extend({
|
||||
* @override
|
||||
* @param {string} handle
|
||||
* @param {number} proposition id (move line id)
|
||||
* @returns {Deferred}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeProposition: function (handle, id) {
|
||||
if (!id) {
|
||||
return $.when();
|
||||
return Promise.resolve();
|
||||
}
|
||||
return this._super(handle, id);
|
||||
},
|
||||
@@ -879,7 +883,7 @@ var ManualLineRenderer = LineRenderer.extend({
|
||||
defs.push(def);
|
||||
}
|
||||
|
||||
return $.when.apply($, defs).then(function () {
|
||||
return Promise.all(defs).then(function () {
|
||||
if (!self.fields.title_account_id) {
|
||||
return self.fields.partner_id.prependTo(self.$('.accounting_view thead td:eq(1) span:first'));
|
||||
} else {
|
||||
@@ -909,10 +913,11 @@ var ManualLineRenderer = LineRenderer.extend({
|
||||
* @override
|
||||
*/
|
||||
_renderCreate: function (state) {
|
||||
this._super(state);
|
||||
var parentPromise = this._super(state);
|
||||
this.$('.create .create_journal_id').show();
|
||||
this.$('.create .create_date').removeClass('d-none')
|
||||
this.$('.create .create_date').removeClass('d-none');
|
||||
this.$('.create .create_journal_id .o_input').addClass('o_required_modifier');
|
||||
return parentPromise;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@@ -25,10 +25,10 @@ QUnit.module('account', {
|
||||
}, function () {
|
||||
QUnit.module('Reconciliation');
|
||||
|
||||
QUnit.test('Reconciliation form field', function (assert) {
|
||||
QUnit.test('Reconciliation form field', async function (assert) {
|
||||
assert.expect(5);
|
||||
|
||||
var form = createView({
|
||||
var form = await createView({
|
||||
View: FormView,
|
||||
model: 'account.invoice',
|
||||
data: this.data,
|
||||
@@ -40,11 +40,11 @@ QUnit.module('account', {
|
||||
mockRPC: function (route, args) {
|
||||
if (args.method === 'remove_move_reconcile') {
|
||||
assert.deepEqual(args.args, [22,{"invoice_id":1}], "should call remove_move_reconcile {warning: required focus}");
|
||||
return $.when();
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (args.method === 'assign_outstanding_credit') {
|
||||
assert.deepEqual(args.args, [4, 20], "should call assign_outstanding_credit {warning: required focus}");
|
||||
return $.when();
|
||||
return Promise.resolve();
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -46,9 +46,9 @@ QUnit.module('section_and_note', {
|
||||
};
|
||||
},
|
||||
}, function () {
|
||||
QUnit.test('correct display of section and note fields', function (assert) {
|
||||
QUnit.test('correct display of section and note fields', async function (assert) {
|
||||
assert.expect(4);
|
||||
var form = createView({
|
||||
var form = await createView({
|
||||
View: FormView,
|
||||
model: 'invoice',
|
||||
data: this.data,
|
||||
@@ -76,18 +76,18 @@ QUnit.module('section_and_note', {
|
||||
"should have a section class");
|
||||
|
||||
// enter edit mode
|
||||
testUtils.form.clickEdit(form);
|
||||
await testUtils.form.clickEdit(form);
|
||||
|
||||
// editing line should be textarea
|
||||
$tr0 = form.$('tr.o_data_row:eq(0)');
|
||||
testUtils.dom.click($tr0.find('td.o_data_cell'));
|
||||
assert.strictEqual($tr0.find('td.o_data_cell textarea[name="name"]').length, 1,
|
||||
await testUtils.dom.click($tr0.find('td.o_data_cell'));
|
||||
assert.containsOnce($tr0, 'td.o_data_cell textarea[name="name"]',
|
||||
"editing line should be textarea");
|
||||
|
||||
// editing section should be input
|
||||
$tr1 = form.$('tr.o_data_row:eq(1)');
|
||||
testUtils.dom.click($tr1.find('td.o_data_cell'));
|
||||
assert.strictEqual($tr1.find('td.o_data_cell input[name="name"]').length, 1,
|
||||
await testUtils.dom.click($tr1.find('td.o_data_cell'));
|
||||
assert.containsOnce($tr1, 'td.o_data_cell input[name="name"]',
|
||||
"editing section should be input");
|
||||
|
||||
form.destroy();
|
||||
|
||||
Reference in New Issue
Block a user