Pricing default
This commit is contained in:
@@ -2591,6 +2591,68 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
('id', 'in', Eval('available_components', [])),
|
||||
])
|
||||
|
||||
def test_pricing_defaults_single_manual_purchase_component(self):
|
||||
'new purchase pricing rows default the only manual line component'
|
||||
Pricing = Pool().get('pricing.pricing')
|
||||
owner = Mock(id=10)
|
||||
component = Mock(id=33, auto=False)
|
||||
component_model = Mock()
|
||||
component_model.search.return_value = [component]
|
||||
pool = Mock()
|
||||
pool.get.return_value = component_model
|
||||
pricing = Pricing()
|
||||
pricing.line = owner
|
||||
pricing.sale_line = None
|
||||
pricing.price_component = None
|
||||
|
||||
with patch('trytond.modules.purchase_trade.pricing.Pool',
|
||||
return_value=pool):
|
||||
pricing.on_change_line()
|
||||
|
||||
component_model.search.assert_called_once_with([('line', '=', owner)])
|
||||
self.assertEqual(pricing.price_component, component)
|
||||
|
||||
def test_pricing_defaults_single_manual_sale_component(self):
|
||||
'new sale pricing rows default the only manual line component'
|
||||
Pricing = Pool().get('pricing.pricing')
|
||||
owner = Mock(id=10)
|
||||
component = Mock(id=33, auto=False)
|
||||
component_model = Mock()
|
||||
component_model.search.return_value = [component]
|
||||
pool = Mock()
|
||||
pool.get.return_value = component_model
|
||||
pricing = Pricing()
|
||||
pricing.line = None
|
||||
pricing.sale_line = owner
|
||||
pricing.price_component = None
|
||||
|
||||
with patch('trytond.modules.purchase_trade.pricing.Pool',
|
||||
return_value=pool):
|
||||
pricing.on_change_sale_line()
|
||||
|
||||
component_model.search.assert_called_once_with([
|
||||
('sale_line', '=', owner)])
|
||||
self.assertEqual(pricing.price_component, component)
|
||||
|
||||
def test_pricing_does_not_default_single_auto_component(self):
|
||||
'new manual pricing rows do not default an auto component'
|
||||
Pricing = Pool().get('pricing.pricing')
|
||||
owner = Mock(id=10)
|
||||
component_model = Mock()
|
||||
component_model.search.return_value = [Mock(id=33, auto=True)]
|
||||
pool = Mock()
|
||||
pool.get.return_value = component_model
|
||||
pricing = Pricing()
|
||||
pricing.line = owner
|
||||
pricing.sale_line = None
|
||||
pricing.price_component = None
|
||||
|
||||
with patch('trytond.modules.purchase_trade.pricing.Pool',
|
||||
return_value=pool):
|
||||
pricing.on_change_line()
|
||||
|
||||
self.assertIsNone(pricing.price_component)
|
||||
|
||||
def test_pricing_component_must_belong_to_pricing_owner(self):
|
||||
'pricing rows reject components from another purchase or sale line'
|
||||
Pricing = Pool().get('pricing.pricing')
|
||||
|
||||
Reference in New Issue
Block a user