Files
odoo_source/addons/website/tests/test_menu.py
T
Jeremy KerstenandDerie Romain 602807acdf [FIX] website: improve/fix menu, copy on unlink, clone page, unique_path, sale_report, ...
Fix bug from the initial poc of JOV

Fix menu creation
   - creating a menu would create a 'container' menu in the DB (.create is call without website_id)
   then writing on it would copy (if condition to cow) the menu with a website_id leaving the first
   one as a menu container unused.
   - website_menu should always have a website_id
     we dont want to support the multiwebsite system that allow to have generic/specific menu
     unlink/write is useless now since we always have a website_id

Make unique_path website dependent, 2 distinct website can have a page with same name

Make Sale report multiwebsite compliant

Make website_id on sale_order / account.invoice as a related stored from partner_id.

Co-authored-by: Derie Romain <rde@odoo.com>
Co-authored-by: Kersten Jérémy <jke@odoo.com>
2018-08-13 20:16:34 +02:00

52 lines
1.7 KiB
Python

# coding: utf-8
from odoo.tests import common
class TestMenu(common.TransactionCase):
def test_website_own_menu_container(self):
Website = self.env['website']
Menu = self.env['website.menu']
total_menus = Menu.search_count([])
Website.create({'name': 'new website'})
self.assertEqual(total_menus + 2, Menu.search_count([]), "New website's bootstraping should have created a container menu and home menu")
def test_menu_got_duplicated(self):
Menu = self.env['website.menu']
total_menu_items = Menu.search_count([])
self.menu_root = Menu.create({
'name': 'Root',
})
self.menu_child = Menu.create({
'name': 'Child',
'parent_id': self.menu_root.id,
})
self.assertEqual(total_menu_items + 4, Menu.search_count([]), "Creating a menu without a website_id should create this menu for every website_id")
def test_menu_count(self):
Menu = self.env['website.menu']
total_menu_items = Menu.search_count([])
top_menu = self.env['website'].get_current_website().menu_id
data = [
{
'id': 'new-1',
'parent_id': top_menu.id,
'name': 'New Menu Specific 1',
'url': '/new-specific-1',
},
{
'id': 'new-2',
'parent_id': top_menu.id,
'name': 'New Menu Specific 2',
'url': '/new-specific-2',
}
]
Menu.save(1, {'data': data, 'to_delete': []})
self.assertEqual(total_menu_items + 2, Menu.search_count([]), "Creating 2 new menus should create only 2 menus records")