From 23deeb187d358d66a87f024c495de06575d82967 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 10 Jan 2017 15:08:18 +0100 Subject: [PATCH 1/2] [FIX] account_check_printing: remove useless sudo This sudo is useless, and prevent the use of the record rules on the creation of payments. opw-703143 --- addons/account_check_printing/account_payment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_check_printing/account_payment.py b/addons/account_check_printing/account_payment.py index 68850f7c206..23742fc73d0 100644 --- a/addons/account_check_printing/account_payment.py +++ b/addons/account_check_printing/account_payment.py @@ -86,7 +86,7 @@ class account_payment(models.Model): and vals.get('check_manual_sequencing'): sequence = self.env['account.journal'].browse(vals['journal_id']).check_sequence_id vals.update({'check_number': sequence.next_by_id()}) - return super(account_payment, self.sudo()).create(vals) + return super(account_payment, self).create(vals) @api.multi def print_checks(self): From fc813847d8cf3242a0202cff813c3466cd0a5e1f Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 10 Jan 2017 16:43:50 +0100 Subject: [PATCH 2/2] [FIX] account: wrong counterpart in invoice / out refund register payment Revision 20935462a0cabeb45480ce70114ff2f4e91eaf79 introduces the below regression: When registering a payment on a customer invoice refund or a vendor bill, with a payment difference e.g. payment of 101 for an invoice of 100 and marking the invoice as fully paid, the counter part in the payment account move were wrongly computed: In those cases, its the payment total minus the invoice residual total that must be performed, and not the other way around. This revision solves this, inspired on how the payment difference is computed for display in the wizard on how it was before the above revision, in the method `_compute_payment_difference` Fixes #15000 --- addons/account/models/account_payment.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 486c7eba0ab..b93c23c380e 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -388,9 +388,12 @@ class account_payment(models.Model): # the writeoff debit and credit must be computed from the invoice residual in company currency # minus the payment amount in company currency, and not from the payment difference in the payment currency # to avoid loss of precision during the currency rate computations. See revision 20935462a0cabeb45480ce70114ff2f4e91eaf79 for a detailed example. - total_residual_company_signed = sum(invoice.residual_company_signed for invoice in self.invoice_ids) + total_residual_company_signed = self._compute_total_invoices_amount() total_payment_company_signed = self.currency_id.with_context(date=self.payment_date).compute(self.amount, self.company_id.currency_id) - amount_wo = total_residual_company_signed - total_payment_company_signed + if self.invoice_ids[0].type in ['in_invoice', 'out_refund']: + amount_wo = total_payment_company_signed - total_residual_company_signed + else: + amount_wo = total_residual_company_signed - total_payment_company_signed debit_wo = amount_wo > 0 and amount_wo or 0.0 credit_wo = amount_wo < 0 and -amount_wo or 0.0 writeoff_line['name'] = _('Counterpart')