From fbdac9c8536675483a103163de0609c216851366 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 4 Feb 2016 10:52:06 +0100 Subject: [PATCH 1/3] [FIX] website: fix search in existing pages Previous implementation did not allow the user to search for pages 'name' but only on the slugified name. Now we slugify the needles before to find a match. 1. Create a new page: 'The new' 2. add a link on your website and try to find this page... - Before this commit, the only ways was to type 'the-new' - After this commit 'the new', 'The new', 'The-new', ... will match This commit closes #10771 --- addons/website/models/website.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 180eee13144..deb9eecce9c 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -432,12 +432,12 @@ class website(osv.osv): def search_pages(self, cr, uid, ids, needle=None, limit=None, context=None): name = (needle or "").replace("/page/website.", "").replace("/page/", "") + name = slugify(name, max_length=50) res = [] for page in self.enumerate_pages(cr, uid, ids, query_string=name, context=context): - if needle in page['loc']: - res.append(page) - if len(res) == limit: - break + res.append(page) + if len(res) == limit: + break return res def kanban(self, cr, uid, ids, model, domain, column, template, step=None, scope=None, orderby=None, context=None): From 27b6d245e79cc0ae5cbd1cdc9ee1fe388075d333 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 22 Nov 2016 15:58:45 +0100 Subject: [PATCH 2/3] [FIX] account, account_tax_cash_basis: rounding When tax cash basis is used, the user might face the error "Wrong credit or debit value in accounting entry !". A detailed use case can be found in issue #14158. The reason is that a float representation of `1.0` of the field `matched_percentage` will become `1.000...2` when used in Python. Therefore, such an expression such as `line.credit_cash_basis - line.credit * matched_percentage` might lead to a slightly negative value for the credit/debit, which will not pass the condition `CHECK (credit+debit>=0)`. Fixes #14158 opw-692797 --- addons/account/models/account_move.py | 2 +- addons/account_tax_cash_basis/tax_cash_basis.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index c09cc42022b..c482bc7f84b 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -55,7 +55,7 @@ class AccountMove(models.Model): total_amount += amount for partial_line in (line.matched_debit_ids + line.matched_credit_ids): total_reconciled += partial_line.amount - if total_amount == 0.0: + if float_is_zero(total_amount, precision_rounding=move.currency_id.rounding): move.matched_percentage = 1.0 else: move.matched_percentage = total_reconciled / total_amount diff --git a/addons/account_tax_cash_basis/tax_cash_basis.py b/addons/account_tax_cash_basis/tax_cash_basis.py index b68e348c59e..242356f4967 100644 --- a/addons/account_tax_cash_basis/tax_cash_basis.py +++ b/addons/account_tax_cash_basis/tax_cash_basis.py @@ -53,7 +53,7 @@ class AccountPartialReconcileCashBasis(models.Model): #create reporting issues. Not sure of the behavior to implement in that case, though. # amount to write is the current cash_basis amount minus the one before the reconciliation matched_percentage = value_before_reconciliation[move.id] - amount = (line.credit_cash_basis - line.debit_cash_basis) - (line.credit - line.debit) * matched_percentage + amount = line.currency_id.round((line.credit_cash_basis - line.debit_cash_basis) - (line.credit - line.debit) * matched_percentage) if not self._check_tax_exigible(line): if line.tax_line_id and line.tax_line_id.use_cash_basis: # group by line account @@ -73,15 +73,15 @@ class AccountPartialReconcileCashBasis(models.Model): for tax in line.tax_ids: line_to_create.append((0, 0, { 'name': '/', - 'debit': line.debit_cash_basis - line.debit * matched_percentage, - 'credit': line.credit_cash_basis - line.credit * matched_percentage, + 'debit': line.currency_id.round(line.debit_cash_basis - line.debit * matched_percentage), + 'credit': line.currency_id.round(line.credit_cash_basis - line.credit * matched_percentage), 'account_id': line.account_id.id, 'tax_ids': [(6, 0, [tax.id])], })) line_to_create.append((0, 0, { 'name': '/', - 'credit': line.debit_cash_basis - line.debit * matched_percentage, - 'debit': line.credit_cash_basis - line.credit * matched_percentage, + 'credit': line.currency_id.round(line.debit_cash_basis - line.debit * matched_percentage), + 'debit': line.currency_id.round(line.credit_cash_basis - line.credit * matched_percentage), 'account_id': line.account_id.id, })) From 7196896e014f43973f1784a27e9e7e53e4be7651 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Tue, 22 Nov 2016 16:10:52 +0100 Subject: [PATCH 3/3] [FIX] web_tip: destroy method set call off() on undefined In some cases, when the destoy method of 'Tip' calls the off() function on '$breathing', even if this one is not defined. To fix this error, we check that '$breathing' is not 'undefined' before calling off() on it. --- addons/web_tip/static/src/js/tip.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/web_tip/static/src/js/tip.js b/addons/web_tip/static/src/js/tip.js index 921c4bb7a4d..684f1acc988 100644 --- a/addons/web_tip/static/src/js/tip.js +++ b/addons/web_tip/static/src/js/tip.js @@ -300,6 +300,8 @@ var Tip = Class.extend({ if (this.$element) { this.$element.popover('destroy'); this.$element.removeClass('oe_tip_show_element'); + } + if (this.$breathing) { this.$breathing.off().remove(); } if (this.$helper) {