diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 9a8887ebeb0..c97b1d4d314 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -70,6 +70,12 @@ class AccountInvoice(models.Model): self.amount_total_signed = self.amount_total * sign self.amount_untaxed_signed = amount_untaxed_signed * sign + def _compute_sign_taxes(self): + for invoice in self: + sign = invoice.type in ['in_refund', 'out_refund'] and -1 or 1 + invoice.amount_untaxed_invoice_signed = invoice.amount_untaxed * sign + invoice.amount_tax_signed = invoice.amount_tax * sign + @api.onchange('amount_total') def _onchange_amount_total(self): for inv in self: @@ -347,8 +353,12 @@ class AccountInvoice(models.Model): store=True, readonly=True, compute='_compute_amount', tracking=True) amount_untaxed_signed = fields.Monetary(string='Untaxed Amount in Company Currency', currency_field='company_currency_id', store=True, readonly=True, compute='_compute_amount') + amount_untaxed_invoice_signed = fields.Monetary(string='Untaxed Amount in Invoice Currency', currency_field='currency_id', + readonly=True, compute='_compute_sign_taxes') amount_tax = fields.Monetary(string='Tax', store=True, readonly=True, compute='_compute_amount') + amount_tax_signed = fields.Monetary(string='Tax in Invoice Currency', currency_field='currency_id', + readonly=True, compute='_compute_sign_taxes') amount_total = fields.Monetary(string='Total', store=True, readonly=True, compute='_compute_amount') amount_total_signed = fields.Monetary(string='Total in Invoice Currency', currency_field='currency_id', @@ -1790,14 +1800,14 @@ class AccountInvoiceLine(models.Model): def _set_taxes(self): """ Used in on_change to set taxes and price""" self.ensure_one() - if self.invoice_id.type in ('out_invoice', 'out_refund'): - taxes = self.product_id.taxes_id or self.account_id.tax_ids or self.invoice_id.company_id.account_sale_tax_id - else: - taxes = self.product_id.supplier_taxes_id or self.account_id.tax_ids or self.invoice_id.company_id.account_purchase_tax_id # Keep only taxes of the company company_id = self.company_id or self.env.user.company_id - taxes = taxes.filtered(lambda r: r.company_id == company_id) + + if self.invoice_id.type in ('out_invoice', 'out_refund'): + taxes = self.product_id.taxes_id.filtered(lambda r: r.company_id == company_id) or self.account_id.tax_ids or self.invoice_id.company_id.account_sale_tax_id + else: + taxes = self.product_id.supplier_taxes_id.filtered(lambda r: r.company_id == company_id) or self.account_id.tax_ids or self.invoice_id.company_id.account_purchase_tax_id self.invoice_line_tax_ids = fp_taxes = self.invoice_id.fiscal_position_id.map_tax(taxes, self.product_id, self.invoice_id.partner_id) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index ad7eec8c651..f230e0ff777 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1012,7 +1012,7 @@ class AccountMoveLine(models.Model): partner_id = self.env['res.partner']._find_accounting_partner(self[0].partner_id).id company_currency = self[0].account_id.company_id.currency_id - writeoff_currency = self[0].currency_id or company_currency + writeoff_currency = self[0].account_id.currency_id or company_currency line_to_reconcile = self.env['account.move.line'] # Iterate and create one writeoff by journal writeoff_moves = self.env['account.move'] diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 034cdab484d..cc9b43efb81 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -835,3 +835,17 @@ class account_payment(models.Model): }) return vals + + def _get_invoice_payment_amount(self, inv): + """ + Computes the amount covered by the current payment in the given invoice. + + :param inv: an invoice object + :returns: the amount covered by the payment in the invoice + """ + self.ensure_one() + return sum([ + data['amount'] + for data in inv._get_payments_vals() + if data['account_payment_id'] == self.id + ]) diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js index 8759a404473..9cd6bd772c0 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -277,6 +277,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { 'field_changed': '_onFieldChanged', }), _avoidFieldUpdate: {}, + MV_LINE_DEBOUNCE: 200, /** * create partner_id field in editable mode @@ -289,6 +290,11 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { this.model = model; this._initialState = state; + if (this.MV_LINE_DEBOUNCE) { + this._onSelectMoveLine = _.debounce(this._onSelectMoveLine, this.MV_LINE_DEBOUNCE, true); + } else { + this._onSelectMoveLine = this._onSelectMoveLine; + } }, /** * @override diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js index 043cd09062c..829c5cbda02 100644 --- a/addons/account/static/tests/reconciliation_tests.js +++ b/addons/account/static/tests/reconciliation_tests.js @@ -585,6 +585,7 @@ odoo.define('account.reconciliation_tests', function (require) { "use strict"; var ReconciliationClientAction = require('account.ReconciliationClientAction'); +var ReconciliationRenderer = require('account.ReconciliationRenderer'); var demoData = require('account.reconciliation_tests.data'); var testUtils = require('web.test_utils'); @@ -592,7 +593,13 @@ var testUtils = require('web.test_utils'); QUnit.module('account', { beforeEach: function () { this.params = demoData.getParams(); - } + testUtils.patch(ReconciliationRenderer.LineRenderer, { + MV_LINE_DEBOUNCE: 0, + }); + }, + afterEach: function () { + testUtils.unpatch(ReconciliationRenderer.LineRenderer); + }, }, function () { QUnit.module('Reconciliation'); diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index 42138b29f8e..433defaffdb 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -165,8 +165,8 @@ - - + + diff --git a/addons/account/views/report_payment_receipt_templates.xml b/addons/account/views/report_payment_receipt_templates.xml index 871ae39479f..c0e11a2ef7f 100644 --- a/addons/account/views/report_payment_receipt_templates.xml +++ b/addons/account/views/report_payment_receipt_templates.xml @@ -46,7 +46,7 @@ - + diff --git a/addons/account_cancel/views/account_views.xml b/addons/account_cancel/views/account_views.xml index e3dd3821294..18f308bd9c5 100644 --- a/addons/account_cancel/views/account_views.xml +++ b/addons/account_cancel/views/account_views.xml @@ -17,7 +17,7 @@ -