diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 0c24a6e2844..d4637bad007 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: @@ -324,8 +330,12 @@ class AccountInvoice(models.Model): store=True, readonly=True, compute='_compute_amount', track_visibility='always') 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', @@ -1751,14 +1761,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 672aa72afdd..983bd9014ea 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -985,7 +985,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 539e9b64a8f..2248020d5e7 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -831,3 +831,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 7455ef8a325..84a023b6dd9 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -275,6 +275,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { 'field_changed': '_onFieldChanged', }), _avoidFieldUpdate: {}, + MV_LINE_DEBOUNCE: 200, /** * create partner_id field in editable mode @@ -287,6 +288,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 b8200c149d9..ffd59877fe6 100644 --- a/addons/account/static/tests/reconciliation_tests.js +++ b/addons/account/static/tests/reconciliation_tests.js @@ -584,6 +584,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'); @@ -591,7 +592,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 cb6c3ea93da..40886710ced 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -163,8 +163,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 @@ -