From bb712ad7017db9c6477ceb40633e2460238b3317 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 9 Jul 2019 11:47:08 +0000 Subject: [PATCH] [FIX] account: Incorrect due date for credit notes Steps to reproduce the bug: - Create an invoice I - Set the invoice date in the past and add payment terms - Validate I - Create refund from I Bug: The invoice date is set as today but the due date was set in the past. opw:2033438 closes odoo/odoo#34748 Signed-off-by: Simon Goffin (sig) --- addons/account/models/account_invoice.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 7de331f7742..48c6aa8c711 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1076,6 +1076,8 @@ class AccountInvoice(models.Model): values['type'] = TYPE2REFUND[invoice['type']] values['date_invoice'] = date_invoice or fields.Date.context_today(invoice) + if values.get('date_due', False) and values['date_invoice'] > values['date_due']: + values['date_due'] = values['date_invoice'] values['state'] = 'draft' values['number'] = False values['origin'] = invoice.number