From 03f14189cbdce7083af226affe74d82beec5191e Mon Sep 17 00:00:00 2001 From: Wolfgang Taferner Date: Mon, 11 Jan 2021 13:33:28 +0000 Subject: [PATCH] [FIX] account/purchase: onchange on purchase create bill does not work closes odoo/odoo#64777 X-original-commit: 0f36bbd257ba5e8e03462f675d81fdbdece1893a Signed-off-by: Laurent Smet Signed-off-by: oco-odoo --- addons/account/models/account_move.py | 3 ++- addons/purchase/models/account_invoice.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 36a2bd6b3e6..4b4ad611538 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -943,7 +943,8 @@ class AccountMove(models.Model): # Recompute amls: update existing line or create new one for each payment term. new_terms_lines = self.env['account.move.line'] for date_maturity, balance, amount_currency in to_compute: - if self.journal_id.company_id.currency_id.is_zero(balance) and len(to_compute) > 1: + currency = self.journal_id.company_id.currency_id + if currency and currency.is_zero(balance) and len(to_compute) > 1: continue if existing_terms_lines_index < len(existing_terms_lines): diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index d0c30016944..314764a270d 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -15,7 +15,7 @@ class AccountMove(models.Model): states={'draft': [('readonly', False)]}, string='Purchase Order', help="Auto-complete from a past purchase order.") - + def _get_invoice_reference(self): self.ensure_one() vendor_refs = [ref for ref in set(self.line_ids.mapped('purchase_line_id.order_id.partner_ref')) if ref]