CreateContract
This commit is contained in:
@@ -2786,6 +2786,65 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
ContractFactory._get_crop(contract_detail, base_contract),
|
||||
crop)
|
||||
|
||||
def test_contract_factory_locations_fallback_to_source_contract(self):
|
||||
'create contracts keeps required locations when wizard line is empty'
|
||||
source_from = Mock(type='supplier')
|
||||
source_to = Mock(type='storage')
|
||||
contract_detail = Mock(from_location=None, to_location=None)
|
||||
base_contract = Mock(
|
||||
from_location=source_from, to_location=source_to)
|
||||
|
||||
from_location, to_location = ContractFactory._get_locations(
|
||||
contract_detail, base_contract, 'Sale')
|
||||
|
||||
self.assertEqual(from_location, source_to)
|
||||
self.assertEqual(to_location, source_to)
|
||||
|
||||
def test_contract_factory_required_header_fields_fallback_to_defaults(self):
|
||||
'create contracts fills required header fields outside the normal form'
|
||||
contract = Mock()
|
||||
party = Mock(wb=None, association=None, certif=None)
|
||||
base_contract = Mock(wb=None, association=None, certif=None)
|
||||
Contract = Mock()
|
||||
Contract.default_wb.return_value = 1
|
||||
Contract.default_association.return_value = 2
|
||||
Contract.default_certif.return_value = 3
|
||||
|
||||
with patch('trytond.modules.purchase_trade.service.Pool') as PoolMock:
|
||||
PoolMock.return_value.get.return_value = Contract
|
||||
|
||||
ContractFactory._apply_party_data(
|
||||
contract, party, base_contract, 'Purchase')
|
||||
|
||||
self.assertEqual(contract.wb, 1)
|
||||
self.assertEqual(contract.association, 2)
|
||||
self.assertEqual(contract.certif, 3)
|
||||
|
||||
def test_contract_factory_incoterm_fallback_to_source_contract(self):
|
||||
'create contracts keeps required incoterm when wizard line is empty'
|
||||
incoterm = Mock()
|
||||
contract_detail = Mock(incoterm=None)
|
||||
base_contract = Mock(incoterm=incoterm)
|
||||
|
||||
self.assertEqual(
|
||||
ContractFactory._get_contract_value(
|
||||
contract_detail, base_contract, 'incoterm'),
|
||||
incoterm)
|
||||
|
||||
def test_contract_factory_currency_unit_fallback_to_hidden_defaults(self):
|
||||
'create contracts can price even when currency/unit selector is empty'
|
||||
contract_detail = Mock(
|
||||
currency_unit=None,
|
||||
currency=Mock(id=7),
|
||||
unit=Mock(id=9),
|
||||
)
|
||||
base_contract = Mock(currency=Mock(id=3))
|
||||
|
||||
self.assertEqual(
|
||||
ContractFactory._get_currency_unit_parts(
|
||||
contract_detail, base_contract),
|
||||
['7', '9'])
|
||||
|
||||
def test_contract_factory_delivery_dates_fallback_to_period(self):
|
||||
'hidden delivery dates are still derived from delivery period'
|
||||
period = Mock(beg_date='2026-05-01', end_date='2026-05-31')
|
||||
|
||||
Reference in New Issue
Block a user