From c150ab367a787ae7e358952e2af76b75683a36c6 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 10 Apr 2019 12:33:45 +0000 Subject: [PATCH 1/6] [FIX] web: FieldFloatToggle cell multi language Have a timesheet uom per Day Have a language with a different number format than English Click on grid cell to change its value Before this commit, the value was stuck on the highest value in range This was because the parsing of the value into float was not taking into account the real format of the float After this commit, it works in all languages OPW 1964657 closes odoo/odoo#32581 Signed-off-by: Lucas Perais (lpe) --- addons/web/static/src/js/fields/basic_fields.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 2c8968ca453..a4284841130 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1035,7 +1035,13 @@ var FieldFloatToggle = AbstractField.extend({ * @returns {float} The current formatted value */ _getDisplayedValue: function () { - return parseFloat(this._formatValue(this.value)); + // this.value is a plain float + // Matches what is in Database + var usrFormatValue = this._formatValue(this.value); + // usrFormatValue is string + // contains a float represented in a user specific format + // the float is the fraction by [this.factor] of this.value + return field_utils.parse['float'](usrFormatValue); }, /** * Formats the HTML input tag for edit mode and stores selection status. @@ -1062,7 +1068,7 @@ var FieldFloatToggle = AbstractField.extend({ * one is not in the range, the next value of the closest one will be chosen. * * @private - * @returns {number} The next formatted value in the range + * @returns {number} The next value in the range */ _nextValue: function () { var range = this.nodeOptions.range; @@ -1091,7 +1097,8 @@ var FieldFloatToggle = AbstractField.extend({ if (this.mode === 'edit') { ev.stopPropagation(); // only stop propagation in edit mode var next_val = this._nextValue(); - this._setValue(next_val.toString()); // will be parsed in _setValue + next_val = field_utils.format['float'](next_val); + this._setValue(next_val); // will be parsed in _setValue } }, From 71b590121ec786468027615fce27c043c02f7411 Mon Sep 17 00:00:00 2001 From: sbbaro Date: Thu, 11 Apr 2019 10:05:01 +0000 Subject: [PATCH 2/6] [IMP] Website sale performance improvement The search on products is quite a slow sql query and it's run different times. We avoid that repetition by storing it in a variable. opw 1941352 closes odoo/odoo#32626 Signed-off-by: Lucas Perais (lpe) --- addons/website_sale/controllers/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 603d0176086..25c0cdd42b6 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -234,8 +234,9 @@ class WebsiteSale(ProductConfiguratorController): Category = request.env['product.public.category'] search_categories = False + search_product = Product.search(domain) if search: - categories = Product.search(domain).mapped('public_categ_ids') + categories = search_product.mapped('public_categ_ids') search_categories = Category.search([('id', 'parent_of', categories.ids)] + request.website.website_domain()) categs = search_categories.filtered(lambda c: not c.parent_id) else: @@ -250,15 +251,14 @@ class WebsiteSale(ProductConfiguratorController): parent_category_ids.append(current_category.parent_id.id) current_category = current_category.parent_id - product_count = Product.search_count(domain) + product_count = len(search_product) pager = request.website.pager(url=url, total=product_count, page=page, step=ppg, scope=7, url_args=post) products = Product.search(domain, limit=ppg, offset=pager['offset'], order=self._get_search_order(post)) ProductAttribute = request.env['product.attribute'] if products: # get all products without limit - selected_products = Product.search(domain, limit=False) - attributes = ProductAttribute.search([('attribute_line_ids.value_ids', '!=', False), ('attribute_line_ids.product_tmpl_id', 'in', selected_products.ids)]) + attributes = ProductAttribute.search([('attribute_line_ids.value_ids', '!=', False), ('attribute_line_ids.product_tmpl_id', 'in', search_product.ids)]) else: attributes = ProductAttribute.browse(attributes_ids) From 6bae16b788af252a4b65708d37bd1291a2d80d34 Mon Sep 17 00:00:00 2001 From: Kiril Vangelovski Date: Mon, 8 Apr 2019 20:12:46 +0000 Subject: [PATCH 3/6] [FIX] hw_screen: Mixed Content when loading with https The protocol is hardcoded to `http` in the url for the longpolling request (/point_of_sale/get_serialized_order). It should match the same protocol as the page was loaded in to avoid Mixed Content errors. closes odoo/odoo#32528 Signed-off-by: Quentin Lejeune (qle) --- addons/hw_screen/static/src/js/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hw_screen/static/src/js/worker.js b/addons/hw_screen/static/src/js/worker.js index 4031e85cf52..80c9d3a6d78 100644 --- a/addons/hw_screen/static/src/js/worker.js +++ b/addons/hw_screen/static/src/js/worker.js @@ -9,7 +9,7 @@ function longpolling() { $.ajax({ type: 'POST', - url: 'http://'+window.location.host+'/point_of_sale/get_serialized_order', + url: window.location.origin+'/point_of_sale/get_serialized_order', dataType: 'json', beforeSend: function(xhr){xhr.setRequestHeader('Content-Type', 'application/json');}, data: JSON.stringify({jsonrpc: '2.0'}), From 5e8b667951463125e888f75877cbc76bacf38ea3 Mon Sep 17 00:00:00 2001 From: Antoine Prieels Date: Tue, 9 Apr 2019 09:24:21 +0000 Subject: [PATCH 4/6] [FIX] hw_screen: Add delay to longpolling When an error occurred in the longpolling, we used to resend a new request immediately. This resulted in thousands of request in a few seconds when we lost connection to the box. closes odoo/odoo#32544 Signed-off-by: Quentin Lejeune (qle) --- addons/hw_screen/static/src/js/worker.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/hw_screen/static/src/js/worker.js b/addons/hw_screen/static/src/js/worker.js index 80c9d3a6d78..5949ab39cef 100644 --- a/addons/hw_screen/static/src/js/worker.js +++ b/addons/hw_screen/static/src/js/worker.js @@ -47,14 +47,17 @@ foreign_js(); } } - }, - - complete: function(jqXHR,err) { if (!stop_longpolling) { longpolling(); } }, + error: function (jqXHR, status, err) { + if (!stop_longpolling) { + setTimeout(longpolling, 5000); + } + }, + timeout: 30000, }); }; From 4ba4d61903ba65301ff431294a9e7fe721918355 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Thu, 11 Apr 2019 13:30:16 +0000 Subject: [PATCH 5/6] [FIX] website_livechat: load im_livechat i18n As authenticated user, join the website livechat. As a portal user, start a livechat. Close it, it asks you to review the chat but all messages are displayed in english. opw-1958819 closes odoo/odoo#32629 Signed-off-by: Julien Castiaux --- addons/website_livechat/models/__init__.py | 3 ++- addons/website_livechat/models/ir_http.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 addons/website_livechat/models/ir_http.py diff --git a/addons/website_livechat/models/__init__.py b/addons/website_livechat/models/__init__.py index 13835e02e09..18f7d71a23d 100644 --- a/addons/website_livechat/models/__init__.py +++ b/addons/website_livechat/models/__init__.py @@ -2,4 +2,5 @@ from . import im_livechat from . import website -from . import res_config_settings \ No newline at end of file +from . import res_config_settings +from . import ir_http diff --git a/addons/website_livechat/models/ir_http.py b/addons/website_livechat/models/ir_http.py new file mode 100644 index 00000000000..baeab9ea57e --- /dev/null +++ b/addons/website_livechat/models/ir_http.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models +from odoo.osv import expression + + +class IrHttp(models.AbstractModel): + _inherit = 'ir.http' + + @classmethod + def _get_translation_frontend_modules_domain(cls): + domain = super(IrHttp, cls)._get_translation_frontend_modules_domain() + return expression.OR([domain, [('name', '=', 'im_livechat')]]) + From 385342b575f6f8510cea6c90108be7b510fd1fa1 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Fri, 12 Apr 2019 09:57:09 +0000 Subject: [PATCH 6/6] [FIX] account: only put internal users as followers of vendor bills (2) Fine-tuning of 0a4e67c609f3d84e25715f57a61ad00ce9aec4df. Due to some confusion, has_group had been replaced by user_has_groups on the corresponding PR. However the latter is not a higher-level version of the former, since it checks the groups on the self.env.user, not on self. As a result, the filtering was completely False, since it checked that the env user was in group_user which was always True. closes odoo/odoo#32653 Signed-off-by: Nans Lefebvre (len) --- addons/account/models/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index d2039926804..9c1518ae3c7 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -703,7 +703,7 @@ class AccountInvoice(models.Model): # Subscribe internal users on the newly created bill partners = self.env['res.partner'].browse(seen_partner_ids) is_internal = lambda p: (p.user_ids and - all(p.user_ids.mapped(lambda u: u.user_has_groups('base.group_user')))) + all(p.user_ids.mapped(lambda u: u.has_group('base.group_user')))) partners_to_subscribe = partners.filtered(is_internal) if partners_to_subscribe: invoice.message_subscribe([p.id for p in partners_to_subscribe])