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

Proposed by jftempo
Status: Merged
Merged at revision: 5090
Proposed branch: lp:~julie-w/unifield-server/US-5051
Merge into: lp:unifield-server
Diff against target: 158 lines (+63/-6)
4 files modified
bin/addons/account/report/account_liquidity_balance.py (+1/-0)
bin/addons/vertical_integration/report/hq_report_ocb.py (+46/-3)
bin/addons/vertical_integration/report/hq_report_ocg.py (+8/-3)
bin/addons/vertical_integration/report/hq_report_ocp.py (+8/-0)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-5051
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+355432@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/account/report/account_liquidity_balance.py'
2--- bin/addons/account/report/account_liquidity_balance.py 2018-02-23 13:03:07 +0000
3+++ bin/addons/account/report/account_liquidity_balance.py 2018-09-20 14:23:21 +0000
4@@ -57,6 +57,7 @@
5 period.date_stop, tuple(self.instance_ids))
6 self.cr.execute(self.liquidity_sql, params)
7 cash_bank_res = self.cr.dictfetchall()
8+ cash_bank_res = reportvi.hq_report_ocb.postprocess_liquidity_balances(self, self.cr, self.uid, cash_bank_res, context=self.context)
9 res.extend(cash_bank_res)
10 # Cheque registers
11 cheque_sql = """
12
13=== modified file 'bin/addons/vertical_integration/report/hq_report_ocb.py'
14--- bin/addons/vertical_integration/report/hq_report_ocb.py 2018-07-20 12:48:55 +0000
15+++ bin/addons/vertical_integration/report/hq_report_ocb.py 2018-09-20 14:23:21 +0000
16@@ -247,10 +247,16 @@
17 new_data.append(self.line_to_utf8(tmp_line))
18 return self.postprocess_selection_columns(cr, uid, new_data, [('account.bank.statement', 'state', 6)], column_deletion=column_deletion)
19
20-
21-# request used for OCB, OCP, and OCG VI and for Liquidity Balances report
22+ def postprocess_liquidity_balances(self, cr, uid, data, context=None, column_deletion=False):
23+ """
24+ Note that the param "column_deletion" is needed (see def archive in finance_export) but NOT used here.
25+ """
26+ return postprocess_liquidity_balances(self, cr, uid, data, context=context)
27+
28+
29+# request & postprocess method used for OCB, OCP, and OCG VI and for Liquidity Balances report
30 liquidity_sql = """
31- SELECT i.code AS instance, j.code, j.name, %s AS period, req.opening, req.calculated, req.closing, c.name AS currency
32+ SELECT i.code AS instance, j.code, j.id, %s AS period, req.opening, req.calculated, req.closing, c.name AS currency
33 FROM res_currency c,
34 (
35 SELECT journal_id, account_id, SUM(col1) AS opening, SUM(col2) AS calculated, SUM(col3) AS closing
36@@ -298,6 +304,41 @@
37 """
38
39
40+def postprocess_liquidity_balances(self, cr, uid, data, context=None):
41+ """
42+ Returns data after having replaced the Journal ID by the Journal Name in the current language
43+ (the language code should be stored in context['lang']).
44+ """
45+ # number and name of the column containing the journal id
46+ col_nbr = 2
47+ col_name = 'id'
48+ col_new_name = 'name'
49+ if context is None or 'lang' not in context:
50+ context = {'lang': 'en_MF'} # English by default
51+ pool = pooler.get_pool(cr.dbname)
52+ journal_obj = pool.get('account.journal')
53+ new_data = []
54+ for line in data:
55+ tmp_l = line
56+ # list
57+ if isinstance(tmp_l, list):
58+ if tmp_l[col_nbr]:
59+ tmp_l[col_nbr] = journal_obj.read(cr, uid, tmp_l[col_nbr], ['name'], context=context)['name']
60+ # tuple
61+ elif isinstance(tmp_l, tuple):
62+ tmp_l = list(tmp_l)
63+ if tmp_l[col_nbr]:
64+ tmp_l[col_nbr] = journal_obj.read(cr, uid, tmp_l[col_nbr], ['name'], context=context)['name']
65+ tmp_l = tuple(tmp_l) # restore back the initial format
66+ # dictionary
67+ elif isinstance(tmp_l, dict):
68+ if tmp_l[col_name]:
69+ tmp_l[col_new_name] = journal_obj.read(cr, uid, tmp_l[col_name], ['name'], context=context)['name']
70+ del tmp_l[col_name]
71+ new_data.append(tmp_l)
72+ return new_data
73+
74+
75 class hq_report_ocb(report_sxw.report_sxw):
76
77 def __init__(self, name, table, rml=False, parser=report_sxw.rml_parse, header='external', store=False):
78@@ -641,6 +682,8 @@
79 'filename': instance_name + '_' + year + month + '_Liquidity Balances.csv',
80 'key': 'liquidity',
81 'query_params': (tuple([period_yyyymm]), reg_types, first_day_of_period, reg_types, period.id, reg_types, last_day_of_period, tuple(instance_ids)),
82+ 'function': 'postprocess_liquidity_balances',
83+ 'fnct_params': context,
84 },
85 {
86 'headers': ['Name', 'Code', 'Donor code', 'Grant amount', 'Reporting CCY', 'State'],
87
88=== modified file 'bin/addons/vertical_integration/report/hq_report_ocg.py'
89--- bin/addons/vertical_integration/report/hq_report_ocg.py 2018-08-16 15:41:51 +0000
90+++ bin/addons/vertical_integration/report/hq_report_ocg.py 2018-09-20 14:23:21 +0000
91@@ -92,10 +92,12 @@
92 line_debit > 0 and "0.00" or round(-line_debit, 2),
93 currency.name]]
94
95- def _get_liquidity_balances(self, cr, instance_ids, period, period_yyyymm):
96+ def _get_liquidity_balances(self, cr, uid, instance_ids, period, period_yyyymm, context=None):
97 """
98 Returns the content of the Liquidity Balances Report as a list of lists
99 """
100+ if context is None:
101+ context = {}
102 reg_types = ('cash', 'bank', 'cheque')
103 liquidity_balance_header = ['Instance',
104 'Code',
105@@ -110,6 +112,7 @@
106 period.date_stop, tuple(instance_ids))
107 cr.execute(liquidity_sql, liquidity_params)
108 liquidity_balance_lines = [list(lbl) for lbl in cr.fetchall()]
109+ liquidity_balance_lines = hq_report_ocb.postprocess_liquidity_balances(self, cr, uid, liquidity_balance_lines, context=context)
110 return [liquidity_balance_header] + liquidity_balance_lines
111
112 def _get_account_balances(self, cr, instance_ids, period, period_yyyymm):
113@@ -132,6 +135,8 @@
114 return [acc_balance_header] + acc_balance_lines
115
116 def create(self, cr, uid, ids, data, context=None):
117+ if context is None:
118+ context = {}
119 pool = pooler.get_pool(cr.dbname)
120 # Create the header
121 first_header = ['Proprietary Instance',
122@@ -362,8 +367,8 @@
123
124 second_report = [second_header] + second_result_lines
125
126- liquidity_report = self._get_liquidity_balances(cr, data['form'].get('instance_ids', False),
127- period, period_yyyymm)
128+ liquidity_report = self._get_liquidity_balances(cr, uid, data['form'].get('instance_ids', False),
129+ period, period_yyyymm, context=context)
130 liquidity_share = 0.05 # 5% of the process
131 self.shared_update_percent(cr, uid, pool, [bg_id],
132 share=liquidity_share, finished=True,
133
134=== modified file 'bin/addons/vertical_integration/report/hq_report_ocp.py'
135--- bin/addons/vertical_integration/report/hq_report_ocp.py 2018-08-16 15:55:30 +0000
136+++ bin/addons/vertical_integration/report/hq_report_ocp.py 2018-09-20 14:23:21 +0000
137@@ -191,6 +191,12 @@
138 line[journal_type_col] = self._get_journal_type_value(cr, uid, line[journal_type_col])
139 return new_data
140
141+ def postprocess_liquidity_balances(self, cr, uid, data, context=None, column_deletion=False):
142+ """
143+ Note that the param "column_deletion" is needed (see def archive in finance_export) but NOT used here.
144+ """
145+ return hq_report_ocb.postprocess_liquidity_balances(self, cr, uid, data, context=context)
146+
147
148 # request used for OCP and OCG VI
149 # Journals excluded from the Account Balances: Migration, In-kind Donation, OD-Extra Accounting
150@@ -510,6 +516,8 @@
151 'key': 'liquidity',
152 'query_params': (tuple([period_yyyymm]), reg_types, first_day_of_period, reg_types, period.id,
153 reg_types, last_day_of_period, tuple(instance_ids)),
154+ 'function': 'postprocess_liquidity_balances',
155+ 'fnct_params': context,
156 },
157 {
158 'headers': ['Instance', 'Account', 'Account Name', 'Period', 'Opening balance', 'Calculated balance',

Subscribers

People subscribed via source and target branches