From f12daec1a1dba46ec4e26ce7c313bc132f9537f8 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 27 Apr 2018 14:09:10 +0200 Subject: [PATCH 1/5] [FIX] web: don't change page before saving When we edit a list view and change page before the change has been savec, the saving and page changing will be done concurrently thus possibly causing an error if the page is changed before the saved is finished: the save will try to modify the page that is no more displayed. In this change, the list view editable wait for the saving to be finished before reloading its content. note: for 9.0 up to saas-15 opw-1839149 closes #24471 --- addons/web/static/src/js/views/list_view.js | 10 ++++++++-- addons/web/static/src/js/views/list_view_editable.js | 11 +++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/views/list_view.js b/addons/web/static/src/js/views/list_view.js index 98462e68493..f742c9fb435 100644 --- a/addons/web/static/src/js/views/list_view.js +++ b/addons/web/static/src/js/views/list_view.js @@ -352,7 +352,7 @@ var ListView = View.extend( /** @lends instance.web.ListView# */ { } else if (self.page > max_page_index) { self.page = 0; } - self.reload_content(); + self.reload_content_when_ready(); }).find('.oe_list_pager_state') .click(function (e) { e.stopPropagation(); @@ -370,7 +370,7 @@ var ListView = View.extend( /** @lends instance.web.ListView# */ { var val = parseInt($select.val(), 10); self._limit = (isNaN(val) ? null : val); self.page = 0; - self.reload_content(); + self.reload_content_when_ready(); }).blur(function() { $(this).trigger('change'); }) @@ -542,6 +542,12 @@ var ListView = View.extend( /** @lends instance.web.ListView# */ { }); return reloaded.promise(); }), + /** + * Proxy allowing override when reload_content can't be called directly + */ + reload_content_when_ready: function() { + return this.reload_content.apply(this, arguments); + }, reload: function () { return this.reload_content(); }, diff --git a/addons/web/static/src/js/views/list_view_editable.js b/addons/web/static/src/js/views/list_view_editable.js index b522e1e37a0..d7f15bd89f2 100644 --- a/addons/web/static/src/js/views/list_view_editable.js +++ b/addons/web/static/src/js/views/list_view_editable.js @@ -401,6 +401,17 @@ ListView.include(/** @lends instance.web.ListView# */{ }); return cells; }, + /** + * Prevent reloading content while an ongoing save + */ + reload_content_when_ready: function() { + var self = this; + var self_super = this._super; + var original_arguments = arguments; + return this.saving_mutex.exec(function() { + return self_super.apply(self, original_arguments); + }); + }, /** * If currently editing a row, resizes all registered form fields based * on the corresponding row cell From 7353405aa4fc88ede6b85bbb46fe0308b17c1052 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 2 May 2018 17:14:50 +0200 Subject: [PATCH 2/5] [FIX] stock: Scheduled date purchase order wrong When running the scheduler for a reordering rule, the delivery lead time of the seller was not taken into account. opw:1837550 --- addons/stock/models/stock_warehouse.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py index d81efe07404..36a6e696cc6 100644 --- a/addons/stock/models/stock_warehouse.py +++ b/addons/stock/models/stock_warehouse.py @@ -845,7 +845,8 @@ class Orderpoint(models.Model): days = self.lead_days or 0.0 if self.lead_type == 'supplier': # These days will be substracted when creating the PO - days += self.product_id._select_seller().delay or 0.0 + qty = self.env.context.get('product_qty', 0.0) + days += self.product_id._select_seller(quantity=qty).delay or 0.0 date_planned = start_date + relativedelta.relativedelta(days=days) return date_planned.strftime(DEFAULT_SERVER_DATETIME_FORMAT) @@ -853,7 +854,7 @@ class Orderpoint(models.Model): def _prepare_procurement_values(self, product_qty, date=False, group=False): return { 'name': self.name, - 'date_planned': date or self._get_date_planned(datetime.today()), + 'date_planned': date or self.with_context(product_qty=product_qty)._get_date_planned(datetime.today()), 'product_id': self.product_id.id, 'product_qty': product_qty, 'company_id': self.company_id.id, From 78ce64a6a79a41e673196939f2bb60a44db27f55 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 3 May 2018 10:49:23 +0200 Subject: [PATCH 3/5] [FIX] account: do not block reconciliation on different partners This constraint was added during the Great Accounting Reform of v9, in an attempt to help users avoid reconciliation mistakes. It turns out that such mistakes are difficult to make in normal situations, since the system only offers matching entries to reconcile, so the constraint is largely redundant. On the other hand, it does block legit cases of reconciliation, such as those where a large number of lines with different partners are reconciled together. This often happens when reversing a Journal Entry that encompasses multiple customers, such as a POS closing entry, or a manual entry. To make the system more flexible, let's consider that when a manual reconciliation breaks the "single partner" rule explicitly, it's for a good reason, so we should allow it. OPW: 1840437 Backport of 8e73023f689d76dc6d545e617ab1c7ce18334068 --- addons/account/models/account_move.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 1c0bec65626..c8931900ac9 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -905,8 +905,6 @@ class AccountMoveLine(models.Model): raise UserError(_('Entries are not of the same account!')) if not all_accounts[0].reconcile: raise UserError(_('The account %s (%s) is not marked as reconciliable !') % (all_accounts[0].name, all_accounts[0].code)) - if len(partners) > 1: - raise UserError(_('The partner has to be the same on all lines for receivable and payable accounts!')) #reconcile everything that can be remaining_moves = self.auto_reconcile_lines() From f49a6b6ebe64688a53b224c10216790812c864e9 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Thu, 3 May 2018 09:58:38 +0200 Subject: [PATCH 4/5] [FIX] website_slides: avoid double slash in slide url --- addons/website_slides/models/slides.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/website_slides/models/slides.py b/addons/website_slides/models/slides.py index 15abfedded9..61fb0aa9816 100644 --- a/addons/website_slides/models/slides.py +++ b/addons/website_slides/models/slides.py @@ -351,6 +351,8 @@ class Slide(models.Model): def _get_embed_code(self): base_url = request and request.httprequest.url_root or self.env['ir.config_parameter'].sudo().get_param('web.base.url') + if base_url[-1] == '/': + base_url = base_url[:-1] for record in self: if record.datas and (not record.document_id or record.slide_type in ['document', 'presentation']): slide_url = base_url + url_for('/slides/embed/%s?page=1' % record.id) From b5516d400eec155cdabcf883f7c0f98d7bf4fb5f Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 4 May 2018 11:44:55 +0200 Subject: [PATCH 5/5] [FIX] website_sale_comparison: use variant id and not product id Before this commit, the compare button from the customized view "Alternative Products" would create the URL by joining `alternative_product_ids` which are ids from product.template. But the route /shop/compare is supposed to receive variants (product.product) IDs. Thus, it would try to search given product.template IDs in product.product records. It would then show incorrect items or no items at all if the ID does not exist. Now, we create the URL with the first variant (product.product) of the product.template. Obviously, the first product.product is arbitrary but we can't retrieve all the variants ids, it would most of the time returns too many items. opw-1840321 --- .../views/website_sale_comparison_template.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_sale_comparison/views/website_sale_comparison_template.xml b/addons/website_sale_comparison/views/website_sale_comparison_template.xml index 3889b05a148..9bb6e10488f 100644 --- a/addons/website_sale_comparison/views/website_sale_comparison_template.xml +++ b/addons/website_sale_comparison/views/website_sale_comparison_template.xml @@ -57,7 +57,7 @@