[FIX] account: no payment terms on refund

In the case where:
create an invoice with payment terms that contains at least 2 term lines
Validate
create a refund by clicking cancel and reconcile

Before this commit, the refund move lines were wrongly created and reconciled with the invoice's move lines

After this commit, since payment terms are irrelevant on refunds, we set it to false and the problem doesn't raise

OPW 804752
This commit is contained in:
Lucas Perais (lpe)
2018-01-24 16:41:42 +01:00
parent adad192cc0
commit d29c2dbbdd
+3 -1
View File
@@ -985,6 +985,7 @@ class AccountInvoice(models.Model):
values['state'] = 'draft'
values['number'] = False
values['origin'] = invoice.number
values['payment_term_id'] = False
if date:
values['date'] = date
@@ -1365,6 +1366,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'])
@@ -1373,7 +1375,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':