diff options
| author | Goffin Simon <sig@odoo.com> | 2020-07-23 07:32:58 +0000 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2020-07-23 15:02:08 +0000 |
| commit | dfda8b010ba8f20ea4fbc730eebd9c23d163c85a (patch) | |
| tree | ff1bd9d281f0d69e37605d4b572d6e26f891c8c6 | |
| parent | 40861fc1ef43796398a13a1fd78918d3ee66607b (diff) | |
[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) <sig@openerp.com>
Co-authored-by: odoo-crm <crm@odoo.com>
| -rw-r--r-- | addons/sale_stock/models/account_move.py | 7 |
1 files 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: |
