summaryrefslogtreecommitdiff
path: root/addons/account/static
diff options
context:
space:
mode:
authorLaurent Smet <las@odoo.com>2020-04-17 07:43:33 +0000
committerLaurent Smet <las@odoo.com>2020-06-15 08:36:04 +0000
commitbeccf82e09d536255d9d9cb9bfe58ebae2559843 (patch)
treee031e879cb607248f437acc351540324c2f27b31 /addons/account/static
parentf074772d259656a08376bd0519e5648997e700ba (diff)
[REF] account: journal items reconciliation (part 1/2)
This commits refactors the code of the reconciliation, in order to facilitate the process of complex use cases, namely multi-currencies or cash-basis-taxes related (see details below). It also prepares the code for a second refactoring where we will save on each journal items the amount_currency and currency_id field (even in case of operation made in company currency), also in the sake of simplification. 1) Multi-currencies: - the account.partial.reconcile model now will have dedicated columns to specify the amount of the partial reconciliation in the debit_line_id currency and the credit_line_id currency. That comes in handy when dealing with journal items having different secondary currencies, but also allows some simplification. - residual_amount_currency computation changed accordingly - moved models account.full.reconcile and account.partial.reconcile in their dedicated .py file 2) Cash basis taxes - cash basis entries now handle correctly rounding errors to make sure the exact amount of gets reported when the reconciliation becomes full. - the account for the base amount of cash basis entries has to be set, now, on the company instead of on each cash basis tax. - that new 'property' field can be set at the CoA installation via the field property_cash_basis_base_account_id of account.chart.template, or going through the accounting settings. Was task task: 2243420 Was PR #50308 Related: odoo/upgrade#1121 Related: odoo/enterprise#10252 Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Diffstat (limited to 'addons/account/static')
-rw-r--r--addons/account/static/src/js/account_payment_field.js26
-rw-r--r--addons/account/static/src/xml/account_payment.xml2
-rw-r--r--addons/account/static/tests/account_payment_field_tests.js9
3 files changed, 12 insertions, 25 deletions
diff --git a/addons/account/static/src/js/account_payment_field.js b/addons/account/static/src/js/account_payment_field.js
index 71ed1dfd272..fa56d1a1858 100644
--- a/addons/account/static/src/js/account_payment_field.js
+++ b/addons/account/static/src/js/account_payment_field.js
@@ -59,19 +59,7 @@ var ShowPaymentLineWidget = AbstractField.extend({
var content = info.content[v];
var options = {
content: function () {
- var $content = $(QWeb.render('PaymentPopOver', {
- name: content.name,
- journal_name: content.journal_name,
- date: content.date,
- amount: content.amount,
- currency: content.currency,
- position: content.position,
- payment_id: content.payment_id,
- payment_method_name: content.payment_method_name,
- move_id: content.move_id,
- ref: content.ref,
- account_payment_id: content.account_payment_id,
- }));
+ var $content = $(QWeb.render('PaymentPopOver', content));
var unreconcile_button = $content.filter('.js_unreconcile_payment').on('click', self._onRemoveMoveReconcile.bind(self));
$content.filter('.js_open_payment').on('click', self._onOpenPayment.bind(self));
@@ -145,13 +133,13 @@ var ShowPaymentLineWidget = AbstractField.extend({
*/
_onRemoveMoveReconcile: function (event) {
var self = this;
- var paymentId = parseInt($(event.target).attr('payment-id'));
- if (paymentId !== undefined && !isNaN(paymentId)){
+ var moveId = parseInt($(event.target).attr('move-id'));
+ var partialId = parseInt($(event.target).attr('partial-id'));
+ if (partialId !== undefined && !isNaN(partialId)){
this._rpc({
- model: 'account.move.line',
- method: 'remove_move_reconcile',
- args: [paymentId],
- context: {'move_id': this.res_id},
+ model: 'account.move',
+ method: 'js_remove_outstanding_partial',
+ args: [moveId, partialId],
}).then(function () {
self.trigger_up('reload');
});
diff --git a/addons/account/static/src/xml/account_payment.xml b/addons/account/static/src/xml/account_payment.xml
index 8d6f484cb6c..c752f838123 100644
--- a/addons/account/static/src/xml/account_payment.xml
+++ b/addons/account/static/src/xml/account_payment.xml
@@ -78,7 +78,7 @@
</tr>
</table>
</div>
- <button class="btn btn-sm btn-primary js_unreconcile_payment float-left" t-att-payment-id="payment_id" style="margin-top:5px; margin-bottom:5px;" groups="account.group_account_invoice">Unreconcile</button>
+ <button class="btn btn-sm btn-primary js_unreconcile_payment float-left" t-att-partial-id="partial_id" t-att-payment-id="payment_id" t-att-move-id="move_id" style="margin-top:5px; margin-bottom:5px;" groups="account.group_account_invoice">Unreconcile</button>
<button class="btn btn-sm btn-secondary js_open_payment float-right" t-att-payment-id="account_payment_id" t-att-move-id="move_id" style="margin-top:5px; margin-bottom:5px;">View</button>
</t>
diff --git a/addons/account/static/tests/account_payment_field_tests.js b/addons/account/static/tests/account_payment_field_tests.js
index 379f099d29c..48609728edd 100644
--- a/addons/account/static/tests/account_payment_field_tests.js
+++ b/addons/account/static/tests/account_payment_field_tests.js
@@ -16,7 +16,7 @@ QUnit.module('account', {
},
records: [{
id: 1,
- payments_widget: '{"content": [{"digits": [69, 2], "currency": "$", "amount": 555.0, "name": "Customer Payment: INV/2017/0004", "date": "2017-04-25", "position": "before", "ref": "BNK1/2017/0003 (INV/2017/0004)", "payment_id": 22, "move_id": 10, "journal_name": "Bank"}], "outstanding": false, "title": "Less Payment"}',
+ payments_widget: '{"content": [{"digits": [69, 2], "currency": "$", "amount": 555.0, "name": "Customer Payment: INV/2017/0004", "date": "2017-04-25", "position": "before", "ref": "BNK1/2017/0003 (INV/2017/0004)", "payment_id": 22, "move_id": 10, "partial_id": 38, "journal_name": "Bank"}], "outstanding": false, "title": "Less Payment"}',
outstanding_credits_debits_widget: '{"content": [{"digits": [69, 2], "currency": "$", "amount": 100.0, "journal_name": "INV/2017/0004", "position": "before", "id": 20}], "move_id": 4, "outstanding": true, "title": "Outstanding credits"}',
}]
},
@@ -26,7 +26,7 @@ QUnit.module('account', {
QUnit.module('Reconciliation');
QUnit.test('Reconciliation form field', async function (assert) {
- assert.expect(6);
+ assert.expect(5);
var form = await createView({
View: FormView,
@@ -38,9 +38,8 @@ QUnit.module('account', {
'</form>',
res_id: 1,
mockRPC: function (route, args) {
- if (args.method === 'remove_move_reconcile') {
- assert.deepEqual(args.args, [22], "should call remove_move_reconcile {warning: required focus}");
- assert.deepEqual(args.kwargs, {context: {"move_id": 1}}, "should call remove_move_reconcile {warning: required focus}");
+ if (args.method === 'js_remove_outstanding_partial') {
+ assert.deepEqual(args.args, [10, 38], "should call js_remove_outstanding_partial {warning: required focus}");
return Promise.resolve();
}
if (args.method === 'js_assign_outstanding_line') {