[13.0][IMP] contract_price_revision: Add fixed price revision

This commit is contained in:
Denis Roussel
2021-02-15 10:24:40 +01:00
parent 0cf9d8f9ef
commit 389201cad6
3 changed files with 71 additions and 12 deletions

View File

@@ -7,18 +7,26 @@ from odoo.addons.contract.tests.test_contract import TestContractBase
class TestContractPriceRevision(TestContractBase):
def execute_wizard(self):
def _create_wizard(self, v_type="percentage", value=0.0):
# TODO: Limitation here, start date should be on the
# beginning of next period (should not have a gap)
wizard = self.env["contract.price.revision.wizard"].create(
{"date_start": "2018-02-01", "variation_percent": 100.0}
self.wizard = self.env["contract.price.revision.wizard"].create(
{
"date_start": "2018-02-01",
"variation_type": v_type,
"variation_percent": value,
"fixed_price": value,
}
)
wizard.with_context({"active_ids": [self.contract.id]}).action_apply()
def execute_wizard(self):
self.wizard.with_context({"active_ids": [self.contract.id]}).action_apply()
def test_contract_price_revision_wizard(self):
# This is for checking if this line is not versioned
self.acct_line.copy({"automatic_price": True})
self.assertEqual(len(self.contract.contract_line_ids.ids), 2)
self._create_wizard(value=100.0)
self.execute_wizard()
self.assertEqual(len(self.contract.contract_line_ids.ids), 3)
lines = self.contract.contract_line_ids.filtered(
@@ -26,8 +34,21 @@ class TestContractPriceRevision(TestContractBase):
)
self.assertEqual(len(lines), 1)
def test_contract_price_fixed_revision_wizard(self):
# This is for checking if this line is not versioned
self.acct_line.copy({"automatic_price": True})
self.assertEqual(len(self.contract.contract_line_ids.ids), 2)
self._create_wizard(v_type="fixed", value=120.0)
self.execute_wizard()
self.assertEqual(len(self.contract.contract_line_ids.ids), 3)
lines = self.contract.contract_line_ids.filtered(
lambda x: x.price_unit == 120.0
)
self.assertEqual(len(lines), 1)
def test_contract_price_revision_invoicing(self):
self.acct_line.copy({"automatic_price": True})
self._create_wizard(value=100.0)
self.execute_wizard()
invoice = self.contract.recurring_create_invoice()
invoices = self.env["account.move"].search(