From 350a4ff861982173220e2df428534468bcc1ad0c Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 22 Aug 2018 09:32:41 +0200 Subject: [PATCH 1/3] [FIX] crm: fix API merge, other spot fix cc72b0c2fada765746ac5347b779c8e5d63f530c did not go far enough Sorry for it --- addons/crm/models/crm_lead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index 3cec41d721e..3c44753c8c0 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -667,7 +667,7 @@ class Lead(FormatAddress, models.Model): partner_match_domain.append(('partner_id', '=', partner_id)) partner_match_domain = ['|'] * (len(partner_match_domain) - 1) + partner_match_domain if not partner_match_domain: - return [] + return self.env['crm.lead'] domain = partner_match_domain if not include_lost: domain += ['&', ('active', '=', True), ('probability', '<', 100)] From 81f975d3f48239ee0722fb3892112db6915e7964 Mon Sep 17 00:00:00 2001 From: Toufik Benjaa Date: Wed, 22 Aug 2018 17:59:22 +0200 Subject: [PATCH 2/3] [FIX] mail: channel_get return wrong channel when duplicate partners - In some cases (merge of partners, etc ...) there might be mail.channel that have two mail.channel.partner with the same res.partner. When you try to open a discuss window with a partner for which you have no existing mail.channel. The channel opened is the one where your partner is duplicated. This is due to the fact that the SQL request to find the mail.channel doesn't take in account that a mail.channel may have twice the same partner. To fix this issue, we try to exactly match the partners we search. --- addons/mail/models/mail_channel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index 91610463e81..372fc8ef0ea 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -361,8 +361,8 @@ class Channel(models.Model): AND P.partner_id IN %s AND channel_type LIKE 'chat' GROUP BY P.channel_id - HAVING COUNT(P.partner_id) = %s - """, (tuple(partners_to), len(partners_to),)) + HAVING array_agg(P.partner_id ORDER BY P.partner_id) = %s + """, (tuple(partners_to), sorted(list(partners_to)),)) result = self.env.cr.dictfetchall() if result: # get the existing channel between the given partners From b50958c40f943df44bd2cf9fe4d460a1438b17c5 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 22 Aug 2018 15:52:33 +0200 Subject: [PATCH 3/3] [FIX] account: allow range amount search for reconciliation widget In the reconciliation widget, search for an amount like 5361.61 Before this commit, if the targetted line that you want to see was represented as 5361.61000001 you did not see it in the results of the search After this commit, you do! OPW 1872543 closes #26523 --- addons/account/models/account_move.py | 37 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index e7d5539bd65..a035ebd7db1 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -608,6 +608,21 @@ class AccountMoveLine(models.Model): :param excluded_ids: list of ids of move lines that should not be fetched :param str: search string """ + epsilon = 0.0001 + + def _domain_range_amount(field, amount, signed=False): + def build_for_amount(amount): + return expression.AND([ + [(field, '>=', amount - epsilon)], + [(field, '<=', amount + epsilon)] + ]) + + unsigned_domain = build_for_amount(amount) + if not signed: + return unsigned_domain + + return expression.OR([unsigned_domain, build_for_amount(-amount)]) + context = (self._context or {}) if excluded_ids is None: excluded_ids = [] @@ -624,14 +639,20 @@ class AccountMoveLine(models.Model): ] try: amount = float(str) - amount_domain = [ - '|', ('amount_residual', '=', amount), - '|', ('amount_residual_currency', '=', amount), - '|', ('amount_residual', '=', -amount), - '|', ('amount_residual_currency', '=', -amount), - '&', ('account_id.internal_type', '=', 'liquidity'), - '|', '|', ('debit', '=', amount), ('credit', '=', amount), ('amount_currency', '=', amount), - ] + residual_domain = expression.OR([ + _domain_range_amount(field, amount, True) + for field in ('amount_residual', 'amount_residual_currency') + ]) + + liquidity_domain = expression.AND([ + [('account_id.internal_type', '=', 'liquidity')], + expression.OR([ + _domain_range_amount(field, amount) + for field in ('debit', 'credit', 'amount_currency') + ]) + ]) + + amount_domain = expression.OR([residual_domain, liquidity_domain]) str_domain = expression.OR([str_domain, amount_domain]) except: pass