bug Th qt
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
import datetime
|
||||
from decimal import Decimal
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
@@ -208,6 +209,43 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
purchase_component.get_quota_purchase('quota'),
|
||||
Decimal('15.00000'))
|
||||
|
||||
def test_sale_and_purchase_generate_pricing_use_quantity_fallback(self):
|
||||
'pricing generation uses quantity when theoretical quantity is missing'
|
||||
Sale = Pool().get('sale.sale')
|
||||
Purchase = Pool().get('purchase.purchase')
|
||||
|
||||
sale = Sale()
|
||||
sale.id = 1
|
||||
sale.quantity = Decimal('10')
|
||||
sale.quantity_theorical = None
|
||||
sale.unit = Mock()
|
||||
sale.sale = Mock(currency=Mock())
|
||||
sale.getnearprice = Mock(return_value=Decimal('0'))
|
||||
|
||||
purchase = Purchase()
|
||||
purchase.id = 1
|
||||
purchase.quantity = Decimal('12')
|
||||
purchase.quantity_theorical = None
|
||||
purchase.unit = Mock()
|
||||
purchase.purchase = Mock(currency=Mock())
|
||||
purchase.getnearprice = Mock(return_value=Decimal('0'))
|
||||
|
||||
pricing_model = Mock()
|
||||
pricing_model.search.return_value = []
|
||||
pc_sale = Mock(id=1, quota_sale=Decimal('2'), pricing_date=None, price_index=Mock(get_price=Mock(return_value=Decimal('1'))))
|
||||
pc_purchase = Mock(id=1, quota=Decimal('3'), pricing_date=None, price_index=Mock(get_price=Mock(return_value=Decimal('1'))))
|
||||
|
||||
with patch('trytond.modules.purchase_trade.sale.Pool') as SalePool, patch(
|
||||
'trytond.modules.purchase_trade.purchase.Pool') as PurchasePool:
|
||||
SalePool.return_value.get.return_value = pricing_model
|
||||
PurchasePool.return_value.get.return_value = pricing_model
|
||||
|
||||
sale.generate_pricing(pc_sale, [datetime.datetime(2026, 4, 1)], [])
|
||||
purchase.generate_pricing(pc_purchase, [datetime.datetime(2026, 4, 1)], [])
|
||||
|
||||
self.assertEqual(pricing_model.save.call_args_list[0].args[0][0].unfixed_qt, Decimal('10'))
|
||||
self.assertEqual(pricing_model.save.call_args_list[1].args[0][0].unfixed_qt, Decimal('12'))
|
||||
|
||||
def test_sale_and_purchase_trader_operator_domains_use_explicit_categories(self):
|
||||
'sale and purchase trader/operator fields are filtered by TRADER/OPERATOR categories'
|
||||
Sale = Pool().get('sale.sale')
|
||||
|
||||
Reference in New Issue
Block a user