[MERGE] forward port branch 9.0 up to d29c2dbbdd

This commit is contained in:
Christophe Simonis
2018-01-24 17:22:44 +01:00
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -1071,6 +1071,7 @@ class AccountInvoice(models.Model):
values['state'] = 'draft'
values['number'] = False
values['origin'] = invoice.number
values['payment_term_id'] = False
values['refund_invoice_id'] = invoice.id
if date:
@@ -1458,6 +1459,7 @@ class AccountPaymentTerm(models.Model):
def compute(self, value, date_ref=False):
date_ref = date_ref or fields.Date.today()
amount = value
sign = value < 0 and -1 or 1
result = []
if self.env.context.get('currency_id'):
currency = self.env['res.currency'].browse(self.env.context['currency_id'])
@@ -1466,7 +1468,7 @@ class AccountPaymentTerm(models.Model):
prec = currency.decimal_places
for line in self.line_ids:
if line.value == 'fixed':
amt = round(line.value_amount, prec)
amt = sign * round(line.value_amount, prec)
elif line.value == 'percent':
amt = round(value * (line.value_amount / 100.0), prec)
elif line.value == 'balance':
+1 -1
View File
@@ -803,7 +803,7 @@ class AccountMoveLine(models.Model):
elif self._context.get('skip_full_reconcile_check') == 'amount_currency_only':
field = 'amount_residual_currency'
#target the pair of move in self that are the oldest
sorted_moves = sorted(self, key=lambda a: a.date)
sorted_moves = sorted(self, key=lambda a: a.date_maturity or a.date)
debit = credit = False
for aml in sorted_moves:
if credit and debit: