From d8d1681a1359b7502cdf91ef667aa49b7998e215 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 23 Mar 2016 18:43:04 +0100 Subject: [PATCH 1/2] [FIX] account: check journal centralization performances This revision is related to 99d8cd6 Avoid to check the journal centralization mutliple times, for each move lines. Checking the journal centralization for each journal for each period just before the call to `super` is enough. Before this revision, if a large number of move lines was passed in the `ids` parameter of the `write` method, with all the same journal / period, this could lead to huge performances issues, the `_check_moves` being called a large number of times for the same journal and period couple, uselessly. opw-672797 --- addons/account/account_move_line.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 30e90dda379..8ce15834ab1 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -1221,6 +1221,7 @@ class account_move_line(osv.osv): todo_date = vals['date'] del vals['date'] + centralized_journals = [] for line in self.browse(cr, uid, ids, context=context): ctx = context.copy() if not ctx.get('journal_id'): @@ -1235,8 +1236,10 @@ class account_move_line(osv.osv): ctx['period_id'] = line.period_id.id #Check for centralisation journal = journal_obj.browse(cr, uid, ctx['journal_id'], context=ctx) - if journal.centralisation: - self._check_moves(cr, uid, context=ctx) + if journal.centralisation and (ctx['journal_id'], ctx['period_id']) not in centralized_journals: + centralized_journals.append((ctx['journal_id'], ctx['period_id'])) + for journal_period in centralized_journals: + self._check_moves(cr, uid, context=dict(ctx, journal_id=journal_period[0], period_id=journal_period[1])) result = super(account_move_line, self).write(cr, uid, ids, vals, context) if affects_move and check and not context.get('novalidate'): From f1b9b301da5d3928f10a6636297f9af9b006ab98 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 24 Mar 2016 11:18:14 +0100 Subject: [PATCH 2/2] [FIX] web: clear filename if image error When the user chooses as product image a file which is not an image, the message "Could not display the selected image" is displayed. However, at saving, a traceback is thrown since the file chosen is uploaded anyway. If the image cannot be displayed, the image field is cleared. opw-672206 --- addons/web/static/src/js/view_form.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 0874792003f..d243c9b1062 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -5229,6 +5229,7 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({ $img.css("margin-top", "" + (self.options.size[1] - $img.height()) / 2 + "px"); }); $img.on('error', function() { + self.on_clear(); $img.attr('src', self.placeholder); instance.webclient.notification.warn(_t("Image"), _t("Could not display the selected image.")); });