summaryrefslogtreecommitdiff
path: root/addons/event/tests
diff options
context:
space:
mode:
authorSébastien Mottet (oms) <oms@odoo.com>2020-04-27 14:37:02 +0000
committerThibault Delavallée <tde@odoo.com>2020-06-16 09:14:31 +0000
commitbe11161a42947437447c5aba699f558a12589c0d (patch)
tree214a4c1a8f9707e4ee16f1dd54757d49270e78a1 /addons/event/tests
parent7c37d457e7ff9261bf17deec25213bab8e56d1fc (diff)
[FIX] event(_questions): take better care of 2many fields when updating from event type
PURPOSE Fix various issues spotted in 13.3 when testing event. Notably computation of 2many fields coming from template. SPECIFICATIONS When updating template on an event, one2many fields should be better managed. Previous heuristic was * if event type uses o2m configuration (use_ticket / _schedule / _question) and has lines * erase existing lines; * create new lines based on old one; This has the drawback of loosing information of what is sent (mail) or sold (tickets) or answered( questions). Another drawback is that only types having line are synchronized. This means that if updating several times the event type you could end up with an XMas configuration with lines coming from different event types, depending on their o2m configuration. We choose a better heuristic that should solve this issue * every time we change type, independently of its use_* field that is used mainly for UX on the type itself: * erase existing lines that have not been used yet (no mail sent, no ticket linked to registrations, no answer linked to registrations) * create new lines based on old one; if type has no lines, event will have its old empty line erased as well; It means that we try to synchronize more the type to the event while keeping configuration line already used in some registrations. Also provide some other fixes like deletion restrictions or better domain for UX purpose. See sub commits for more details. LINKS Task ID 2244487 PR odoo/odoo#52998 FwdPort of odoo/odoo#52923 X-original-commit: 645f70cad033083e82a3ef9102c694c331badef9 Co-authored-by: Sebastien Mottet <oms@odoo.com> Co-authored-by: Thibault Delavallée <tde@odoo.com>
Diffstat (limited to 'addons/event/tests')
-rw-r--r--addons/event/tests/test_event_internals.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/addons/event/tests/test_event_internals.py b/addons/event/tests/test_event_internals.py
index bd7e537f75f..09a0f9f5a92 100644
--- a/addons/event/tests/test_event_internals.py
+++ b/addons/event/tests/test_event_internals.py
@@ -139,8 +139,8 @@ class TestEventData(TestEventCommon):
registration.write({'event_ticket_id': event_ticket1.id})
self.assertEqual(registration.event_ticket_id, event_ticket1)
- # change template to a void one for mails -> do not reset event
- # change template to a one with other tickets -> reset event
+ # change template to a void one for mails -> reset event lines that are void
+ # change template to a one with other tickets -> keep line linked to a registration
event_type.write({
'use_mail_schedule': False,
'event_type_mail_ids': [(5, 0)],
@@ -148,15 +148,16 @@ class TestEventData(TestEventCommon):
(0, 0, {'name': 'Registration1'}),
(0, 0, {'name': 'Registration2'})],
})
- event._compute_from_event_type()
- self.assertEqual(len(event.event_mail_ids), 1)
- self.assertEqual(len(event.event_ticket_ids), 2)
+ event._compute_event_ticket_ids()
+ event._compute_event_mail_ids()
+ self.assertEqual(event.event_mail_ids, self.env['event.mail'])
+ self.assertEqual(len(event.event_ticket_ids), 3)
self.assertEqual(
set(event.mapped('event_ticket_ids.name')),
- set(['Registration1', 'Registration2'])
+ set(['TestRegistration', 'Registration1', 'Registration2'])
)
# registration loose its ticket
- self.assertEqual(registration.event_ticket_id, self.env['event.event.ticket'])
+ self.assertEqual(registration.event_ticket_id, event_ticket1)
# change template to a one with different mails -> reset event
event_type.write({
@@ -165,7 +166,8 @@ class TestEventData(TestEventCommon):
'interval_nbr': 3, 'interval_unit': 'days', 'interval_type': 'after_event',
'template_id': self.env['ir.model.data'].xmlid_to_res_id('event.event_reminder')})]
})
- event._compute_from_event_type()
+ event._compute_event_ticket_ids()
+ event._compute_event_mail_ids()
self.assertEqual(len(event.event_mail_ids), 1)
self.assertEqual(event.event_mail_ids.interval_nbr, 3)
self.assertEqual(event.event_mail_ids.interval_type, 'after_event')