[MERGE] forward port branch 9.0 up to fc813847d8

This commit is contained in:
Christophe Simonis
2017-01-10 16:53:27 +01:00
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -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')
@@ -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):