From 9a36751f2d7c26ae5319a03dc607acf9bee873d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Thu, 23 Apr 2015 17:04:39 +0200 Subject: [PATCH] [IMP] mis_builder: fix and improve get_aml_domain_for_expr --- mis_builder/models/aep.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mis_builder/models/aep.py b/mis_builder/models/aep.py index 77ef5802..a0c8461c 100644 --- a/mis_builder/models/aep.py +++ b/mis_builder/models/aep.py @@ -145,13 +145,18 @@ class AccountingExpressionProcessor(object): domains = [] for mo in self.ACC_RE.finditer(expr): - _, mode, account_codes, domain = self._parse_mo(mo) + field, mode, account_codes, domain = self._parse_mo(mo) if mode == 'i': continue account_ids = set() for account_code in account_codes: account_ids.update(self._account_ids_by_code[account_code]) - domains.append([('account_id', 'in', tuple(account_ids))]) + domain = [('account_id', 'in', tuple(account_ids))] + if field == 'crd': + domain.append(('credit', '>', 0)) + elif field == 'deb': + domain.append(('debit', '>', 0)) + domain.extend(domain) domains.append(domain) return or_domains(domains)