Merge lp:~julie-w/unifield-server/US-5688 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5318
Proposed branch: lp:~julie-w/unifield-server/US-5688
Merge into: lp:unifield-server
Diff against target: 45 lines (+15/-13)
1 file modified
bin/addons/msf_budget/msf_budget_tools.py (+15/-13)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-5688
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+364807@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/msf_budget/msf_budget_tools.py'
2--- bin/addons/msf_budget/msf_budget_tools.py 2017-02-09 10:35:44 +0000
3+++ bin/addons/msf_budget/msf_budget_tools.py 2019-03-20 14:43:45 +0000
4@@ -247,18 +247,6 @@
5 def _get_cost_center_ids(self, cr, uid, browse_cost_center):
6 return self.pool.get('account.analytic.account').search(cr, uid, [('parent_id', 'child_of', browse_cost_center.id)])
7
8- def _create_account_destination_domain(self, account_destination_list):
9- if len(account_destination_list) == 0:
10- return ['&',
11- ('general_account_id', 'in', []),
12- ('destination_id', 'in', [])]
13- elif len(account_destination_list) == 1:
14- return ['&',
15- ('general_account_id', '=', account_destination_list[0][0]),
16- ('destination_id', '=', account_destination_list[0][1])]
17- else:
18- return ['|'] + self._create_account_destination_domain([account_destination_list[0]]) + self._create_account_destination_domain(account_destination_list[1:])
19-
20 def _get_actual_amounts(self, cr, uid, output_currency_id, domain=[], context=None):
21 # Input: domain for the selection of analytic lines (cost center, date, etc...)
22 # Output: a dict of list {(general_account_id, destination_id): [jan_actual, feb_actual,...]}
23@@ -279,7 +267,21 @@
24 res[account_id, destination_id] = [0] * 12
25
26 # fill search domain (one search for all analytic lines)
27- domain += self._create_account_destination_domain(account_destination_ids)
28+ account_dest_combinations = {}
29+ # create a dict with key = account, and value = list of the related possible destinations
30+ for acc_dest_id in account_destination_ids:
31+ if acc_dest_id[0] not in account_dest_combinations:
32+ account_dest_combinations[acc_dest_id[0]] = []
33+ account_dest_combinations[acc_dest_id[0]].append(acc_dest_id[1])
34+ i = 0
35+ for acc in account_dest_combinations:
36+ i += 1
37+ if i < len(account_dest_combinations):
38+ # don't add the "or" at least iteration
39+ domain.append('|')
40+ domain.append('&')
41+ domain.append(('general_account_id', '=', acc))
42+ domain.append(('destination_id', 'in', account_dest_combinations[acc]))
43
44 # Analytic domain is now done; lines are retrieved and added
45 analytic_line_obj = self.pool.get('account.analytic.line')

Subscribers

People subscribed via source and target branches