diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index bda14f6b089..22a4a4d66f5 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -260,11 +260,13 @@ class account_payment(models.Model): self.partner_type = 'customer' elif self.payment_type == 'outbound': self.partner_type = 'supplier' + else: + self.partner_type = False # Set payment method domain res = self._onchange_journal() if not res.get('domain', {}): res['domain'] = {} - res['domain']['journal_id'] = self.payment_type == 'inbound' and [('at_least_one_inbound', '=', True)] or [('at_least_one_outbound', '=', True)] + res['domain']['journal_id'] = self.payment_type == 'inbound' and [('at_least_one_inbound', '=', True)] or self.payment_type == 'outbound' and [('at_least_one_outbound', '=', True)] or [] res['domain']['journal_id'].append(('type', 'in', ('bank', 'cash'))) return res diff --git a/addons/pad/models/pad.py b/addons/pad/models/pad.py index 65a8bf5bc5f..0be7050db21 100644 --- a/addons/pad/models/pad.py +++ b/addons/pad/models/pad.py @@ -124,7 +124,7 @@ class PadCommon(models.AbstractModel): myPad.setText(path, (html2plaintext(vals[field.pad_content_field]).encode('utf-8'))) # Update the `pad_content_field` if the pad is modified for k, v in vals.items(): - field = self._fields[k] + field = self._fields.get(k) if hasattr(field, 'pad_content_field'): vals[field.pad_content_field] = self.pad_get_content(v) diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index b6b9553a875..27cdbcaf8b1 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -87,13 +87,11 @@ class AccountInvoice(models.Model): self.purchase_id = False return {} - @api.onchange('currency_id', 'date_invoice') + @api.onchange('currency_id') def _onchange_currency_id(self): if self.currency_id: for line in self.invoice_line_ids.filtered(lambda r: r.purchase_line_id): - if line.purchase_id.currency_id != self.currency_id: - line.price_unit = line.purchase_id.currency_id.with_context(date=self.date_invoice)\ - .compute(line.purchase_line_id.price_unit, self.currency_id, round=False) + line.price_unit = line.purchase_id.currency_id.with_context(date=self.date_invoice).compute(line.purchase_line_id.price_unit, self.currency_id, round=False) @api.onchange('invoice_line_ids') def _onchange_origin(self): diff --git a/addons/web_editor/static/src/js/base.js b/addons/web_editor/static/src/js/base.js index ac36b706f50..f7ba58ac636 100644 --- a/addons/web_editor/static/src/js/base.js +++ b/addons/web_editor/static/src/js/base.js @@ -32,14 +32,13 @@ data.dom_ready = dom_ready; var all_ready; data.ready = function () { if (!all_ready) { - all_ready = $.when(dom_ready, ajax.loadXML()); + all_ready = dom_ready; if (!odoo._modules) { - all_ready.then(load_translations); + all_ready = all_ready.then(load_translations); } - } else { // can add async template - all_ready = $.when(dom_ready, ajax.loadXML()); } - return all_ready; + // also load new templates since previous ready call + return $.when(all_ready, ajax.loadXML()); }; function load_translations() { diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js index 9ce1e5fb255..595602d6305 100644 --- a/addons/web_editor/static/src/js/rte.js +++ b/addons/web_editor/static/src/js/rte.js @@ -280,7 +280,15 @@ var RTE = Widget.extend({ } else { rng = $editable.data('range') || rng; } - rng.select(); + try { + // TODO this line might break for unknown reasons. I suppose that + // the created range is an invalid one. As it might be tricky to + // adapt that line and that it is not a critical one, temporary fix + // is to ignore the errors that this generates. + rng.select(); + } catch (e) { + console.log('error', e); + } history.recordUndo($editable, event, internal_history); }, /** @@ -567,8 +575,8 @@ var RTE = Widget.extend({ onEnableEditableArea: function ($editable) { }, - onMouseup: function (event) { - var $target = $(event.target); + onMouseup: function (ev) { + var $target = $(ev.target); var $editable = $target.closest('.o_editable'); if (!$editable.length) { @@ -580,26 +588,16 @@ var RTE = Widget.extend({ self.historyRecordUndo($target, 'activate', true); }); - // 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(); + // Browsers select different content from one to another after a + // triple click (especially: if triple-clicking on a paragraph on + // Chrome, blank characters of the element following the paragraph are + // selected too) + // + // The triple click behavior is reimplemented for all browsers here + if (ev.originalEvent.detail === 3) { + // Select the whole content inside the deepest DOM element that was + // triple-clicked + range.create(ev.target, 0, ev.target, ev.target.childNodes.length).select(); } }, diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js index 5f28c9510bb..b8f3198dae2 100644 --- a/addons/web_editor/static/src/js/rte.summernote.js +++ b/addons/web_editor/static/src/js/rte.summernote.js @@ -422,6 +422,9 @@ dom.isImg = function (node) { }; var fn_is_forbidden_node = dom.isForbiddenNode || function () {}; dom.isForbiddenNode = function (node) { + if (node.tagName === "BR") { + return false; + } return fn_is_forbidden_node(node) || $(node).is(".media_iframe_video"); }; var fn_is_img_font = dom.isImgFont || function () {}; diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index 35e49346ee0..a3e3db42a71 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -703,10 +703,16 @@ dom.isRemovableEmptyNode = function (node) { dom.isForbiddenNode = function (node) { return node.tagName === "BR" || $(node).is(".fa, img"); }; -dom.listBetween = function (sc, ec) { +/** + * @todo 'so' and 'eo' were added as a bugfix and are not given everytime. They + * however should be as the function may be wrong without them (for example, + * when asking the list between an element and its parent, as there is no path + * from the beginning of the former to the beginning of the later). + */ +dom.listBetween = function (sc, ec, so, eo) { var nodes = []; var ancestor = dom.commonAncestor(sc, ec); - dom.walkPoint({'node': sc, 'offset': 0}, {'node': ec, 'offset': 0}, function (point) { + dom.walkPoint({'node': sc, 'offset': so || 0}, {'node': ec, 'offset': eo || 0}, function (point) { if (ancestor !== point.node || ancestor === sc || ancestor === ec) { nodes.push(point.node); } @@ -1926,7 +1932,7 @@ $.summernote.pluginEvents.formatBlock = function (event, editor, layoutInfo, sTa } // fix by odoo because if you select a style in a li with no p tag all the ul is wrapped by the style tag - var nodes = dom.listBetween(r.sc, r.ec); + var nodes = dom.listBetween(r.sc, r.ec, r.so, r.eo); for (var i=0; i