summaryrefslogtreecommitdiff
path: root/addons/website_event/tests/common.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2020-07-01 13:13:36 +0000
committerThibault Delavallée <tde@odoo.com>2020-07-31 18:05:12 +0000
commit917ad9a9a9f74e36c00ad2bc0d31b588b9afe0c8 (patch)
tree87a2b5f1cadfb26cc9604bb3b898104e258affcd /addons/website_event/tests/common.py
parentd5840a90936014d7ec62af936c0fef97505cb669 (diff)
[REF] website_event(_track): better support menu management from frontend
RATIONALE Events are sometimes held online, gathering a community. In this merge we improve Event application to better support full-online events with improved tracks, wishlists, chat rooms, ... PURPOSE New and improved pages are about to land for online event. However current menus and pages management is hard to tweak, especially when dealing with the stable policy of 13.3 . SPECIFICATIONS Refactor and improve code about event menu management. Purpose is to ease inheritance and be able to add menus and pages with less custom code in sub modules. Refactor some code, notably * code dealing with menus to activate and de-activate that is duplicated for each kind of menu; * allow to give a menu_type through inheritance in create_menu notably to support website.event.menu model available in Track app and unfortunately not in website_event; * make a somehow generic way of getting fields dealing with menu items through simple inheritance; * support sequence to allow ordering of menu entries by propagating the sequence to website menus; Behavior in website_event and website_event_track should be the same. Behavior will be tweaked in other modules through inheritance.. Improve behavior when removing frontend menus * correctly fetch views (for Introduction / Location) and try to unlink them to avoid bloating the db; * update boolean menu fields according to website menu management. Removing a menu from frontend should be reflected on boolean fields of event; LINKS PR #55260 Task ID-2310491 (Event Online Preparation 5) Part of Task ID-2252655 (Main Online Event task) Part of Task ID-2283796 (Event B2Basics / Registration Flow) Co-Authored-By: Aurélien Warnon <awa@odoo.com> Co-Authored-By: David Beguin <dbe@odoo.com> Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Diffstat (limited to 'addons/website_event/tests/common.py')
-rw-r--r--addons/website_event/tests/common.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/addons/website_event/tests/common.py b/addons/website_event/tests/common.py
index b4bd532ab04..333a2ed4789 100644
--- a/addons/website_event/tests/common.py
+++ b/addons/website_event/tests/common.py
@@ -2,16 +2,44 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.event.tests.common import TestEventCommon
+from odoo.addons.mail.tests.common import mail_new_test_user
class TestWebsiteEventCommon(TestEventCommon):
+ @classmethod
+ def setUpClass(cls):
+ super(TestWebsiteEventCommon, cls).setUpClass()
+
+ cls.company_main = cls.env.user.company_id
+ cls.user_event_web_manager = mail_new_test_user(
+ cls.env, login='user_event_web_manager',
+ name='Martin Sales Manager', email='crm_manager@test.example.com',
+ company_id=cls.company_main.id,
+ notification_type='inbox',
+ groups='event.group_event_manager,website.group_website_designer',
+ )
+
def _get_menus(self):
return set(['Introduction', 'Location', 'Register'])
- def _assert_website_menus(self, event):
+ def _assert_website_menus(self, event, menu_entries=None):
self.assertTrue(event.menu_id)
+ if menu_entries is None:
+ menu_entries = self._get_menus()
+
menus = self.env['website.menu'].search([('parent_id', '=', event.menu_id.id)])
- self.assertEqual(len(menus), len(self._get_menus()))
- self.assertEqual(set(menus.mapped('name')), self._get_menus())
+ self.assertEqual(len(menus), len(menu_entries))
+ self.assertEqual(set(menus.mapped('name')), menu_entries)
+
+ for page_specific in ['Introduction', 'Location']:
+ view = self.env['ir.ui.view'].search(
+ [('name', '=', page_specific + ' ' + event.name)]
+ )
+ if page_specific in menu_entries:
+ self.assertTrue(bool(view))
+ # TDE FIXME: page deletion not done in 13.3 for Introduction/Location, difficult to fix
+ # without website.event.menu model (or crappy code based on name)
+ # else:
+ # self.assertFalse(bool(view))