Set only once date when computing purchase and sale prices

This commit is contained in:
Cédric Krier committed 2023-08-17 16:13:40 +02:00
1 parent 4deaaf59a2
commit 4430198462
2 files changed
+2 -4

No files matched your search

+1 -2
View File
@@ -164,7 +164,6 @@ class Product(metaclass=PoolMeta):
ProductSupplier = pool.get('purchase.product_supplier')
ProductSupplierPrice = pool.get('purchase.product_supplier.price')
today = Date.today()
context = Transaction().context
prices = {}
@@ -179,6 +178,7 @@ class Product(metaclass=PoolMeta):
currency = Currency(context['currency'])
elif context.get('company'):
currency = Company(context['company']).currency
date = context.get('purchase_date') or Date.today()
for product in products:
unit_price = product._get_purchase_unit_price(quantity=quantity)
@@ -205,7 +205,6 @@ class Product(metaclass=PoolMeta):
unit_price = Uom.compute_price(
default_uom, unit_price, product_uom)
if currency and default_currency and unit_price is not None:
date = context.get('purchase_date') or today
with Transaction().set_context(date=date):
unit_price = Currency.compute(
default_currency, unit_price, currency, round=False)
+1 -2
View File
@@ -150,7 +150,6 @@ class Product(metaclass=PoolMeta):
Currency = pool.get('currency.currency')
Date = pool.get('ir.date')
today = Date.today()
context = Transaction().context
prices = {}
@@ -166,6 +165,7 @@ class Product(metaclass=PoolMeta):
company = None
if context.get('company'):
company = Company(context['company'])
date = context.get('sale_date') or Date.today()
for product in products:
unit_price = product._get_sale_unit_price(quantity=quantity)
@@ -178,7 +178,6 @@ class Product(metaclass=PoolMeta):
product.default_uom, unit_price, product.sale_uom)
if currency and company and unit_price is not None:
if company.currency != currency:
date = Transaction().context.get('sale_date') or today
with Transaction().set_context(date=date):
unit_price = Currency.compute(
company.currency, unit_price,