Merge lp:~jfb-tempo-consulting/unifield-server/US-11456 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 6274
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-11456
Merge into: lp:unifield-server
Diff against target: 208 lines (+71/-20)
4 files modified
bin/addons/account/report/account_liquidity_balance.py (+41/-8)
bin/addons/register_accounting/report/report_liquidity_position.py (+2/-2)
bin/addons/vertical_integration/report/hq_report_ocb.py (+21/-8)
bin/addons/vertical_integration/report/hq_report_ocp.py (+7/-2)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-11456
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+465686@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 2023-02-28 11:11:15 +0000
3+++ bin/addons/account/report/account_liquidity_balance.py 2024-05-07 10:18:00 +0000
4@@ -44,7 +44,7 @@
5 'get_register_data': self._get_register_data,
6 })
7
8- def _filter_journal_status(self, reg_data):
9+ def _filter_journal_status(self, reg_data, date_to):
10 """
11 Applies the following changes to the reg_data:
12 - adds the journal status
13@@ -53,9 +53,9 @@
14 journal_obj = self.pool.get('account.journal')
15 new_reg_data = []
16 for reg in reg_data:
17- journal_active = journal_obj.read(self.cr, self.uid, reg['id'], ['is_active'])['is_active']
18- if journal_active or reg['opening'] or reg['calculated'] or reg['closing']:
19- reg['journal_status'] = journal_active and _('Active') or _('Inactive')
20+ j_info = journal_obj.read(self.cr, self.uid, reg['id'], ['is_active', 'inactivation_date'])
21+ if j_info['is_active'] or (j_info['inactivation_date'] and j_info['inactivation_date'] > date_to) or reg['opening'] or reg['calculated'] or reg['closing']:
22+ reg['journal_status'] = j_info['is_active'] and _('Active') or _('Inactive')
23 new_reg_data.append(reg)
24 return new_reg_data
25
26@@ -82,15 +82,22 @@
27 fields_to_fetch=['date_start', 'date_stop'])
28 date_from = period.date_start
29 date_to = period.date_stop
30+
31 if not date_from or not date_to:
32 raise osv.except_osv(_('Error'), _('Start date and/or End date missing.'))
33 period_title = self.period_title or ''
34 # Cash and Bank registers
35 reg_types = ('cash', 'bank')
36- params = (period_title, reg_types, date_from, reg_types, date_from, date_to, reg_types, date_to, tuple(self.instance_ids))
37+ params = {
38+ 'period_title': period_title,
39+ 'j_type': reg_types,
40+ 'date_from': date_from,
41+ 'date_to': date_to,
42+ 'instance_ids': tuple(self.instance_ids),
43+ }
44 self.cr.execute(self.liquidity_sql, params)
45 cash_bank_res = self.cr.dictfetchall()
46- cash_bank_res = self._filter_journal_status(cash_bank_res)
47+ cash_bank_res = self._filter_journal_status(cash_bank_res, date_to)
48 cash_bank_res = reportvi.hq_report_ocb.postprocess_liquidity_balances(self, self.cr, self.uid, cash_bank_res,
49 encode=False, context=self.context)
50 res.extend(cash_bank_res)
51@@ -134,6 +141,32 @@
52 SELECT journal_id, account_id, SUM(col1) AS opening, SUM(col2) AS calculated, SUM(col3) AS closing
53 FROM (
54 (
55+ -- coo: export chq register empty
56+ SELECT j.id AS journal_id, j.default_debit_account_id AS account_id, 0 as col1, 0 as col2, 0 as col3
57+ FROM account_bank_statement st, account_journal j, account_period p
58+ WHERE
59+ st.journal_id = j.id
60+ AND st.period_id = p.id
61+ AND j.type = 'cheque'
62+ AND p.date_start >= %s
63+ AND p.date_stop <= %s
64+ GROUP BY j.id, j.default_debit_account_id
65+ )
66+ UNION
67+ (
68+ -- hq: export cheque register if at least 1 line exists
69+ SELECT aml.journal_id AS journal_id, aml.account_id AS account_id, 0.00 as col1, 0.00 as col2, 0.00 as col3
70+ FROM account_move_line AS aml, account_journal j
71+ WHERE
72+ aml.journal_id = j.id
73+ AND j.type = 'cheque'
74+ AND aml.date >= %s
75+ AND aml.date <= %s
76+ AND aml.account_id IN (j.default_debit_account_id, j.default_credit_account_id)
77+ GROUP BY aml.journal_id, aml.account_id
78+ )
79+ UNION
80+ (
81 SELECT journal_id, account_id, ROUND(SUM(amount_currency), 2) as col1, 0.00 as col2, 0.00 as col3
82 FROM account_move_line
83 WHERE id IN %s
84@@ -158,10 +191,10 @@
85 # ensure not to have empty arrays to avoid crash at query execution...
86 pending_chq_starting_bal_ids = pending_chq_starting_bal_ids or [-1]
87 pending_chq_closing_bal_ids = pending_chq_closing_bal_ids or [-1]
88- cheque_params = (period_title, tuple(pending_chq_starting_bal_ids), tuple(pending_chq_closing_bal_ids), tuple(self.instance_ids))
89+ cheque_params = (period_title, date_from, date_to, date_from, date_to, tuple(pending_chq_starting_bal_ids), tuple(pending_chq_closing_bal_ids), tuple(self.instance_ids))
90 self.cr.execute(cheque_sql, cheque_params)
91 cheque_res = self.cr.dictfetchall()
92- cheque_res = self._filter_journal_status(cheque_res)
93+ cheque_res = self._filter_journal_status(cheque_res, date_to)
94 cheque_res = reportvi.hq_report_ocb.postprocess_liquidity_balances(self, self.cr, self.uid, cheque_res, encode=False, context=self.context)
95 res.extend(cheque_res)
96 # sort result by instance code and by journal code
97
98=== modified file 'bin/addons/register_accounting/report/report_liquidity_position.py'
99--- bin/addons/register_accounting/report/report_liquidity_position.py 2023-11-03 15:04:29 +0000
100+++ bin/addons/register_accounting/report/report_liquidity_position.py 2024-05-07 10:18:00 +0000
101@@ -106,7 +106,7 @@
102 reg_obj = pool.get('account.bank.statement')
103 journal_obj = pool.get('account.journal')
104 # bank and cash journals (for cheques, see getPendingCheques)
105- journal_ids = journal_obj.search(self.cr, self.uid, [('type', 'in', ['bank', 'cash']), ('is_active', '=', True)], order='NO_ORDER')
106+ journal_ids = journal_obj.search(self.cr, self.uid, [('type', 'in', ['bank', 'cash'])], order='NO_ORDER')
107 args = [('period_id', '=', self.period_id), ('journal_id', 'in', journal_ids)]
108 reg_ids = reg_obj.search(self.cr, self.uid, args, order='journal_id')
109 regs = reg_obj.browse(self.cr, self.uid, reg_ids, context={'lang': self.localcontext.get('lang')})
110@@ -301,7 +301,7 @@
111
112 # get the cheque registers for the selected period and previous ones IF the one of the selected period exists
113 journal_ids = []
114- for j_id in journal_obj.search(self.cr, self.uid, [('type', '=', 'cheque'), ('is_active', '=', True)], order='NO_ORDER'):
115+ for j_id in journal_obj.search(self.cr, self.uid, [('type', '=', 'cheque')], order='NO_ORDER'):
116 if reg_obj.search_exist(self.cr, self.uid, [('journal_id', '=', j_id), ('period_id', '=', self.period_id)]):
117 journal_ids.append(j_id)
118 period_ids = period_obj.search(self.cr, self.uid,
119
120=== modified file 'bin/addons/vertical_integration/report/hq_report_ocb.py'
121--- bin/addons/vertical_integration/report/hq_report_ocb.py 2024-03-15 10:42:56 +0000
122+++ bin/addons/vertical_integration/report/hq_report_ocb.py 2024-05-07 10:18:00 +0000
123@@ -321,18 +321,31 @@
124 # request & postprocess method used for OCP VI, and for Liquidity Balances report
125 # NOTE: the Liquidity Bal. report is actually not included in OCB VI anymore, so all liquidity-related code in this file could sometime be moved
126 liquidity_sql = """
127- SELECT i.code AS instance, j.code, j.id, %s AS period, req.opening, req.calculated, req.closing, c.name AS currency
128+ SELECT i.code AS instance, j.code, j.id, %(period_title)s AS period, req.opening, req.calculated, req.closing, c.name AS currency
129 FROM res_currency c,
130 (
131 SELECT journal_id, account_id, SUM(col1) AS opening, SUM(col2) AS calculated, SUM(col3) AS closing
132 FROM (
133 (
134+ -- export new register with no lines
135+ SELECT j.id AS journal_id, j.default_debit_account_id AS account_id, 0 as col1, 0 as col2, 0 as col3
136+ FROM account_bank_statement st, account_journal j, account_period p
137+ WHERE
138+ st.journal_id = j.id
139+ AND st.period_id = p.id
140+ AND j.type IN %(j_type)s
141+ AND p.date_start >= %(date_from)s
142+ AND p.date_stop <= %(date_to)s
143+ GROUP BY j.id, j.default_debit_account_id
144+ )
145+ UNION
146+ (
147 SELECT aml.journal_id AS journal_id, aml.account_id AS account_id, ROUND(SUM(amount_currency), 2) as col1, 0.00 as col2, 0.00 as col3
148 FROM account_move_line AS aml
149 LEFT JOIN account_journal j
150 ON aml.journal_id = j.id
151- WHERE j.type IN %s
152- AND aml.date < %s
153+ WHERE j.type IN %(j_type)s
154+ AND aml.date < %(date_from)s
155 AND aml.account_id IN (j.default_debit_account_id, j.default_credit_account_id)
156 GROUP BY aml.journal_id, aml.account_id
157 )
158@@ -342,8 +355,8 @@
159 FROM account_move_line AS aml
160 LEFT JOIN account_journal j
161 ON aml.journal_id = j.id
162- WHERE j.type IN %s
163- AND aml.date >= %s AND aml.date <= %s
164+ WHERE j.type IN %(j_type)s
165+ AND aml.date >= %(date_from)s AND aml.date <= %(date_to)s
166 AND aml.account_id IN (j.default_debit_account_id, j.default_credit_account_id)
167 GROUP BY aml.journal_id, aml.account_id
168 )
169@@ -353,8 +366,8 @@
170 FROM account_move_line AS aml
171 LEFT JOIN account_journal j
172 ON aml.journal_id = j.id
173- WHERE j.type IN %s
174- AND aml.date <= %s
175+ WHERE j.type IN %(j_type)s
176+ AND aml.date <= %(date_to)s
177 AND aml.account_id IN (j.default_debit_account_id, j.default_credit_account_id)
178 GROUP BY aml.journal_id, aml.account_id
179 )
180@@ -365,7 +378,7 @@
181 WHERE req.journal_id = j.id
182 AND j.instance_id = i.id
183 AND j.currency = c.id
184- AND j.instance_id IN %s;
185+ AND j.instance_id IN %(instance_ids)s;
186 """
187
188
189
190=== modified file 'bin/addons/vertical_integration/report/hq_report_ocp.py'
191--- bin/addons/vertical_integration/report/hq_report_ocp.py 2023-05-10 07:56:54 +0000
192+++ bin/addons/vertical_integration/report/hq_report_ocp.py 2024-05-07 10:18:00 +0000
193@@ -541,8 +541,13 @@
194 'Closing balance', 'Currency'],
195 'filename': liquidity_balance_filename,
196 'key': 'liquidity',
197- 'query_params': (tuple([period_yyyymm]), reg_types, first_day_of_period, reg_types, first_day_of_period,
198- last_day_of_period, reg_types, last_day_of_period, tuple(instance_ids)),
199+ 'dict_query_params': {
200+ 'period_title': period_yyyymm,
201+ 'j_type': reg_types,
202+ 'date_from': first_day_of_period,
203+ 'date_to': last_day_of_period,
204+ 'instance_ids': tuple(instance_ids),
205+ },
206 'function': 'postprocess_liquidity_balances',
207 'fnct_params': context,
208 }

Subscribers

People subscribed via source and target branches