From ac170e8a8238a9b0aa468f83b11aabc4cd9493de Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 19 Jul 2019 14:50:15 +0000 Subject: [PATCH 1/7] [FIX] web_editor, website: stop snippet animations before cloning Before this commit, when a snippet was cloned, its animation was not destroyed first. The flow was: 1. Clone the snippet (DOM) - web_editor trigger `snippet_cloned` 2. Start cloned snippet animation - website listen `snippet_cloned` This was causing bugs, eg facebook snippet for which the animation is to create an iframe containing the facebook widget. When cloning this snippet, its iframe would be cloned to, then its animation would be started, creating another iframe. To fix such flows, the snippet cloning flow should be: 1. Strop the snippet animation 2. Clone the snippet (DOM) - web_editor trigger `snippet_cloned` 3. Start cloned snippet animation - website listen `snippet_cloned` 4. Restart the original snippet animation task-1951466 closes odoo/odoo#35029 Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/editor/snippets.editor.js | 5 +++- .../static/src/js/content/website_root.js | 1 + addons/website/static/src/js/menu/edit.js | 23 ++++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 11a96897fa6..803a190256f 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -337,6 +337,9 @@ var SnippetEditor = Widget.extend({ */ _onCloneClick: function (ev) { ev.preventDefault(); + + this.trigger_up('snippet_will_be_cloned', {$target: this.$target}); + var $clone = this.$target.clone(false); this.trigger_up('request_history_undo_record', {$target: this.$target}); @@ -352,7 +355,7 @@ var SnippetEditor = Widget.extend({ } }, }); - this.trigger_up('snippet_cloned', {$target: $clone}); + this.trigger_up('snippet_cloned', {$target: $clone, $origin: this.$target}); }, /** * Called when the overlay dimensions/positions should be recomputed. diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js index ab1de2ea357..dee89b8be1b 100644 --- a/addons/website/static/src/js/content/website_root.js +++ b/addons/website/static/src/js/content/website_root.js @@ -43,6 +43,7 @@ var WebsiteRoot = BodyManager.extend({ }), custom_events: _.extend({}, BodyManager.prototype.custom_events || {}, { animation_start_demand: '_onAnimationStartDemand', + animation_stop_demand: '_onAnimationStopDemand', ready_to_clean_for_save: '_onAnimationStopDemand', }), diff --git a/addons/website/static/src/js/menu/edit.js b/addons/website/static/src/js/menu/edit.js index c42e2196887..3b7803e8d56 100644 --- a/addons/website/static/src/js/menu/edit.js +++ b/addons/website/static/src/js/menu/edit.js @@ -17,6 +17,7 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ custom_events: _.extend({}, websiteNavbarData.WebsiteNavbarActionWidget.custom_events || {}, { content_will_be_destroyed: '_onContentWillBeDestroyed', content_was_recreated: '_onContentWasRecreated', + snippet_will_be_cloned: '_onSnippetWillBeCloned', snippet_cloned: '_onSnippetCloned', snippet_dropped: '_onSnippetDropped', }), @@ -111,9 +112,22 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ $target: ev.data.$target, }); }, + /** + * Called when a snippet is about to be cloned in the page. Notifies the + * WebsiteRoot that is should destroy the animations for this snippet. + * + * @private + * @param {OdooEvent} ev + */ + _onSnippetWillBeCloned: function (ev) { + this.trigger_up('animation_stop_demand', { + $target: ev.data.$target, + }); + }, /** * Called when a snippet is cloned in the page. Notifies the WebsiteRoot - * that is should start the animations for this snippet. + * that is should start the animations for this snippet and the snippet it + * was cloned from. * * @private * @param {OdooEvent} ev @@ -123,6 +137,13 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ editableMode: true, $target: ev.data.$target, }); + // TODO: remove in saas-12.5, undefined $origin will restart #wrapwrap + if (ev.data.$origin) { + this.trigger_up('animation_start_demand', { + editableMode: true, + $target: ev.data.$origin, + }); + } }, /** * Called when a snippet is dropped in the page. Notifies the WebsiteRoot From fb9caab7c1352c8181c08343e1374b96aa29d1e4 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Mon, 22 Jul 2019 11:40:49 +0000 Subject: [PATCH 2/7] [FIX] website_quote: negative discounts are always included in the display price Before this commit, negative discounts (surcharges) were shown in the sales order when the price list have the option : "Show public price & discount to the customer". Now, the negative discounts are included in the display price. This issue was already been addressed in the sales module (see https://github.com/odoo/odoo/blob/ac170e8a8238a9b0aa468f83b11aabc4cd9493de/addons/sale/models/sale.py#L1046) Fine-tunning of : cae506f0ed26625f99ab1614f90e45e7ac72c205 opw-2039071 closes odoo/odoo#35065 Signed-off-by: Jorge Pinna Puissant (jpp) --- addons/website_quote/models/sale_order.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/website_quote/models/sale_order.py b/addons/website_quote/models/sale_order.py index 8d8931cd01c..69199f1c8ef 100644 --- a/addons/website_quote/models/sale_order.py +++ b/addons/website_quote/models/sale_order.py @@ -122,7 +122,11 @@ class SaleOrder(models.Model): price = self.pricelist_id.with_context(uom=line.product_uom_id.id).get_product_price(line.product_id, line.product_uom_qty, False) if self.pricelist_id.discount_policy == 'without_discount' and line.price_unit: discount = (line.price_unit - price) / line.price_unit * 100 - price = line.price_unit + # negative discounts (= surcharge) are included in the display price + if discount < 0: + discount = 0 + else: + price = line.price_unit else: price = line.price_unit From 041ec73b2c7559d22d00518aaa1aac25f61dbe7d Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 22 Jul 2019 13:11:30 +0000 Subject: [PATCH 3/7] [FIX] doc: complete tale about two profilers This section of log mentionned two profilers making think they were the same. The odoo/tools/misc.py `profile` logs a method calls inside a file that can be used to generate a graph of method calls. The odoo/tools/profiler.py `profile` logs a method lines calls, queries and time spend inside the log. fixes #31278 opw-2038941 closes #35074 Signed-off-by: Nicolas Lempereur (nle) --- doc/howtos/profilecode.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/howtos/profilecode.rst b/doc/howtos/profilecode.rst index ed6d2640648..d21c1f3891c 100644 --- a/doc/howtos/profilecode.rst +++ b/doc/howtos/profilecode.rst @@ -17,7 +17,7 @@ its sub-called methods. .. code:: python - from odoo.tools.profiler import profile + from odoo.tools.misc import profile [...] @profile('/temp/prof.profile') @api.multi @@ -37,10 +37,15 @@ A tool called *xdot* will display the resulting graph: xdot /temp/prof.xdot -The profiler can be also used without saving data in a file: +Log a method +============ + +Another profiler can be used to log statistics on a method: .. code:: python + from odoo.tools.profiler import profile + [...] @profile @api.model def mymethod(...): From bdfed675044e5e7b65621ae875392395076a0108 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Mon, 22 Jul 2019 11:54:27 +0000 Subject: [PATCH 4/7] [FIX] website_quote: Show 'Unit Price' column from quote template line Before this commit, the unit price of the quote template line were hidden. Now, the unit price are shown. This is necessary because the unit price is used if : - the template is selected before the customer (price_list) is selected. - the price_list is "Show public price & discount to the customer" This commit revert 9416483465d749749a24838ba4c5ea154633bf6d opw-2039071 closes odoo/odoo#35069 Signed-off-by: Yannick Tivisse (yti) --- addons/website_quote/views/sale_quote_views.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/website_quote/views/sale_quote_views.xml b/addons/website_quote/views/sale_quote_views.xml index 88af719f528..7762620d72c 100644 --- a/addons/website_quote/views/sale_quote_views.xml +++ b/addons/website_quote/views/sale_quote_views.xml @@ -49,7 +49,7 @@ - +