[12.0][REF] - Split analytic accouts and contracts

This commit is contained in:
sbejaoui
2019-09-17 18:14:23 +02:00
committed by Thomas Binsfeld
parent ae1b366692
commit 424f819d87
10 changed files with 55 additions and 51 deletions

View File

@@ -11,7 +11,7 @@ class TestProductTemplate(TransactionCase):
super(TestProductTemplate, self).setUp()
self.service_product = self.env.ref('product.product_product_1')
self.consu_product = self.env.ref('product.product_product_5')
self.contract = self.env['account.analytic.contract'].create(
self.contract = self.env['contract.template'].create(
{'name': 'Test'}
)

View File

@@ -14,13 +14,13 @@ class TestSaleOrder(TransactionCase):
self.product1 = self.env.ref('product.product_product_1')
self.product2 = self.env.ref('product.product_product_2')
self.sale = self.env.ref('sale.sale_order_2')
self.contract_template1 = self.env['account.analytic.contract'].create(
self.contract_template1 = self.env['contract.template'].create(
{'name': 'Template 1'}
)
self.contract_template2 = self.env['account.analytic.contract'].create(
self.contract_template2 = self.env['contract.template'].create(
{
'name': 'Template 2',
'recurring_invoice_line_ids': [
'contract_line_ids': [
(
0,
0,
@@ -58,15 +58,14 @@ class TestSaleOrder(TransactionCase):
self.order_line1.date_start = '2018-01-01'
self.order_line1.product_uom_qty = 12
pricelist = self.sale.partner_id.property_product_pricelist.id
self.contract = self.env["account.analytic.account"].create(
self.contract = self.env["contract.contract"].create(
{
"name": "Test Contract 2",
"partner_id": self.sale.partner_id.id,
"pricelist_id": pricelist,
"recurring_invoices": True,
"contract_type": "sale",
"contract_template_id": self.contract_template1.id,
"recurring_invoice_line_ids": [
"contract_line_ids": [
(
0,
0,
@@ -86,7 +85,7 @@ class TestSaleOrder(TransactionCase):
],
}
)
self.contract_line = self.contract.recurring_invoice_line_ids[0]
self.contract_line = self.contract.contract_line_ids[0]
def test_compute_is_contract(self):
"""Sale Order should have is_contract true if one of its lines is
@@ -104,13 +103,13 @@ class TestSaleOrder(TransactionCase):
self.order_line1.contract_id.contract_template_id,
self.contract_template1,
)
contract_line = self.order_line1.contract_id.recurring_invoice_line_ids
contract_line = self.order_line1.contract_id.contract_line_ids
self.assertEqual(contract_line.date_start, Date.to_date('2018-01-01'))
self.assertEqual(contract_line.date_end, Date.to_date('2018-12-31'))
self.assertEqual(
contract_line.recurring_next_date, Date.to_date('2018-01-31')
)
def test_action_confirm_without_contract_creation(self):
""" It should create a contract for each contract template used in
order_line """
@@ -126,13 +125,13 @@ class TestSaleOrder(TransactionCase):
self.order_line1.contract_id.contract_template_id,
self.contract_template1,
)
contract_line = self.order_line1.contract_id.recurring_invoice_line_ids
contract_line = self.order_line1.contract_id.contract_line_ids
self.assertEqual(contract_line.date_start, Date.to_date('2018-01-01'))
self.assertEqual(contract_line.date_end, Date.to_date('2018-12-31'))
self.assertEqual(
contract_line.recurring_next_date, Date.to_date('2018-01-31')
)
def test_sale_contract_count(self):
"""It should count contracts as many different contract template used
in order_line"""
@@ -157,7 +156,7 @@ class TestSaleOrder(TransactionCase):
def test_check_contract_sale_partner(self):
"""Can't link order line to a partner contract different then the
order one"""
contract2 = self.env['account.analytic.account'].create(
contract2 = self.env['contract.contract'].create(
{
'name': 'Contract',
'contract_template_id': self.contract_template2.id,
@@ -170,9 +169,10 @@ class TestSaleOrder(TransactionCase):
def test_check_contract_sale_contract_template(self):
"""Can't link order line to a contract with different contract
template then the product one"""
contract1 = self.env['account.analytic.account'].create(
contract1 = self.env['contract.contract'].create(
{
'name': 'Contract',
'partner_id': self.env.user.partner_id.id,
'contract_template_id': self.contract_template1.id,
}
)
@@ -235,7 +235,7 @@ class TestSaleOrder(TransactionCase):
self.contract_line.date_end, Date.to_date("2018-05-31")
)
self.assertFalse(self.contract_line.is_auto_renew)
new_contract_line = self.env['account.analytic.invoice.line'].search(
new_contract_line = self.env['contract.line'].search(
[('sale_order_line_id', '=', self.order_line1.id)]
)
self.assertEqual(