From 4f6ec1cd2a9253bb0c6c17d304490c7809facf8a Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Sun, 12 Aug 2018 22:40:50 +0200 Subject: [IMP] website,*: support multiple websites This implements support to administer multiple websites. Although the core functionality already existed, managing multiple websites was fairly technical. In the interest of database updates and migration this attempts to keep duplicated data to a minimum. To do this the usual generic records are rendered unless some website-specific record exists that replaces it. Copy-on-write (COW) is used to create these website-specific records. Through this mechanism creating a website-specific record is delayed until necessary. A COW mechanism has been implemented on 4 models: ir.ui.view, website.page, website.menu and ir.attachment. These COW mechanisms are activated when editing data through the website (aka frontend). These frontend edits (e.g. with web_editor) will be website-specific, possibly creating a website-specific record when necessary. When editing data in the backend nothing special will happen, even when editing a generic record. Note that because of this mechanism also facilitates the ability to create new, uncustomized websites because the generic data is kept. Support is provided for a website to have any theme. Themes are fairly complex to handle. Standalone themes can depend on other standalone themes (e.g. theme_beauty depends on theme_loftspace) and themes usually modify some data of the themes they depend on. Because a theme can be installed on multiple websites, using website_id m2o fields does not work well. It would require duplicate data, making updates and migration harder. Because of this, data for themes (ir.ui.view and ir.attachment specifically) have a theme_id m2o. website has a theme_ids m2m that identifies all theme modules currently installed on it. Through these fields we figure out what to render. A theme is only fully uninstalled when it's no longer active on any website. The advantage of this approach is that upgrading or migrating theme data is no different from the single-website case. The website.published.mixin class was modified to handle multiple websites. A wizard was added in the backend to easily manage this for multiple website. Although not used anywhere in this commit, a 'website_id' variable has been added in the evaluation context of ir.rule. It allows to easily make any model multi-website aware, all that's needed is a custom website_id m2o field on a model and a custom record rule. --- addons/website/static/src/js/backend/dashboard.js | 21 +++++++++++++++++++-- .../website/static/src/js/content/website_root.js | 18 ++++++++++++++++++ addons/website/static/src/js/menu/content.js | 13 ++++++++++++- addons/website/static/src/xml/website.backend.xml | 8 ++++++++ .../static/src/xml/website.pageProperties.xml | 19 +++++++++++++++++-- 5 files changed, 74 insertions(+), 5 deletions(-) (limited to 'addons/website/static/src') diff --git a/addons/website/static/src/js/backend/dashboard.js b/addons/website/static/src/js/backend/dashboard.js index 9ece194ab1e..393709b91db 100644 --- a/addons/website/static/src/js/backend/dashboard.js +++ b/addons/website/static/src/js/backend/dashboard.js @@ -64,6 +64,7 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, { return this._rpc({ route: '/website/fetch_dashboard_data', params: { + website_id: this.website_id || false, date_from: this.date_from.year()+'-'+(this.date_from.month()+1)+'-'+this.date_from.date(), date_to: this.date_to.year()+'-'+(this.date_to.month()+1)+'-'+this.date_to.date(), }, @@ -72,6 +73,7 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, { self.dashboards_data = result.dashboards; self.currency_id = result.currency_id; self.groups = result.groups; + self.websites = result.websites; }); }, @@ -245,6 +247,16 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, { }, + on_website_button: function(website_id) { + var self = this; + this.website_id = website_id; + $.when(this.fetch_data()).then(function() { + self.$('.o_website_dashboard').empty(); + self.render_dashboards(); + self.render_graphs(); + }); + }, + on_reverse_breadcrumb: function() { var self = this; web_client.do_push_state({}); @@ -293,10 +305,15 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, { this.$searchview = $(QWeb.render("website.DateRangeButtons", { widget: this, })); - this.$searchview.click('button.js_date_range', function(ev) { + this.$searchview.find('button.js_date_range').click(function(ev) { + self.$searchview.find('button.js_date_range.active').removeClass('active'); + $(ev.target).addClass('active'); self.on_date_range_button($(ev.target).data('date')); - $(this).find('button.js_date_range.active').removeClass('active'); + }); + this.$searchview.find('button.js_website').click(function(ev) { + self.$searchview.find('button.js_website.active').removeClass('active'); $(ev.target).addClass('active'); + self.on_website_button($(ev.target).data('website-id')); }); } this.update_control_panel({ diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js index 29163838f7a..162bd42c07b 100644 --- a/addons/website/static/src/js/content/website_root.js +++ b/addons/website/static/src/js/content/website_root.js @@ -40,6 +40,7 @@ var WebsiteRoot = BodyManager.extend({ 'click .js_publish_management .js_publish_btn': '_onPublishBtnClick', 'submit .js_website_submit_form': '_onWebsiteFormSubmit', 'click .js_disable_on_click': '_onDisableOnClick', + 'click .js_multi_website_switch': '_multiWebsiteSwitch', }), custom_events: _.extend({}, BodyManager.prototype.custom_events || {}, { animation_start_demand: '_onAnimationStartDemand', @@ -279,6 +280,23 @@ var WebsiteRoot = BodyManager.extend({ _onDisableOnClick: function (ev) { $(ev.currentTarget).addClass('disabled'); }, + + /** + * Called when clicking on the multi-website switcher. + * + * @param {OdooEvent} ev + */ + _multiWebsiteSwitch: function (ev) { + var website_id_to_switch_to = ev.target.getAttribute('website-id'); + this._rpc({ + route: '/website/set_session_website', + params: { + website_id: website_id_to_switch_to || false, + }, + }).then(function () { + window.location.reload(true); + }); + }, }); return { diff --git a/addons/website/static/src/js/menu/content.js b/addons/website/static/src/js/menu/content.js index 66679b5d20d..df4a2d0fe0d 100644 --- a/addons/website/static/src/js/menu/content.js +++ b/addons/website/static/src/js/menu/content.js @@ -145,6 +145,16 @@ var PagePropertiesDialog = weWidgets.Dialog.extend({ }); })); + defs.push(this._rpc({model: 'res.users', + method: 'has_group', + args: ['website.group_multi_website'], + context: context}) + .then(function (has_group) { + if (!has_group) { + self.$('#website_restriction').addClass('hidden'); + } + })); + var datepickersOptions = { minDate: moment({y: 1900}), maxDate: moment().add(200, 'y'), @@ -210,6 +220,7 @@ var PagePropertiesDialog = weWidgets.Dialog.extend({ is_menu: this.$('#is_menu').prop('checked'), is_homepage: this.$('#is_homepage').prop('checked'), website_published: this.$('#is_published').prop('checked'), + restrict_to_current_website: this.$('#restrict_to_current_website').prop('checked'), create_redirect: this.$('#create_redirect').prop('checked'), redirect_type: this.$('#redirect_type').val(), website_indexed: this.$('#is_indexed').prop('checked'), @@ -954,7 +965,7 @@ function _deletePage(pageId, fromPageManagement) { // Delete the page if the user confirmed return self._rpc({ model: 'website.page', - method: 'delete_page', + method: 'unlink', args: [pageId], context: context, }); diff --git a/addons/website/static/src/xml/website.backend.xml b/addons/website/static/src/xml/website.backend.xml index a1a0d24edb1..6bdb10f24c6 100644 --- a/addons/website/static/src/xml/website.backend.xml +++ b/addons/website/static/src/xml/website.backend.xml @@ -70,6 +70,14 @@ +
+ + + +
diff --git a/addons/website/static/src/xml/website.pageProperties.xml b/addons/website/static/src/xml/website.pageProperties.xml index 7f3b4cbfc64..39786f3449b 100644 --- a/addons/website/static/src/xml/website.pageProperties.xml +++ b/addons/website/static/src/xml/website.pageProperties.xml @@ -127,8 +127,23 @@ -
- +
+ + + +
+
+
-- cgit v1.2.3 From ff26b20a48e17966ffc72867b7342160c2766283 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 24 Jul 2018 11:02:40 +0200 Subject: [REF] website: small diff pep, renaming, make generic function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit should not change the behaviour in most cases. Co-authored-by: Derie Romain Co-authored-by: Kersten Jérémy --- addons/website/static/src/js/content/website_root.js | 2 +- addons/website/static/src/js/menu/content.js | 2 +- addons/website/static/src/scss/website.ui.scss | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/website/static/src') diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js index 162bd42c07b..0f3fff53dfc 100644 --- a/addons/website/static/src/js/content/website_root.js +++ b/addons/website/static/src/js/content/website_root.js @@ -289,7 +289,7 @@ var WebsiteRoot = BodyManager.extend({ _multiWebsiteSwitch: function (ev) { var website_id_to_switch_to = ev.target.getAttribute('website-id'); this._rpc({ - route: '/website/set_session_website', + route: '/website/force_website', params: { website_id: website_id_to_switch_to || false, }, diff --git a/addons/website/static/src/js/menu/content.js b/addons/website/static/src/js/menu/content.js index df4a2d0fe0d..d4fd2734c10 100644 --- a/addons/website/static/src/js/menu/content.js +++ b/addons/website/static/src/js/menu/content.js @@ -980,7 +980,7 @@ function _deletePage(pageId, fromPageManagement) { } websiteNavbarData.websiteNavbarRegistry.add(ContentMenu, '#content-menu'); -websiteRootData.websiteRootRegistry.add(PageManagement, '#edit_website_pages'); +websiteRootData.websiteRootRegistry.add(PageManagement, '#list_website_pages'); return { PagePropertiesDialog: PagePropertiesDialog, diff --git a/addons/website/static/src/scss/website.ui.scss b/addons/website/static/src/scss/website.ui.scss index 4b24667ed1f..b752157cf1c 100644 --- a/addons/website/static/src/scss/website.ui.scss +++ b/addons/website/static/src/scss/website.ui.scss @@ -463,7 +463,7 @@ body .modal { padding-top: 9px; } } -#edit_website_pages { +#list_website_pages { th { background-color: $o-brand-odoo; color: white; -- cgit v1.2.3 From a45bb90fac04e454e9792dfea82772227e963e17 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 24 Jul 2018 17:01:28 +0200 Subject: [IMP] website: improve pagemanager to be multi website compliant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now we can see which specific page override wich page when page are sorted by url. Co-authored-by: Derie Romain Co-authored-by: Kersten Jérémy --- addons/website/static/src/js/menu/content.js | 4 +-- addons/website/static/src/scss/website.ui.scss | 16 ++++++--- .../static/src/xml/website.pageProperties.xml | 38 +++++++++++----------- 3 files changed, 33 insertions(+), 25 deletions(-) (limited to 'addons/website/static/src') diff --git a/addons/website/static/src/js/menu/content.js b/addons/website/static/src/js/menu/content.js index d4fd2734c10..bcb46553b65 100644 --- a/addons/website/static/src/js/menu/content.js +++ b/addons/website/static/src/js/menu/content.js @@ -81,7 +81,7 @@ var PagePropertiesDialog = weWidgets.Dialog.extend({ defs.push(this._rpc({ model: 'website.page', method: 'get_page_info', - args: [this.page_id, context.website_id], + args: [this.page_id], context: context, }).then(function (page) { page[0].url = _.str.startsWith(page[0].url, '/') ? page[0].url.substring(1) : page[0].url; @@ -220,7 +220,7 @@ var PagePropertiesDialog = weWidgets.Dialog.extend({ is_menu: this.$('#is_menu').prop('checked'), is_homepage: this.$('#is_homepage').prop('checked'), website_published: this.$('#is_published').prop('checked'), - restrict_to_current_website: this.$('#restrict_to_current_website').prop('checked'), + share_page_info: this.$('#share_page_info').prop('checked'), create_redirect: this.$('#create_redirect').prop('checked'), redirect_type: this.$('#redirect_type').val(), website_indexed: this.$('#is_indexed').prop('checked'), diff --git a/addons/website/static/src/scss/website.ui.scss b/addons/website/static/src/scss/website.ui.scss index b752157cf1c..a7be7e98290 100644 --- a/addons/website/static/src/scss/website.ui.scss +++ b/addons/website/static/src/scss/website.ui.scss @@ -468,11 +468,19 @@ body .modal { background-color: $o-brand-odoo; color: white; } - td > a.fa { - margin-left: 5px; - color: $o-brand-odoo; + td, th { + padding: 0.45rem; + } + td { + > a.fa { + margin-left: 5px; + color: $o-brand-odoo; + } + .text-muted { + opacity: 0.5; + } } .fa-check, .fa-eye-slash { - color: $o-brand-primary; + color: #00a09d; } } diff --git a/addons/website/static/src/xml/website.pageProperties.xml b/addons/website/static/src/xml/website.pageProperties.xml index 39786f3449b..7ac590cda2f 100644 --- a/addons/website/static/src/xml/website.pageProperties.xml +++ b/addons/website/static/src/xml/website.pageProperties.xml @@ -88,26 +88,26 @@
-
- -
+
+ +
-
- -
+
+ +
-
-
-
- -
+
+ +
-
+
-
- -
+ +
-- cgit v1.2.3 From 602807acdf20ff4f75a1abb7f5fa1be4db3f532d Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 24 Jul 2018 17:01:44 +0200 Subject: [FIX] website: improve/fix menu, copy on unlink, clone page, unique_path, sale_report, ... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-authored-by: Kersten Jérémy --- addons/website/static/src/js/content/menu.js | 2 +- addons/website/static/src/js/content/website_root.js | 2 +- addons/website/static/src/js/menu/content.js | 2 +- addons/website/static/src/js/widgets/theme.js | 3 +-- addons/website/static/src/scss/website.ui.scss | 2 +- addons/website/static/src/xml/website.backend.xml | 4 ++-- addons/website/static/src/xml/website.pageProperties.xml | 16 ++++++++-------- 7 files changed, 15 insertions(+), 16 deletions(-) (limited to 'addons/website/static/src') diff --git a/addons/website/static/src/js/content/menu.js b/addons/website/static/src/js/content/menu.js index 6effb471ec9..3511f51a70f 100644 --- a/addons/website/static/src/js/content/menu.js +++ b/addons/website/static/src/js/content/menu.js @@ -67,7 +67,7 @@ sAnimation.registry.affixMenu = sAnimation.Class.extend({ // Reset opened menus this.$dropdowns.removeClass('show'); - this.$navbarCollapses.removeClass('in').attr('aria-expanded', false); + this.$navbarCollapses.removeClass('show').attr('aria-expanded', false); }, }); diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js index 0f3fff53dfc..a51c8011e92 100644 --- a/addons/website/static/src/js/content/website_root.js +++ b/addons/website/static/src/js/content/website_root.js @@ -287,7 +287,7 @@ var WebsiteRoot = BodyManager.extend({ * @param {OdooEvent} ev */ _multiWebsiteSwitch: function (ev) { - var website_id_to_switch_to = ev.target.getAttribute('website-id'); + var website_id_to_switch_to = ev.currentTarget.getAttribute('website-id'); this._rpc({ route: '/website/force_website', params: { diff --git a/addons/website/static/src/js/menu/content.js b/addons/website/static/src/js/menu/content.js index bcb46553b65..91494a4018b 100644 --- a/addons/website/static/src/js/menu/content.js +++ b/addons/website/static/src/js/menu/content.js @@ -542,7 +542,7 @@ var EditMenuDialog = weWidgets.Dialog.extend({ this._rpc({ model: 'website.menu', method: 'save', - args: [[context.website_id], { data: data, to_delete: self.to_delete }], + args: [context.website_id, { data: data, to_delete: self.to_delete }], context: context, }).then(function () { return _super(); diff --git a/addons/website/static/src/js/widgets/theme.js b/addons/website/static/src/js/widgets/theme.js index 50434604677..ce73fd35d3d 100644 --- a/addons/website/static/src/js/widgets/theme.js +++ b/addons/website/static/src/js/widgets/theme.js @@ -55,7 +55,6 @@ var ThemeCustomizeDialog = Dialog.extend({ */ start: function () { var self = this; - this._generateDialogHTML(); this.$modal.addClass('o_theme_customize_modal'); @@ -77,7 +76,7 @@ var ThemeCustomizeDialog = Dialog.extend({ this._loadViews() ); }, - + //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- diff --git a/addons/website/static/src/scss/website.ui.scss b/addons/website/static/src/scss/website.ui.scss index a7be7e98290..f146b3de677 100644 --- a/addons/website/static/src/scss/website.ui.scss +++ b/addons/website/static/src/scss/website.ui.scss @@ -38,7 +38,7 @@ body.o_connected_user { } } .o_menu_systray { - a { + > li > a { padding: 0 $grid-gutter-width/2; &.css_edit_dynamic{ diff --git a/addons/website/static/src/xml/website.backend.xml b/addons/website/static/src/xml/website.backend.xml index 6bdb10f24c6..5508d4be9d9 100644 --- a/addons/website/static/src/xml/website.backend.xml +++ b/addons/website/static/src/xml/website.backend.xml @@ -70,9 +70,9 @@
-
+
- diff --git a/addons/website/static/src/xml/website.pageProperties.xml b/addons/website/static/src/xml/website.pageProperties.xml index 7ac590cda2f..cf4719d5951 100644 --- a/addons/website/static/src/xml/website.pageProperties.xml +++ b/addons/website/static/src/xml/website.pageProperties.xml @@ -45,7 +45,7 @@
-
+
@@ -88,7 +88,7 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-- cgit v1.2.3 From 8300155cd6133e0b8496cf4505081a1626e6f0aa Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Mon, 13 Aug 2018 18:41:58 +0200 Subject: [IMP] website: res_config_setting make most key website specific MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit google analytics, google map api key, ... can be set by website Remove useless duplicated label Co-authored-by: Derie Romain Co-authored-by: Kersten Jérémy --- addons/website/static/src/scss/website.ui.scss | 2 +- addons/website/static/src/xml/website.backend.xml | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'addons/website/static/src') diff --git a/addons/website/static/src/scss/website.ui.scss b/addons/website/static/src/scss/website.ui.scss index f146b3de677..eb459ee1503 100644 --- a/addons/website/static/src/scss/website.ui.scss +++ b/addons/website/static/src/scss/website.ui.scss @@ -481,6 +481,6 @@ body .modal { } } .fa-check, .fa-eye-slash { - color: #00a09d; + color: $info; } } diff --git a/addons/website/static/src/xml/website.backend.xml b/addons/website/static/src/xml/website.backend.xml index 5508d4be9d9..b4f2b9c6029 100644 --- a/addons/website/static/src/xml/website.backend.xml +++ b/addons/website/static/src/xml/website.backend.xml @@ -53,12 +53,14 @@ @@ -72,7 +74,7 @@
- -- cgit v1.2.3 From 066cfc9598a307a48b86104f4bf861a58de09b41 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Wed, 25 Jul 2018 16:51:50 +0200 Subject: [IMP] website_[blog|event|forum|sale|slide]: make website specific MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set up env & tools for module website multiwebsite (blog, event, sale..) website_id in modelConverter and ir_rule add _compute_domain_keys to have a different cache per website or rules would not be correctly website_dependant eg: blog 1 on website 1, blog 2 on website 2 access blog 1 from website 1 => can access -> normal access blog 1 from website 2 => can access -> should crash because (ir rule) split mixing website.published.mixin and website.published.multi.mixin to have website_id only on last one. multi mixing will: - override website_published compute to take current_website into account (not in backend) - force website when clicking on published in backend - website blog, website_sale, website_event, website_forum, website_slides are now multi website Co-authored-by: Derie Romain Co-authored-by: Kersten Jérémy --- addons/website/static/src/js/backend/dashboard.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/website/static/src') diff --git a/addons/website/static/src/js/backend/dashboard.js b/addons/website/static/src/js/backend/dashboard.js index 393709b91db..b4fe22ba84e 100644 --- a/addons/website/static/src/js/backend/dashboard.js +++ b/addons/website/static/src/js/backend/dashboard.js @@ -112,6 +112,7 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, { return this._rpc({ route: '/website/dashboard/set_ga_data', params: { + 'website_id': self.website_id, 'ga_client_id': ga_client_id, 'ga_analytics_key': ga_analytics_key, }, -- cgit v1.2.3