From b85bd358234684974f9af63bc5f28cfabb527767 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 17 Oct 2017 11:11:34 +0200 Subject: [PATCH 1/4] [FIX] web_editor: fixed issue of chrome triple click Partial backport of 11.0 commit (https://github.com/odoo/odoo/commit/6ad2ae30354a77c0f898cb9cb5a859713061d71a) to solve issue 774152. Note: it has to be forward-ported as implementation has been improved to handle mass mailing cases. When an user triple-clicked on a paragraph and then typed text, the paragraph was removed instead of its content (so the new text was added at the beginning of the next paragraph). See: http://stackoverflow.com/questions/38467334/why-does-google-chrome-always-add-space-after-selected-text --- addons/web_editor/static/src/js/rte.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js index 8eef4cfe3a6..37b87553506 100644 --- a/addons/web_editor/static/src/js/rte.js +++ b/addons/web_editor/static/src/js/rte.js @@ -586,6 +586,28 @@ var RTE = Widget.extend({ setTimeout(function () { self.historyRecordUndo($target, 'activate', true); },0); + + // To Fix Google Chrome Tripleclick Issue, which selects the ending + // whitespace characters (so Tripleclicking then typing text will remove + // the whole paragraph instead of its content). + // http://stackoverflow.com/questions/38467334/why-does-google-chrome-always-add-space-after-selected-text + if ($.browser.chrome === true && event.originalEvent.detail === 3) { + var currentSelection = range.create(); + if (currentSelection.sc.parentNode === currentSelection.ec) { + _selectSC(currentSelection); + } else if (currentSelection.eo === 0) { + var $hasNext = $(currentSelection.sc).parent(); + while (!$hasNext.next().length && !$hasNext.is('body')) { + $hasNext = $hasNext.parent(); + } + if ($hasNext.next()[0] === currentSelection.ec) { + _selectSC(currentSelection); + } + } + } + function _selectSC(selection) { + range.create(selection.sc, selection.so, selection.sc, selection.sc.length).select(); + } }, editable: function () { From 9ae78328ec6fa0c1ba5c0a5f7583a565c7fa4e3f Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Thu, 31 Aug 2017 14:38:23 +0200 Subject: [PATCH 2/4] [FIX] fields: writing on a one2many with a domain should not remove all lines Specifically, the command `(6, 0, ids)` should only unlink/detach the lines that satisfy to the field's domain. Test from #18440 opw-756983 Closes #18438 Closes #18440 --- .../test_new_api/tests/test_new_fields.py | 24 +++++++++++++++++++ openerp/osv/fields.py | 9 +++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/openerp/addons/test_new_api/tests/test_new_fields.py b/openerp/addons/test_new_api/tests/test_new_fields.py index fe118ba44ca..6ac223bd458 100644 --- a/openerp/addons/test_new_api/tests/test_new_fields.py +++ b/openerp/addons/test_new_api/tests/test_new_fields.py @@ -528,6 +528,30 @@ class TestNewFields(common.TransactionCase): self.assertFalse(discussion.very_important_messages) self.assertFalse(message.exists()) + def test_70_x2many_write(self): + discussion = self.env.ref('test_new_api.discussion_0') + Message = self.env['test_new_api.message'] + # There must be 3 messages, 0 important + self.assertEqual(len(discussion.messages), 3) + self.assertEqual(len(discussion.important_messages), 0) + self.assertEqual(len(discussion.very_important_messages), 0) + discussion.important_messages = [(0, 0, { + 'body': 'What is the answer?', + 'important': True, + })] + # There must be 4 messages, 1 important + self.assertEqual(len(discussion.messages), 4) + self.assertEqual(len(discussion.important_messages), 1) + self.assertEqual(len(discussion.very_important_messages), 1) + discussion.very_important_messages |= Message.new({ + 'body': '42', + 'important': True, + }) + # There must be 5 messages, 2 important + self.assertEqual(len(discussion.messages), 5) + self.assertEqual(len(discussion.important_messages), 2) + self.assertEqual(len(discussion.very_important_messages), 2) + class TestMagicFields(common.TransactionCase): diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index b451da449e6..99a51c4e79b 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -861,8 +861,13 @@ class one2many(_column): # Must use write() to recompute parent_store structure if needed obj.write(cr, user, act[2], {self._fields_id:id}, context=context or {}) ids2 = act[2] or [0] - cr.execute('select id from '+_table+' where '+self._fields_id+'=%s and id <> ALL (%s)', (id,ids2)) - ids3 = map(lambda x:x[0], cr.fetchall()) + # if the o2m has a static domain we must respect it when unlinking + domain = (self._domain(original_obj) + if callable(self._domain) else self._domain) + extra_domain = domain or [] + ids3 = obj.search(cr, user, [(self._fields_id,'=',id), ('id','not in',ids2)] + extra_domain, context=context) + # If the model has cascade deletion, we delete the rows because it is the intended behavior, + # otherwise we only nullify the reverse foreign key column. inverse_field = obj._fields.get(self._fields_id) if getattr(inverse_field, "ondelete", None) == "cascade": obj.unlink(cr, user, ids3, context=context) From 6e46ba7b460b5f155735c91f957a4dca3dec8f96 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Tue, 17 Oct 2017 15:19:31 +0200 Subject: [PATCH 3/4] [FIX] point_of_sale: fix taxes rounding in POS Don't round the base amount at each step during compute_all of taxes. -opw: 776986 --- addons/point_of_sale/static/src/js/models.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index a18bd707da6..43c375937ed 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1407,7 +1407,7 @@ exports.Orderline = Backbone.Model.extend({ var recompute_base = function(base_amount, fixed_amount, percent_amount){ if(fixed_amount === 0.0 && percent_amount === 0.0) return base_amount; - return round_pr((base_amount - fixed_amount) / (1.0 + percent_amount / 100.0), currency_rounding); + return (base_amount - fixed_amount) / (1.0 + percent_amount / 100.0); } // 4) Iterate the taxes in the reversed sequence order to retrieve the initial base of the computation. @@ -1461,7 +1461,6 @@ exports.Orderline = Backbone.Model.extend({ taxes_vals.push(tax_vals); }); - return { taxes: taxes_vals, total_excluded: round_pr(total_excluded, currency_rounding_bak), From e0fbe7b5becf608f76f02123f3076cf27c54c20e Mon Sep 17 00:00:00 2001 From: rde Date: Mon, 16 Oct 2017 14:19:19 +0200 Subject: [PATCH 4/4] [FIX] website_sale: disable checkout btn if GTS unchecked at load opw-774286 *Before this commit: On checkout, you can enable a step to force user to have the General Terms of Sale checked to continue the checkout. Checking/Unchecking will correctly disabled/enabled the button. The checkbox is already checked at page load (on the template). BUT, if the template has been modified to set the checkbox as unchecked at load (eg the user removed 'checked="checked"' from the template), the button will still be enabled even if the checkbox is unchecked. *Now: No matter if it is checked or not on the template, the button will correctly be enabled/disabled regarding the checkbox state at load. --- addons/website_sale/static/src/js/website_sale_payment.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/static/src/js/website_sale_payment.js b/addons/website_sale/static/src/js/website_sale_payment.js index 5b02f5b7c61..266c69a9db5 100644 --- a/addons/website_sale/static/src/js/website_sale_payment.js +++ b/addons/website_sale/static/src/js/website_sale_payment.js @@ -6,9 +6,10 @@ var ajax = require('web.ajax'); $(document).ready(function () { // If option is enable if ($("#checkbox_cgv").length) { - $("#checkbox_cgv").click(function() { + $("#checkbox_cgv").change(function() { $("div.oe_sale_acquirer_button").find('input, button').prop("disabled", !this.checked); }); + $('#checkbox_cgv').trigger('change'); } // When choosing an acquirer, display its Pay Now button