diff options
Diffstat (limited to 'addons/website')
| -rw-r--r-- | addons/website/models/ir_ui_view.py | 6 | ||||
| -rw-r--r-- | addons/website/models/website_menu.py | 7 | ||||
| -rw-r--r-- | addons/website/static/src/js/widgets/theme.js | 28 | ||||
| -rw-r--r-- | addons/website/static/src/scss/website.scss | 4 | ||||
| -rw-r--r-- | addons/website/tests/test_views.py | 37 |
5 files changed, 74 insertions, 8 deletions
diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index a5e17c21628..a36bc717c7c 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -133,12 +133,8 @@ class View(models.Model): ('website_id', '!=', None), ]) for specific_parent_view in specific_parent_views: - record.copy({ - # Set key to avoid copy() to generate an unique key as - # we want the specific view to have the same key - 'key': record.key, + record.with_context(website_id=specific_parent_view.website_id.id).write({ 'inherit_id': specific_parent_view.id, - 'website_id': specific_parent_view.website_id.id, }) return records diff --git a/addons/website/models/website_menu.py b/addons/website/models/website_menu.py index 202f6e19039..4afb9bd63e5 100644 --- a/addons/website/models/website_menu.py +++ b/addons/website/models/website_menu.py @@ -149,7 +149,12 @@ class Menu(models.Model): if menu_id.page_id: menu_id.page_id = None else: - page = self.env['website.page'].search(['|', ('url', '=', menu['url']), ('url', '=', '/' + menu['url'])], limit=1) + domain = self.env["website"].website_domain(website_id) + [ + "|", + ("url", "=", menu["url"]), + ("url", "=", "/" + menu["url"]), + ] + page = self.env["website.page"].search(domain, limit=1) if page: menu['page_id'] = page.id menu['url'] = page.url diff --git a/addons/website/static/src/js/widgets/theme.js b/addons/website/static/src/js/widgets/theme.js index d5a2997031d..fcdc8c5ad3b 100644 --- a/addons/website/static/src/js/widgets/theme.js +++ b/addons/website/static/src/js/widgets/theme.js @@ -547,6 +547,34 @@ var ThemeCustomizeDialog = Dialog.extend({ _setActive: function () { var self = this; + // First enforce that all input groups have only one element checked as + // it is supposed to be (it might not be the case on initialization, for + // exemple if we had data-xmlid="A" and data-xmlid="A,B" and if A and B + // are active, the 2 related inputs would be checked). + var $radioXMLInputs = this.$inputs.filter('[type="radio"][data-xmlid]'); + var optionNames = _.uniq(_.map($radioXMLInputs, function (option) { + return option.name; + })); + _.each(optionNames, function (optionName) { + var $inputs = $radioXMLInputs.filter('[name="' + optionName + '"]:checked'); + if ($inputs.length > 1) { + $inputs.prop('checked', false); + + var maxNbXMLIDs = -1; + var $maxInput = null; + _.each($inputs, function (input) { + var $input = $(input); + var xmlID = $input.data('xmlid'); + var nbXMLIDs = xmlID ? xmlID.split(',').length : 0; + if (nbXMLIDs >= maxNbXMLIDs) { + maxNbXMLIDs = nbXMLIDs; + $maxInput = $input; + } + }); + $maxInput.prop('checked', true); + } + }); + // Look at all options to see if they are enabled or disabled var $enable = this.$inputs.filter(':checked'); diff --git a/addons/website/static/src/scss/website.scss b/addons/website/static/src/scss/website.scss index 5fb20b332c8..1c9792b91ab 100644 --- a/addons/website/static/src/scss/website.scss +++ b/addons/website/static/src/scss/website.scss @@ -534,8 +534,8 @@ table.table_desc tr td { // Default &.s_carousel_default { // Controls - chevron - .carousel-control-prev-icon:before { content: "\f053"; margin-left: 1.5rem; } - .carousel-control-next-icon:before { content: "\f054"; margin-right: 1.5rem; } + .carousel-control-prev-icon:before { content: "\f053" #{"/*rtl:'\f054'*/"}; margin-left: 1.5rem; } + .carousel-control-next-icon:before { content: "\f054" #{"/*rtl:'\f053'*/"}; margin-right: 1.5rem; } .carousel-control-prev-icon:before, .carousel-control-next-icon:before { background-color: rgba(0,0,0,0); diff --git a/addons/website/tests/test_views.py b/addons/website/tests/test_views.py index b8262bb11b8..38b3311ecbd 100644 --- a/addons/website/tests/test_views.py +++ b/addons/website/tests/test_views.py @@ -811,6 +811,43 @@ class TestCowViewSaving(common.TransactionCase): all_title_updated = specific_view.website_meta_title == self.base_view.website_meta_title == "A bug got fixed by updating this field" self.assertEqual(all_title_updated, True, "Update on top level generic views should also be applied on specific views") + def test_module_new_inherit_view_on_parent_already_forked_xpath_replace(self): + """ Deeper, more specific test of above behavior. + A module install should add/update the COW view (if allowed fields, + eg not modified or prohibited (website_id, inherit_id..)). + This test ensure it does not crash if the child view is a primary view. + """ + View = self.env['ir.ui.view'] + + # Simulate layout views + base_view = View.create({ + 'name': 'Main Frontend Layout', + 'type': 'qweb', + 'arch': '<t t-call="web.layout"><t t-set="head_website"/></t>', + 'key': '_portal.frontend_layout', + }).with_context(load_all_views=True) + + inherit_view = View.create({ + 'name': 'Main layout', + 'mode': 'extension', + 'inherit_id': base_view.id, + 'arch': '<xpath expr="//t[@t-set=\'head_website\']" position="replace"><t t-call-assets="web_editor.summernote" t-js="false" groups="website.group_website_publisher"/></xpath>', + 'key': '_website.layout', + }) + + # Trigger cow on website_sale hierarchy for website 1 + base_view.with_context(website_id=1).write({'name': 'Main Frontend Layout (W1)'}) + + # Simulate website_sale_comparison install, that's the real test, it + # should not crash. + View._load_records([dict(xml_id='_website_forum.layout', values={ + 'name': 'Forum Layout', + 'mode': 'primary', + 'inherit_id': inherit_view.id, + 'arch': '<xpath expr="//t[@t-call-assets=\'web_editor.summernote\'][@t-js=\'false\']" position="attributes"><attribute name="groups"/></xpath>', + 'key': '_website_forum.layout', + })]) + def test_multiple_inherit_level(self): """ Test multi-level inheritance: Base |
