From dfda8b010ba8f20ea4fbc730eebd9c23d163c85a Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 23 Jul 2020 07:32:58 +0000 Subject: [PATCH] [FIX] sale_stock: Printing an invoice When printing an invoice with one of its line without write_date, a traceback was raised. opw:2301363 closes odoo/odoo#54856 X-original-commit: 765e3d526890f1babd85ec3a68aa322f61ab9d10 Signed-off-by: Simon Goffin (sig) Co-authored-by: odoo-crm --- addons/sale_stock/models/account_move.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/sale_stock/models/account_move.py b/addons/sale_stock/models/account_move.py index a3632af2049..233e4882b98 100644 --- a/addons/sale_stock/models/account_move.py +++ b/addons/sale_stock/models/account_move.py @@ -51,9 +51,10 @@ class AccountMove(models.Model): last_invoice = previous_invoices[-1] if len(previous_invoices) else None # Get the incoming and outgoing sml between self.invoice_date and the previous invoice (if any). - self_datetime = max(self.invoice_line_ids.mapped('write_date')) if self.invoice_line_ids else None - last_invoice_datetime = max(last_invoice.invoice_line_ids.mapped('write_date')) if last_invoice else None - + write_dates = [wd for wd in self.invoice_line_ids.mapped('write_date') if wd] + self_datetime = max(write_dates) if write_dates else None + last_write_dates = last_invoice and [wd for wd in last_invoice.invoice_line_ids.mapped('write_date') if wd] + last_invoice_datetime = max(last_write_dates) if last_write_dates else None def _filter_incoming_sml(ml): if ml.state == 'done' and ml.location_id.usage == 'customer' and ml.lot_id: if last_invoice_datetime: