Add module account_statement_operation_rule

This module allows to automatically apply Statement Operations (or
"presets") on the statement lines reconciliations according to rules,
for instance based on the balance.
This commit is contained in:
Guewen Baconnier
2014-11-11 11:17:27 +01:00
parent 86cf2e953a
commit 4ebb2cbc72
8 changed files with 412 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
openerp.account_statement_operation_rule = function (instance) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
instance.web.account_statement_operation_rule = instance.web.account_statement_operation_rule || {};
instance.web.account.bankStatementReconciliationLine.include({
operation_rules: function() {
var self = this;
var model_operation_rule = new instance.web.Model("account.statement.operation.rule");
model_operation_rule.call("operations_for_reconciliation",
[self.st_line.id,
_.pluck(self.get("mv_lines_selected"), 'id')])
.then(function (operations) {
_.each(operations, function(operation_id) {
preset_btn = self.$("button.preset[data-presetid='" + operation_id + "']");
preset_btn.click();
self.addLineBeingEdited();
});
});
},
render: function() {
deferred = this._super();
if (deferred) {
deferred.done(this.operation_rules());
}
return deferred;
},
restart: function() {
deferred = this._super();
deferred.done(this.operation_rules());
return deferred;
},
});
};