[FIX] account: Incorrect due date for credit notes

Fine tuning of this commit: d0f3e896d4

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) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2019-07-22 12:02:55 +00:00
parent 9b921dae5e
commit b6e7af37eb
+4 -2
View File
@@ -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