From b3baa64adb8dd9e7b8a4e6acb3a817cc2bb0d78b Mon Sep 17 00:00:00 2001 From: smna-odoo Date: Mon, 5 Jun 2023 07:24:00 +0000 Subject: [PATCH] [FIX] sale: prevent traceback while add new product in sale order line An error occurs because to convert the amount in sale order line company is required. when user remove the company and tries to add a new product in sale order line error occur. applying these changes will resolve this issue. sentry-4090085761 closes odoo/odoo#125575 X-original-commit: c04bc8026eae79c01fb9315d8063b12d3a1e2fa8 Signed-off-by: Victor Feyens (vfe) Signed-off-by: Smit Nagar (smna) --- addons/account/models/product.py | 3 ++- addons/sale/models/sale_order_line.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/account/models/product.py b/addons/account/models/product.py index 5de8659a39c..9297ee2cfdd 100644 --- a/addons/account/models/product.py +++ b/addons/account/models/product.py @@ -123,7 +123,6 @@ class ProductProduct(models.Model): def _get_product_accounts(self): return self.product_tmpl_id._get_product_accounts() - @api.model def _get_tax_included_unit_price(self, company, currency, document_date, document_type, is_refund_document=False, product_uom=None, product_currency=None, product_price_unit=None, product_taxes=None, fiscal_position=None @@ -131,6 +130,8 @@ class ProductProduct(models.Model): """ Helper to get the price unit from different models. This is needed to compute the same unit price in different models (sale order, account move, etc.) with same parameters. """ + self.ensure_one() + company.ensure_one() product = self diff --git a/addons/sale/models/sale_order_line.py b/addons/sale/models/sale_order_line.py index 7769978de8c..e7a6eead58d 100644 --- a/addons/sale/models/sale_order_line.py +++ b/addons/sale/models/sale_order_line.py @@ -433,7 +433,7 @@ class SaleOrderLine(models.Model): else: price = line.with_company(line.company_id)._get_display_price() line.price_unit = line.product_id._get_tax_included_unit_price( - line.company_id, + line.company_id or line.env.company, line.order_id.currency_id, line.order_id.date_order, 'sale',