[FIX] account: dates can be datetime.date or strings

Open the customers followup report
on a line, click on its contextual menu (the down arrow next to invoice name)
click change expected payment date

Before this commit, there was a traceback, because the new date was a string
which has no strftime function

from 03c40e3104 we learn that it can
either be a string or a date object, as Odoo in v12.0 supports this

After this commit, there is no traceback

OPW 1933953
OPW 1933979

closes odoo/odoo#30756
This commit is contained in:
Lucas Perais (lpe)
2019-02-01 09:12:42 +00:00
parent 3076d7e464
commit 7e06f1a8ed
+4 -1
View File
@@ -1124,7 +1124,10 @@ class AccountMoveLine(models.Model):
self._update_check()
#when we set the expected payment date, log a note on the invoice_id related (if any)
if vals.get('expected_pay_date') and self.invoice_id:
msg = _('New expected payment date: ') + fields.Date.to_string(vals['expected_pay_date']) + '.\n' + vals.get('internal_note', '')
str_expected_pay_date = vals['expected_pay_date']
if isinstance(str_expected_pay_date, date):
str_expected_pay_date = fields.Date.to_string(str_expected_pay_date)
msg = _('New expected payment date: ') + str_expected_pay_date + '.\n' + vals.get('internal_note', '')
self.invoice_id.message_post(body=msg) #TODO: check it is an internal note (not a regular email)!
#when making a reconciliation on an existing liquidity journal item, mark the payment as reconciled
for record in self: