[FW][MERGE] event_*: provide various fixes

RATIONALE

Even will soon gain a major update called Event Online, allowing to better
support full-online events. In order to prepare its merge, preparatory merge
are done to lessen the final diff.

PURPOSE

Prepare Event Online support by providing fixes and preparatory cleaning
commits.

SPECIFICATIONS

event_sale: do not copy SO information when duplicating a registration.
Indeed it makes no sense and leads to incoherent billing information.

website_event: fix ACL issue when updating menus through event fields
while not being website editor.

website_sale: fix visitor tests, make them independent from demo data.

LINKS

Task ID-2300907 (Event Bugprovements 2)
Prepares Task ID-2283796 (Event B2Basics)
Prepares Task ID-2252655 (master Online Event task)

closes odoo/odoo#54769

Forward-port-of: odoo/odoo#54627
Forward-port-of: odoo/odoo#54621
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Odoo's Mergebot
2020-07-22 14:06:10 +02:00
committed by GitHub
2 changed files with 17 additions and 14 deletions
+3 -3
View File
@@ -97,7 +97,7 @@ class Event(models.Model):
if event.menu_id and not event.website_menu:
event.menu_id.unlink()
elif event.website_menu and not event.menu_id:
root_menu = self.env['website.menu'].create({'name': event.name, 'website_id': event.website_id.id})
root_menu = self.env['website.menu'].sudo().create({'name': event.name, 'website_id': event.website_id.id})
event.menu_id = root_menu
for sequence, (name, url, xml_id) in enumerate(event._get_menu_entries()):
event._create_menu(sequence, name, url, xml_id)
@@ -105,9 +105,9 @@ class Event(models.Model):
def _create_menu(self, sequence, name, url, xml_id):
if not url:
self.env['ir.ui.view'].search([('name', '=', name + ' ' + self.name)]).unlink()
newpath = self.env['website'].new_page(name + ' ' + self.name, template=xml_id, ispage=False)['url']
newpath = self.env['website'].sudo().new_page(name + ' ' + self.name, template=xml_id, ispage=False)['url']
url = "/event/" + slug(self) + "/page/" + newpath[1:]
menu = self.env['website.menu'].create({
menu = self.env['website.menu'].sudo().create({
'name': name,
'url': url,
'parent_id': self.menu_id.id,
@@ -14,11 +14,8 @@ class WebsiteSaleVisitorTests(TransactionCase):
def test_create_visitor_on_tracked_product(self):
self.WebsiteSaleController = WebsiteSale()
Visitor = self.env['website.visitor']
Track = self.env['website.track']
self.assertEqual(len(Visitor.search([])), 0, "No visitor at the moment")
self.assertEqual(len(Track.search([])), 0, "No track at the moment")
existing_visitors = self.env['website.visitor'].search([])
existing_tracks = self.env['website.track'].search([])
product = self.env['product.product'].create({
'name': 'Storage Box',
@@ -28,14 +25,18 @@ class WebsiteSaleVisitorTests(TransactionCase):
with MockRequest(self.env, website=self.website):
self.cookies = self.WebsiteSaleController.products_recently_viewed_update(product.id)
self.assertEqual(len(Visitor.search([])), 1, "A visitor should be created after visiting a tracked product")
self.assertEqual(len(Track.search([])), 1, "A track should be created after visiting a tracked product")
new_visitors = self.env['website.visitor'].search([('id', 'not in', existing_visitors.ids)])
new_tracks = self.env['website.track'].search([('id', 'not in', existing_tracks.ids)])
self.assertEqual(len(new_visitors), 1, "A visitor should be created after visiting a tracked product")
self.assertEqual(len(new_tracks), 1, "A track should be created after visiting a tracked product")
with MockRequest(self.env, website=self.website, cookies=self.cookies):
self.WebsiteSaleController.products_recently_viewed_update(product.id)
self.assertEqual(len(Visitor.search([])), 1, "No visitor should be created after visiting another tracked product")
self.assertEqual(len(Track.search([])), 1, "No track should be created after visiting the same tracked product before 30 min")
new_visitors = self.env['website.visitor'].search([('id', 'not in', existing_visitors.ids)])
new_tracks = self.env['website.track'].search([('id', 'not in', existing_tracks.ids)])
self.assertEqual(len(new_visitors), 1, "No visitor should be created after visiting another tracked product")
self.assertEqual(len(new_tracks), 1, "No track should be created after visiting the same tracked product before 30 min")
product = self.env['product.product'].create({
'name': 'Large Cabinet',
@@ -46,5 +47,7 @@ class WebsiteSaleVisitorTests(TransactionCase):
with MockRequest(self.env, website=self.website, cookies=self.cookies):
self.WebsiteSaleController.products_recently_viewed_update(product.id)
self.assertEqual(len(Visitor.search([])), 1, "No visitor should be created after visiting another tracked product")
self.assertEqual(len(Track.search([])), 2, "A track should be created after visiting another tracked product")
new_visitors = self.env['website.visitor'].search([('id', 'not in', existing_visitors.ids)])
new_tracks = self.env['website.track'].search([('id', 'not in', existing_tracks.ids)])
self.assertEqual(len(new_visitors), 1, "No visitor should be created after visiting another tracked product")
self.assertEqual(len(new_tracks), 2, "A track should be created after visiting another tracked product")