diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2018-01-22 16:19:23 +0100 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2018-01-24 16:41:42 +0100 |
| commit | d29c2dbbddb2e7407e714b0bb11ffdf6fa317672 (patch) | |
| tree | bf25bcc0cfaf6bc358a527d32d284d18e2ccc12d /addons | |
| parent | adad192cc0018ce6838feb2a954044ee0b623841 (diff) | |
[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
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/models/account_invoice.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 5b09af3be43..f653941e7b6 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -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': |
