[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) <vfe@odoo.com>
Signed-off-by: Smit Nagar (smna) <smna@odoo.com>
This commit is contained in:
smna-odoo
2023-06-19 16:40:07 +02:00
parent 56227b9049
commit b3baa64adb
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -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
+1 -1
View File
@@ -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',