From b6e7af37eb93e08f3bf049bd6eb0c52c13e7b4e8 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 22 Jul 2019 09:56:02 +0000 Subject: [PATCH] [FIX] account: Incorrect due date for credit notes Fine tuning of this commit: d0f3e896d4d29e60e818b806599421be557556cc To ensure that the date_invoice is a date object because a comparison is made with date_due opw:2033438 closes odoo/odoo#35058 Signed-off-by: Simon Goffin (sig) --- addons/account/models/account_invoice.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index a94180f3b04..14075ff0c0d 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1504,8 +1504,10 @@ 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'] + if values.get('date_due', False) and values['date_invoice']: + # To ensure that the date_invoice is a date object + if self._fields['date_invoice'].to_date(values['date_invoice']) > values['date_due']: + values['date_due'] = values['date_invoice'] values['state'] = 'draft' values['number'] = False values['origin'] = invoice.number