[IMP] contract: Add contract modification

This commit is contained in:
Víctor Martínez
2020-12-16 09:44:18 +01:00
committed by Pedro M. Baeza
parent 7f8c59fb2a
commit a9f65b439a
15 changed files with 426 additions and 1985 deletions

View File

@@ -25,6 +25,7 @@ class TestContractBase(common.SavepointCase):
cls.partner = cls.env['res.partner'].create({
'name': 'partner test contract',
'property_product_pricelist': cls.pricelist.id,
'email': 'demo@demo.com'
})
cls.product_1 = cls.env.ref('product.product_product_1')
cls.product_2 = cls.env.ref('product.product_product_2')
@@ -133,6 +134,42 @@ class TestContract(TestContractBase):
vals.update(overrides)
return self.env['contract.template.line'].create(vals)
def test_add_modifications(self):
self.contract.message_subscribe(
partner_ids=self.contract.partner_id.ids,
subtype_ids=self.env.ref(
'contract.mail_message_subtype_contract_modification'
).ids
)
# Check initial modification auto-creation
self.assertEqual(len(self.contract.modification_ids), 1)
self.contract.write({
'modification_ids': [
(
0,
0,
{
'date': '2020-01-01',
'description': 'Modification 1',
}
),
(
0,
0,
{
'date': '2020-02-01',
'description': 'Modification 2',
}
)
]
})
self.assertEqual(len(self.contract.message_partner_ids.ids), 2)
mail_messages = self.env["mail.message"].search([
("model", "=", "contract.contract"),
("res_id", "=", self.contract.id),
])
self.assertGreaterEqual(len(mail_messages), 3)
def test_check_discount(self):
with self.assertRaises(ValidationError):
self.acct_line.write({'discount': 120})