Create contract
This commit is contained in:
@@ -2255,6 +2255,81 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
with self.assertRaises(UserError):
|
||||
ContractFactory._get_line_sources(contract_detail, sources, ct)
|
||||
|
||||
def test_contract_detail_defaults_sale_locations_from_dropship_purchase(self):
|
||||
'create contracts copies supplier-to-customer locations from purchase to sale'
|
||||
supplier = Mock(id=1, type='supplier')
|
||||
customer = Mock(id=2, type='customer')
|
||||
purchase = Mock(from_location=supplier, to_location=customer)
|
||||
lqt = Mock(
|
||||
lot_p=Mock(line=Mock(purchase=purchase)),
|
||||
lot_s=None)
|
||||
|
||||
with patch.object(
|
||||
lot_module.ContractDetail, '_get_lqt_from_context',
|
||||
return_value=lqt):
|
||||
self.assertEqual(lot_module.ContractDetail.default_from_location(), 1)
|
||||
self.assertEqual(lot_module.ContractDetail.default_to_location(), 2)
|
||||
|
||||
def test_contract_detail_defaults_sale_from_purchase_stock_destination(self):
|
||||
'create contracts uses purchase stock destination as sale source'
|
||||
supplier = Mock(id=1, type='supplier')
|
||||
storage = Mock(id=3, type='storage')
|
||||
purchase = Mock(from_location=supplier, to_location=storage)
|
||||
lqt = Mock(
|
||||
lot_p=Mock(line=Mock(purchase=purchase)),
|
||||
lot_s=None)
|
||||
|
||||
with patch.object(
|
||||
lot_module.ContractDetail, '_get_lqt_from_context',
|
||||
return_value=lqt):
|
||||
self.assertEqual(lot_module.ContractDetail.default_from_location(), 3)
|
||||
self.assertIsNone(lot_module.ContractDetail.default_to_location())
|
||||
|
||||
def test_contract_detail_defaults_purchase_locations_from_dropship_sale(self):
|
||||
'create contracts copies supplier-to-customer locations from sale to purchase'
|
||||
supplier = Mock(id=1, type='supplier')
|
||||
customer = Mock(id=2, type='customer')
|
||||
sale = Mock(from_location=supplier, to_location=customer)
|
||||
lqt = Mock(
|
||||
lot_p=None,
|
||||
lot_s=Mock(sale_line=Mock(sale=sale)))
|
||||
|
||||
with patch.object(
|
||||
lot_module.ContractDetail, '_get_lqt_from_context',
|
||||
return_value=lqt):
|
||||
self.assertEqual(lot_module.ContractDetail.default_from_location(), 1)
|
||||
self.assertEqual(lot_module.ContractDetail.default_to_location(), 2)
|
||||
|
||||
def test_contract_detail_defaults_purchase_to_sale_stock_source(self):
|
||||
'create contracts uses sale stock source as purchase destination'
|
||||
storage = Mock(id=3, type='storage')
|
||||
customer = Mock(id=2, type='customer')
|
||||
sale = Mock(from_location=storage, to_location=customer)
|
||||
lqt = Mock(
|
||||
lot_p=None,
|
||||
lot_s=Mock(sale_line=Mock(sale=sale)))
|
||||
|
||||
with patch.object(
|
||||
lot_module.ContractDetail, '_get_lqt_from_context',
|
||||
return_value=lqt):
|
||||
self.assertIsNone(lot_module.ContractDetail.default_from_location())
|
||||
self.assertEqual(lot_module.ContractDetail.default_to_location(), 3)
|
||||
|
||||
def test_contract_detail_hides_melya_company_fields(self):
|
||||
'create contracts mirrors Melya company field visibility'
|
||||
company = Mock(party=Mock(name='MELYA'))
|
||||
company_model = Mock(return_value=company)
|
||||
transaction = Mock()
|
||||
transaction.context = {'company': 42}
|
||||
|
||||
with patch('trytond.modules.purchase_trade.lot.Pool') as PoolMock, \
|
||||
patch('trytond.modules.purchase_trade.lot.Transaction',
|
||||
return_value=transaction):
|
||||
PoolMock.return_value.get.return_value = company_model
|
||||
|
||||
self.assertTrue(
|
||||
lot_module.ContractDetail.default_company_visible())
|
||||
|
||||
def test_sale_report_price_lines_basis_displays_premium_only(self):
|
||||
'basis report pricing displays only the premium in templates'
|
||||
Sale = Pool().get('sale.sale')
|
||||
|
||||
Reference in New Issue
Block a user