[FIX] contract: Modification mail + Auto-create follower in contract creation related to partner_id

Co-Authored-By: Pedro M. Baeza <pedro.baeza@tecnativa.com>
This commit is contained in:
Víctor Martínez
2021-01-04 16:47:48 +01:00
committed by Pedro M. Baeza
parent 18f1f8ce52
commit 25baee81f9
2 changed files with 28 additions and 22 deletions

View File

@@ -135,11 +135,11 @@ class TestContract(TestContractBase):
return self.env['contract.template.line'].create(vals)
def test_add_modifications(self):
partner2 = self.partner.copy()
subtype = self.env.ref('contract.mail_message_subtype_contract_modification')
self.contract.message_subscribe(
partner_ids=self.contract.partner_id.ids,
subtype_ids=self.env.ref(
'contract.mail_message_subtype_contract_modification'
).ids
partner_ids=partner2.ids,
subtype_ids=subtype.ids
)
# Check initial modification auto-creation
self.assertEqual(len(self.contract.modification_ids), 1)
@@ -163,12 +163,16 @@ class TestContract(TestContractBase):
)
]
})
self.assertGreaterEqual(len(self.contract.message_partner_ids), 2)
mail_messages = self.env["mail.message"].search([
partner_ids = self.contract.message_follower_ids.filtered(
lambda x: subtype in x.subtype_ids
).mapped('partner_id')
self.assertGreaterEqual(len(partner_ids), 2)
total_mail_messages = self.env["mail.message"].search_count([
("model", "=", "contract.contract"),
("res_id", "=", self.contract.id),
("subtype_id", "=", subtype.id)
])
self.assertGreaterEqual(len(mail_messages), 2)
self.assertGreaterEqual(total_mail_messages, 1)
def test_check_discount(self):
with self.assertRaises(ValidationError):
@@ -256,7 +260,7 @@ class TestContract(TestContractBase):
self.contract.recurring_create_invoice()
invoice_daily = self.contract._get_related_invoices()
self.assertTrue(invoice_daily)
self.assertEqual(len(invoice_daily.message_partner_ids.ids), 2)
self.assertEqual(len(invoice_daily.message_partner_ids.ids), 1)
def test_contract_weekly_post_paid(self):
recurring_next_date = to_date('2018-03-01')