From b2b71efb365b08677fb6fa0cd83f4adec28c8da8 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Sat, 20 Jan 2018 21:17:25 +0100 Subject: [PATCH 1/8] [BACKPORT] website: translation if website default lang is not en_US Before this commit: When website default lang was not en_US, the translation of fields* in the web_editor would not be saved correctly. Let's illustrate with fr_BE set as main lang: The web_editor's RPC calls does not send language in the context when editing a page (6ebcc06), but it does in translation mode. Note that editing is always performed in the website main lang, fr_BE in this case. Therefore: 1. When EDITING: The backend suppose the language is en_US as there is no lang in the context (hardcoded everywhere). It then write in the record itself instead of the ir.translation as it should since fr_BE is a translation. (In Odoo, every lang is a translation, en_US is always the main lang) 2. When TRANSLATING (in en_US): It would also write on model as the web_editor send the language to the backend when in translate mode. But since en_US is recognized as the main lang (which is correct), it also writes in the model, overriding the incorrect fr_BE writing which was also wrote on the model. This has been fixed in 10.0 with these 2 commits: 036ccbe 2955bf2 With these fixes, the lang is correctly added (by the backend) if the website module is installed. By ensuring the lang is correctly set, the ORM _write() function will process the edition and translation datas as it should: - If it receive en_US, it will write on the model - If it receive another lang, it will write on ir.translation This closes #10883, closes #22403 *Not the HTML/XML fields which are handled differently by the ORM/translation --- addons/web_editor/models/ir_ui_view.py | 6 ++++++ addons/website/models/ir_ui_view.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/addons/web_editor/models/ir_ui_view.py b/addons/web_editor/models/ir_ui_view.py index dd7501c44f9..0f326f2e19a 100644 --- a/addons/web_editor/models/ir_ui_view.py +++ b/addons/web_editor/models/ir_ui_view.py @@ -35,12 +35,18 @@ class view(osv.osv): def extract_embedded_fields(self, cr, uid, arch, context=None): return arch.xpath('//*[@data-oe-model != "ir.ui.view"]') + + def get_default_lang_code(self, cr, uid, context=None): + return False + def save_embedded_field(self, cr, uid, el, context=None): Model = self.pool[el.get('data-oe-model')] field = el.get('data-oe-field') converter = self.pool['ir.qweb'].get_converter_for(el.get('data-oe-type')) value = converter.from_html(cr, uid, Model, Model._fields[field], el) + if context and not context.get('lang'): + context['lang'] = self.get_default_lang_code(cr, uid, context=context) if value is not None: # TODO: batch writes? diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 4df13b22c85..01246baaf01 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -228,3 +228,10 @@ class view(osv.osv): 'active': v.active, }) return result + + def get_default_lang_code(self, cr, uid, context): + website_id = context['website_id'] + if website_id: + return self.pool['website'].browse(cr, uid, website_id, context=context).default_lang_code + else: + return super(view, self).get_default_lang_code(cr, uid, context=context) From 32a7a1ed09515edc3daefe0b9ad0b2782998fa66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Ru=CC=88bner?= Date: Thu, 11 Feb 2016 15:19:33 +0100 Subject: [PATCH 2/8] [FIX] website: do_not_show option in translator dialog not working Before this commit, it would do the opposite of what it should: When 'Do not show this dialog later' is checked, it would remove the localStorage item instead of creating it. When unchecked, it would create the localStorage item to prevent the dialog to shows up again. Now, we perform the correct behavior. This closes #10882, closes #11550 --- addons/website/static/src/js/website.translator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/js/website.translator.js b/addons/website/static/src/js/website.translator.js index fe720622431..1965c409883 100644 --- a/addons/website/static/src/js/website.translator.js +++ b/addons/website/static/src/js/website.translator.js @@ -67,9 +67,9 @@ var Translate = translate.Class.include({ dialog.appendTo($(document.body)); dialog.on('activate', this, function () { if (dialog.$('input[name=do_not_show]').prop('checked')) { - localStorage.removeItem(nodialog); - } else { localStorage.setItem(nodialog, true); + } else { + localStorage.removeItem(nodialog); } dialog.$el.modal('hide'); }); From 84b0ec4da361adab9a4fa1943491fc4c745c762a Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 8 Feb 2018 09:17:54 +0100 Subject: [PATCH 3/8] [FIX] delivery: Get correct carrier price on picking created from SO Steps to reproduce: * Create a sales order (SO). * Assign a carrier. * Don't press on "Set price" button next to carrier. * Validate SO. * Validate picking. * Delivery line is added to the SO with price 0. This is because the delivery SO line is added with the value of picking carrier_price field, but that field hasn't been set. If you modify on view carrier field, there's an onchange that fills correct price, so I use that onchange method for getting same results. --- addons/delivery/models/stock_move.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/delivery/models/stock_move.py b/addons/delivery/models/stock_move.py index 92fb62d7dc3..1f0b48663e6 100644 --- a/addons/delivery/models/stock_move.py +++ b/addons/delivery/models/stock_move.py @@ -38,4 +38,7 @@ class StockMove(models.Model): pickings.write({ 'carrier_id': proc.sale_line_id.order_id.carrier_id.id, }) + # Get correct carrier price + for picking in pickings: + picking.onchange_carrier() return res From 72a8b420d28c254e828cbeaa195465b49ea4abca Mon Sep 17 00:00:00 2001 From: "Yenthe V.G" Date: Wed, 7 Feb 2018 11:05:07 +0100 Subject: [PATCH 4/8] [IMP] doc: specify to go in developer mode to access a feature Closes #22877 --- doc/setup/cdn.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/setup/cdn.rst b/doc/setup/cdn.rst index 290a9aff400..83d0a43333d 100644 --- a/doc/setup/cdn.rst +++ b/doc/setup/cdn.rst @@ -37,7 +37,8 @@ Step 2: Configure the odoo instance with your zone In the Odoo back end, go to the :guilabel:`Website Settings`: menu, then activate the CDN support and copy/paste your zone URL in the -:guilabel:`CDN Base URL` field. +:guilabel:`CDN Base URL` field. This field is only visible and configurable if +you have developer mode activated. .. image:: cdn/odoo_cdn_base_url.png :class: img-responsive From 8dfd6a2507c2b59016d466d818c0d42afbfdb027 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 5 Feb 2018 15:00:44 +0100 Subject: [PATCH 5/8] [FIX] web_editor: fix image deletion and replacement Deleting/replacing an image through summernote gave unexpected results. As modifiying the related function may be tricky, this commit instead wrap them to solve the specific erratic behavior: if the range is in/ matches an image, then simply remove the image and move the cursor to its previous location. --- addons/web_editor/static/src/js/summernote.js | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index da837d67354..9c5ef38d43d 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -953,15 +953,21 @@ range.WrappedRange.prototype.deleteContents = function (towrite) { return this; } - var prevBP = dom.removeBetween(this.sc, this.so, this.ec, this.eo, towrite); + var r; + var image = this.isOnImg(); + if (image) { + // If the range matches/is in an image, then the image is to be removed + // and the cursor moved to its previous position + var parentNode = image.parentNode; + var index = _.indexOf(parentNode.childNodes, image); + parentNode.removeChild(image); + r = new range.WrappedRange(parentNode, index, parentNode, index); + } else { + r = dom.removeBetween(this.sc, this.so, this.ec, this.eo, towrite); + } - $(dom.node(prevBP.sc)).trigger("click"); // trigger click to disable and reanable editor and image handler - return new range.WrappedRange( - prevBP.sc, - prevBP.so, - prevBP.ec, - prevBP.eo - ); + $(dom.node(r.sc)).trigger("click"); // trigger click to disable and reanable editor and image handler + return new range.WrappedRange(r.sc, r.so, r.ec, r.eo); }; range.WrappedRange.prototype.clean = function (mergeFilter, all) { var node = dom.node(this.sc === this.ec ? this.sc : this.commonAncestor()); From ce51ad7e69dbc1415eaf5f2ae846bbe89a37f69b Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 7 Feb 2018 15:55:20 +0100 Subject: [PATCH 6/8] [FIX] web_editor: allow deleting all images in table cells Before this commit, it was impossible to delete an image which was a direct child of a table cell using the trash-icon button in the toolbar. This commit fixes the behavior by changing the logic quite a lot, so it is kinda tricky (see https://github.com/odoo/odoo/commit/25849e918651eba080dac3af4e4fcdc8f1280241 for more explaination). Closes https://github.com/odoo/odoo/issues/22523 --- addons/web_editor/static/src/js/summernote.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index 9c5ef38d43d..574836d0180 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -1313,7 +1313,7 @@ function summernote_keydown_clean (field) { function remove_table_content(r) { var ancestor = r.commonAncestor(); - var nodes = dom.listBetween(r.sc, r.ec); + var nodes = dom.listBetween(r.sc, r.ec, r.so, r.eo); if (dom.isText(r.sc)) { r.sc.textContent = r.sc.textContent.slice(0, r.so); } From aac8f9730ec7d6f9066eb96bcb945e6e27ef057a Mon Sep 17 00:00:00 2001 From: mreficent Date: Fri, 9 Feb 2018 09:53:57 +0100 Subject: [PATCH 7/8] [FIX] base: on_change_country() on res.company should return an ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the return value was sometimes an int and sometimes a browse record. Was PR #22810. Courtesy of Miquel Raïch (Eficent) --- addons/account/models/chart_template.py | 2 +- odoo/addons/base/res/res_company.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index ffae12f070c..7bb0718c6d7 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -715,7 +715,7 @@ class WizardMultiChartsAccounts(models.TransientModel): if company_id: company = self.env['res.company'].browse(company_id) currency_id = company.on_change_country(company.country_id.id)['value']['currency_id'] - res.update({'currency_id': currency_id.id}) + res.update({'currency_id': currency_id}) chart_templates = account_chart_template.search([('visible', '=', True)]) if chart_templates: diff --git a/odoo/addons/base/res/res_company.py b/odoo/addons/base/res/res_company.py index 81d0ac2a8e0..3a0ad5a1a14 100644 --- a/odoo/addons/base/res/res_company.py +++ b/odoo/addons/base/res/res_company.py @@ -258,8 +258,8 @@ class Company(models.Model): self.ensure_one() currency_id = self._get_user_currency() if country_id: - currency_id = self.env['res.country'].browse(country_id).currency_id.id - return {'value': {'currency_id': currency_id}} + currency_id = self.env['res.country'].browse(country_id).currency_id + return {'value': {'currency_id': currency_id.id}} @api.onchange('country_id') def _onchange_country_id_wrapper(self): From df3fb9f85abbb78b529e4a6095b04915d6684e09 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Fri, 9 Feb 2018 10:54:22 +0100 Subject: [PATCH 8/8] [FIX] calendar: fix partners_to_notify to have flat list of ids Before this commit, user see a traceback: (res_users.partner_id in (3,ARRA.. ... operator does not exist: integer = integer[] After update from initial commit After append from commit 1bb74b75885e066dbad5c709e9ff63feb053b767 Now, extend to allow [1].extend([2,3]) This commit closes #22944 Courtesy of @paulius-sladkevicius for reporting --- addons/calendar/models/calendar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 793fd1055f7..34f0b86b3fb 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -1415,7 +1415,7 @@ class Meeting(models.Model): partners_to_notify = meeting.partner_ids.ids event_attendees_changes = attendees_create and real_ids and attendees_create[real_ids[0]] if event_attendees_changes: - partners_to_notify.append(event_attendees_changes['removed_partners'].ids) + partners_to_notify.extend(event_attendees_changes['removed_partners'].ids) self.env['calendar.alarm_manager'].notify_next_alarm(partners_to_notify) if (values.get('start_date') or values.get('start_datetime') or