Round price returned by get_sale_price
This commit is contained in:
@@ -6,7 +6,7 @@ from sql import Null
|
||||
|
||||
from trytond.model import ModelSQL, ModelView, ValueMixin, fields
|
||||
from trytond.modules.currency.fields import Monetary
|
||||
from trytond.modules.product import price_digits
|
||||
from trytond.modules.product import price_digits, round_price
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval, TimeDelta
|
||||
from trytond.transaction import Transaction
|
||||
@@ -183,6 +183,8 @@ class Product(metaclass=PoolMeta):
|
||||
unit_price = Currency.compute(
|
||||
company.currency, unit_price,
|
||||
currency, round=False)
|
||||
if unit_price is not None:
|
||||
unit_price = round_price(unit_price)
|
||||
prices[product.id] = unit_price
|
||||
return prices
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ from trytond.modules.company import CompanyReport
|
||||
from trytond.modules.company.model import (
|
||||
employee_field, reset_employee, set_employee)
|
||||
from trytond.modules.currency.fields import Monetary
|
||||
from trytond.modules.product import price_digits, round_price
|
||||
from trytond.modules.product import price_digits
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Bool, Eval, If, PYSONEncoder
|
||||
from trytond.tools import firstline, sortable_values
|
||||
@@ -1522,11 +1522,8 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView):
|
||||
|
||||
with Transaction().set_context(
|
||||
self._get_context_sale_price()):
|
||||
unit_price = Product.get_sale_price([self.product],
|
||||
abs(self.quantity or 0))[self.product.id]
|
||||
if unit_price is not None:
|
||||
unit_price = round_price(unit_price)
|
||||
return unit_price
|
||||
return Product.get_sale_price(
|
||||
[self.product], abs(self.quantity or 0))[self.product.id]
|
||||
|
||||
@fields.depends('product')
|
||||
def on_change_with_product_uom_category(self, name=None):
|
||||
|
||||
@@ -57,9 +57,9 @@ class SaleTestCase(
|
||||
|
||||
with Transaction().set_context(uom=pound.id):
|
||||
prices = Product.get_sale_price([product], quantity=0.5)
|
||||
self.assertEqual(prices, {product.id: Decimal('2267.96185')})
|
||||
self.assertEqual(prices, {product.id: Decimal('2267.9618')})
|
||||
prices = Product.get_sale_price([product], quantity=1.5)
|
||||
self.assertEqual(prices, {product.id: Decimal('2267.96185')})
|
||||
self.assertEqual(prices, {product.id: Decimal('2267.9618')})
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
|
||||
@@ -14,7 +14,7 @@ from trytond.model.exceptions import AccessError
|
||||
from trytond.modules.company.model import (
|
||||
employee_field, reset_employee, set_employee)
|
||||
from trytond.modules.currency.fields import Monetary
|
||||
from trytond.modules.product import price_digits, round_price
|
||||
from trytond.modules.product import price_digits
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Bool, Eval, If
|
||||
from trytond.tools import sortable_values
|
||||
@@ -700,8 +700,6 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
||||
with Transaction().set_context(self._get_context_sale_price()):
|
||||
self.unit_price = Product.get_sale_price(
|
||||
[product], self.quantity or 0)[product.id]
|
||||
if self.unit_price is not None:
|
||||
self.unit_price = round_price(self.unit_price)
|
||||
|
||||
self.consumption_recurrence = self.service.consumption_recurrence
|
||||
self.consumption_delay = self.service.consumption_delay
|
||||
|
||||
@@ -229,8 +229,6 @@ class Move(metaclass=PoolMeta):
|
||||
taxes=[t.id for t in line.taxes]):
|
||||
line.unit_price = Product.get_sale_price(
|
||||
[line.product], line.quantity)[line.product.id]
|
||||
if line.unit_price is not None:
|
||||
line.unit_price = round_price(line.unit_price)
|
||||
return line
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user