[MERGE] forward port branch 10.0 up to b50958c40f
This commit is contained in:
@@ -611,6 +611,21 @@ class AccountMoveLine(models.Model):
|
|||||||
:param excluded_ids: list of ids of move lines that should not be fetched
|
:param excluded_ids: list of ids of move lines that should not be fetched
|
||||||
:param str: search string
|
: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 {})
|
context = (self._context or {})
|
||||||
if excluded_ids is None:
|
if excluded_ids is None:
|
||||||
excluded_ids = []
|
excluded_ids = []
|
||||||
@@ -627,14 +642,20 @@ class AccountMoveLine(models.Model):
|
|||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
amount = float(str)
|
amount = float(str)
|
||||||
amount_domain = [
|
residual_domain = expression.OR([
|
||||||
'|', ('amount_residual', '=', amount),
|
_domain_range_amount(field, amount, True)
|
||||||
'|', ('amount_residual_currency', '=', amount),
|
for field in ('amount_residual', 'amount_residual_currency')
|
||||||
'|', ('amount_residual', '=', -amount),
|
])
|
||||||
'|', ('amount_residual_currency', '=', -amount),
|
|
||||||
'&', ('account_id.internal_type', '=', 'liquidity'),
|
liquidity_domain = expression.AND([
|
||||||
'|', '|', ('debit', '=', amount), ('credit', '=', amount), ('amount_currency', '=', amount),
|
[('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])
|
str_domain = expression.OR([str_domain, amount_domain])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ class Lead(models.Model):
|
|||||||
partner_match_domain.append(('partner_id', '=', partner_id))
|
partner_match_domain.append(('partner_id', '=', partner_id))
|
||||||
partner_match_domain = ['|'] * (len(partner_match_domain) - 1) + partner_match_domain
|
partner_match_domain = ['|'] * (len(partner_match_domain) - 1) + partner_match_domain
|
||||||
if not partner_match_domain:
|
if not partner_match_domain:
|
||||||
return []
|
return self.env['crm.lead']
|
||||||
domain = partner_match_domain
|
domain = partner_match_domain
|
||||||
if not include_lost:
|
if not include_lost:
|
||||||
domain += ['&', ('active', '=', True), ('probability', '<', 100)]
|
domain += ['&', ('active', '=', True), ('probability', '<', 100)]
|
||||||
|
|||||||
@@ -380,8 +380,8 @@ class Channel(models.Model):
|
|||||||
AND P.partner_id IN %s
|
AND P.partner_id IN %s
|
||||||
AND channel_type LIKE 'chat'
|
AND channel_type LIKE 'chat'
|
||||||
GROUP BY P.channel_id
|
GROUP BY P.channel_id
|
||||||
HAVING COUNT(P.partner_id) = %s
|
HAVING array_agg(P.partner_id ORDER BY P.partner_id) = %s
|
||||||
""", (tuple(partners_to), len(partners_to),))
|
""", (tuple(partners_to), sorted(list(partners_to)),))
|
||||||
result = self.env.cr.dictfetchall()
|
result = self.env.cr.dictfetchall()
|
||||||
if result:
|
if result:
|
||||||
# get the existing channel between the given partners
|
# get the existing channel between the given partners
|
||||||
|
|||||||
Reference in New Issue
Block a user