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

Proposed by jftempo
Status: Merged
Merged at revision: 6178
Proposed branch: lp:~julie-w/unifield-server/US-9596
Merge into: lp:unifield-server
Diff against target: 412 lines (+187/-55)
6 files modified
bin/addons/account/account.py (+32/-1)
bin/addons/analytic_distribution/analytic_distribution_wizard_view.xml (+1/-1)
bin/addons/msf_profile/i18n/fr_MF.po (+32/-1)
bin/addons/vertical_integration/report/hq_report_ocp.py (+50/-34)
bin/addons/vertical_integration/vertical_integration_wizard.xml (+27/-4)
bin/addons/vertical_integration/wizard/ocp_export.py (+45/-14)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-9596
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+415506@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/account.py'
2--- bin/addons/account/account.py 2022-02-01 15:56:05 +0000
3+++ bin/addons/account/account.py 2022-02-14 09:44:29 +0000
4@@ -1069,6 +1069,33 @@
5 class account_period(osv.osv):
6 _name = "account.period"
7 _description = "Account period"
8+
9+ def _get_false(self, cr, uid, ids, *a, **b):
10+ """
11+ Returns False for all ids (cf. only the search method is used for the field)
12+ """
13+ return {}.fromkeys(ids, False)
14+
15+ def _search_period_visible(self, cr, uid, obj, name, args, context=None):
16+ """
17+ Returns a domain with the periods to display, based on args looking like:
18+ [('period_visible', '=', [fiscalyear_id, instance_id, all_missions])]
19+ """
20+ if context is None:
21+ context = {}
22+ period_dom = []
23+ if args:
24+ if len(args[0]) < 3 or args[0][1] != '=' or not isinstance(args[0][2], list) or len(args[0][2]) < 3:
25+ raise osv.except_osv(_('Error'), _('Filter not implemented.'))
26+ fy_id = args[0][2][0]
27+ inst_id = args[0][2][1]
28+ all_missions = args[0][2][2]
29+ if all_missions:
30+ period_dom = [('number', '!=', 16), ('fiscalyear_id', '=', fy_id), ('state', '!=', 'created')]
31+ else:
32+ period_dom = [('number', '!=', 16), ('child_mission_closed', '=', [inst_id, fy_id])]
33+ return period_dom
34+
35 _columns = {
36 'name': fields.char('Period Name', size=64, required=True),
37 'code': fields.char('Code', size=24),
38@@ -1079,8 +1106,12 @@
39 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly',True)]}, select=True),
40 'state': fields.selection([('draft','Open'), ('done','Closed')], 'State', readonly=True,
41 help='When monthly periods are created. The state is \'Draft\'. At the end of monthly period it is in \'Done\' state.'),
42- 'company_id': fields.related('fiscalyear_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True)
43+ 'company_id': fields.related('fiscalyear_id', 'company_id', type='many2one', relation='res.company',
44+ string='Company', store=True, readonly=True),
45+ 'period_visible': fields.function(_get_false, method=True, type='boolean', string='Display the period', store=False,
46+ fnct_search=_search_period_visible),
47 }
48+
49 _defaults = {
50 'state': 'draft',
51 }
52
53=== modified file 'bin/addons/analytic_distribution/analytic_distribution_wizard_view.xml'
54--- bin/addons/analytic_distribution/analytic_distribution_wizard_view.xml 2020-09-24 13:33:19 +0000
55+++ bin/addons/analytic_distribution/analytic_distribution_wizard_view.xml 2022-02-14 09:44:29 +0000
56@@ -112,7 +112,7 @@
57 </p>
58
59 <script language="javascript">
60- var invalid_small_amount = $('#invalid_small_amount').val() || $('invalid_small_amount').text();
61+ var invalid_small_amount = $('#invalid_small_amount').val() || $('#invalid_small_amount').text();
62 if (invalid_small_amount) {
63 $('#label_invalid_small_amount').show();
64 }
65
66=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
67--- bin/addons/msf_profile/i18n/fr_MF.po 2022-02-08 14:19:11 +0000
68+++ bin/addons/msf_profile/i18n/fr_MF.po 2022-02-14 09:44:29 +0000
69@@ -65335,7 +65335,8 @@
70 msgid "wizard.import.mapping"
71 msgstr "wizard.import.mapping"
72
73-#. modules: register_accounting, analytic_override
74+#. modules: account, register_accounting, analytic_override
75+#: code:addons/account/account.py:1089
76 #: code:addons/analytic_override/analytic_line.py:80
77 #: code:addons/register_accounting/account_move_line.py:52
78 #, python-format
79@@ -113720,6 +113721,36 @@
80 msgid "Impossible to create a register on an inactive journal."
81 msgstr "Impossible de créer un registre sur un journal inactif."
82
83+#. module: account
84+#: field:account.period,period_visible:0
85+msgid "Display the period"
86+msgstr "Afficher la période"
87+
88+#. module: vertical_integration
89+#: view:ocp.export.wizard:0
90+msgid "The database name is not OCP_HQ. This will impact the DB ID column."
91+msgstr "Le nom de la base de données n'est pas OCP_HQ. Cela impactera la colonne DB ID."
92+
93+#. module: vertical_integration
94+#: field:ocp.export.wizard,all_missions:0
95+msgid "All Missions"
96+msgstr "Toutes les Missions"
97+
98+#. module: vertical_integration
99+#: view:ocp.export.wizard:0
100+msgid "or All Missions"
101+msgstr "ou Toutes les Missions"
102+
103+#. module: vertical_integration
104+#: help:ocp.export.wizard,all_missions:0
105+msgid "Generate the Monthly Export (only) for all missions at once"
106+msgstr "Génère le \"Monthly Export\" (uniquement) pour toutes les missions à la fois"
107+
108+#. module: vertical_integration
109+#: field:ocp.export.wizard,warning_db_name:0
110+msgid "Display a warning on database name"
111+msgstr "Affiche un avertissement sur le nom de la base de données"
112+
113 #. module: sync_client
114 #: field:sync_client.survey.user.detailed,answer_later:0
115 msgid "Answer later"
116
117=== modified file 'bin/addons/vertical_integration/report/hq_report_ocp.py'
118--- bin/addons/vertical_integration/report/hq_report_ocp.py 2019-12-13 15:56:37 +0000
119+++ bin/addons/vertical_integration/report/hq_report_ocp.py 2022-02-14 09:44:29 +0000
120@@ -53,7 +53,7 @@
121
122 def _get_journal_type_value(self, cr, uid, journal_type_key):
123 """
124- Returns the value of the Journal Type corresponding to the key in parameter (ex: inkind => In-kind Donation...)
125+ Returns the value of the Journal Type corresponding to the key in parameter (e.g. inkind => In-kind Donation...)
126 If no corresponding value is found, returns the key.
127 """
128 journal_types = self._get_journal_types(cr, uid)
129@@ -62,7 +62,7 @@
130 def _handle_od_ji_entries(self, cr, uid, data):
131 """
132 Takes data in parameter corresponding to ACCOUNT MOVE LINES (results from 'bs_entries' or 'plresult' requests)
133- 1) Replaces the journal type "key" by its corresponding "value" (ex: inkind => In-kind Donation)
134+ 1) Replaces the journal type "key" by its corresponding "value" (e.g. inkind => In-kind Donation)
135 2) Modifies it for all entries that originate from HQ entry corrections:
136 - instance: 'EAUD' or 'SIEG' if this matches the first 4 characters of the original HQ entry (if not: 'SIEG' by default)
137 - journal: the journal name corresponds to the 9-to-11 characters of the reference field of the original HQ entry
138@@ -106,7 +106,7 @@
139 def _handle_od_aji_entries(self, cr, uid, data):
140 """
141 Takes data in parameter corresponding to ACCOUNT ANALYTIC LINES (results from 'rawdata' request)
142- 1) Replaces the journal type "key" by its corresponding "value" (ex: inkind => In-kind Donation)
143+ 1) Replaces the journal type "key" by its corresponding "value" (e.g. inkind => In-kind Donation)
144 2) Modifies it for all entries that originate from HQ entry corrections:
145 - instance: 'EAUD' or 'SIEG' if this matches the first 4 characters of the original HQ entry (if not: 'SIEG' by default)
146 - journal: the journal name corresponds to the 9-to-11 characters of the reference field of the original HQ entry
147@@ -187,7 +187,7 @@
148 instance_code = line[instance_code_col][:3]
149 line[instance_code_col] = instance_code
150 line[cc_col] = instance_code
151- # Replaces the journal type "key" by its corresponding "value" (ex: inkind => In-kind Donation)
152+ # Replaces the journal type "key" by its corresponding "value" (e.g. inkind => In-kind Donation)
153 line[journal_type_col] = self._get_journal_type_value(cr, uid, line[journal_type_col])
154 return new_data
155
156@@ -285,7 +285,6 @@
157 m_obj = pool.get('account.move')
158 ml_obj = pool.get('account.move.line')
159 excluded_journal_types = ['hq', 'migration', 'inkind', 'extra'] # journal types that should not be used to take lines
160- reg_types = ('cash', 'bank', 'cheque')
161 # Fetch data from wizard
162 if not data.get('form', False):
163 raise osv.except_osv(_('Error'), _('No data retrieved. Check that the wizard is filled in.'))
164@@ -294,17 +293,14 @@
165 period_id = form.get('period_id', False)
166 instance_ids = form.get('instance_ids', False)
167 instance_id = form.get('instance_id', False)
168- if not fy_id or not period_id or not instance_ids or not instance_id:
169+ all_missions = form.get('all_missions', False)
170+ if not fy_id or not period_id or not instance_ids or (not instance_id and not all_missions):
171 raise osv.except_osv(_('Warning'), _('Some information is missing: either fiscal year or period or instance.'))
172 period = pool.get('account.period').browse(cr, uid, period_id, context=context,
173 fields_to_fetch=['date_start', 'date_stop', 'number'])
174 first_day_of_period = period.date_start
175- last_day_of_period = period.date_stop
176 tm = strptime(first_day_of_period, '%Y-%m-%d')
177 year_num = tm.tm_year
178- year = str(year_num)
179- month = '%02d' % (tm.tm_mon)
180- period_yyyymm = "{0}{1}".format(year, month)
181
182 # US-822: if December is picked should:
183 # - include Period 16 action 2 Year end PL RESULT entries
184@@ -471,14 +467,22 @@
185 # + If you cannot do a SQL request to create the content of the file, do a simple request (with key) and add a postprocess function that returns the result you want
186
187 # Define the file name according to the following format:
188- # First3DigitsOfInstanceCode_chosenPeriod_currentDatetime_Monthly_Export.csv (ex: KE1_201609_171116110306_Monthly_Export.csv)
189- inst = mi_obj.browse(cr, uid, instance_id, context=context, fields_to_fetch=['code'])
190- instance_code = inst and inst.code[:3] or ''
191+ # AllinstancesORFirst3CharactersOfInstanceCode_chosenPeriod_currentDatetime_Monthly_Export.csv
192+ # (e.g. KE1_201609_171116110306_Monthly_Export.csv)
193+ if all_missions:
194+ prefix = 'Allinstances'
195+ elif instance_id:
196+ inst = mi_obj.browse(cr, uid, instance_id, context=context, fields_to_fetch=['code'])
197+ prefix = inst and inst.code[:3] or ''
198+ else:
199+ prefix = ''
200 selected_period = strftime('%Y%m', strptime(first_day_of_period, '%Y-%m-%d')) or ''
201 current_time = time.strftime('%d%m%y%H%M%S')
202- monthly_export_filename = '%s_%s_%s_Monthly_Export.csv' % (instance_code, selected_period, current_time)
203- liquidity_balance_filename = '%s_%s_%s_Liquidity_Balances.csv' % (instance_code, selected_period, current_time)
204- account_balance_filename = '%s_%s_%s_Account_Balances.csv' % (instance_code, selected_period, current_time)
205+ monthly_export_filename = '%s_%s_%s_Monthly_Export.csv' % (prefix, selected_period, current_time)
206+ liquidity_balance_filename = account_balance_filename = ''
207+ if not all_missions:
208+ liquidity_balance_filename = '%s_%s_%s_Liquidity_Balances.csv' % (prefix, selected_period, current_time)
209+ account_balance_filename = '%s_%s_%s_Account_Balances.csv' % (prefix, selected_period, current_time)
210
211 processrequests = [
212 {
213@@ -509,25 +513,37 @@
214 'id': 0,
215 'object': 'account.move.line',
216 },
217- {
218- 'headers': ['Instance', 'Code', 'Name', 'Period', 'Starting balance', 'Calculated balance',
219- 'Closing balance', 'Currency'],
220- 'filename': liquidity_balance_filename,
221- 'key': 'liquidity',
222- 'query_params': (tuple([period_yyyymm]), reg_types, first_day_of_period, reg_types, first_day_of_period,
223- last_day_of_period, reg_types, last_day_of_period, tuple(instance_ids)),
224- 'function': 'postprocess_liquidity_balances',
225- 'fnct_params': context,
226- },
227- {
228- 'headers': ['Instance', 'Account', 'Account Name', 'Period', 'Starting balance', 'Calculated balance',
229- 'Closing balance', 'Booking Currency'],
230- 'filename': account_balance_filename,
231- 'key': 'account_balances_per_currency',
232- 'query_params': (tuple([period_yyyymm]), first_day_of_period, tuple(instance_ids), period.id,
233- tuple(instance_ids), last_day_of_period, tuple(instance_ids)),
234- },
235 ]
236+ if not all_missions:
237+ year = str(year_num)
238+ month = '%02d' % (tm.tm_mon)
239+ period_yyyymm = "{0}{1}".format(year, month)
240+ last_day_of_period = period.date_stop
241+ reg_types = ('cash', 'bank', 'cheque')
242+ # Liquidity Balances
243+ processrequests.append(
244+ {
245+ 'headers': ['Instance', 'Code', 'Name', 'Period', 'Starting balance', 'Calculated balance',
246+ 'Closing balance', 'Currency'],
247+ 'filename': liquidity_balance_filename,
248+ 'key': 'liquidity',
249+ 'query_params': (tuple([period_yyyymm]), reg_types, first_day_of_period, reg_types, first_day_of_period,
250+ last_day_of_period, reg_types, last_day_of_period, tuple(instance_ids)),
251+ 'function': 'postprocess_liquidity_balances',
252+ 'fnct_params': context,
253+ }
254+ )
255+ # Account Balances
256+ processrequests.append(
257+ {
258+ 'headers': ['Instance', 'Account', 'Account Name', 'Period', 'Starting balance',
259+ 'Calculated balance', 'Closing balance', 'Booking Currency'],
260+ 'filename': account_balance_filename,
261+ 'key': 'account_balances_per_currency',
262+ 'query_params': (tuple([period_yyyymm]), first_day_of_period, tuple(instance_ids), period.id,
263+ tuple(instance_ids), last_day_of_period, tuple(instance_ids)),
264+ },
265+ )
266 if plresult_ji_in_ids:
267 processrequests.append({
268 'filename': monthly_export_filename,
269
270=== modified file 'bin/addons/vertical_integration/vertical_integration_wizard.xml'
271--- bin/addons/vertical_integration/vertical_integration_wizard.xml 2021-01-07 13:19:21 +0000
272+++ bin/addons/vertical_integration/vertical_integration_wizard.xml 2022-02-14 09:44:29 +0000
273@@ -217,11 +217,34 @@
274 <field name="type">form</field>
275 <field name="arch" type="xml">
276 <form string="Export to HQ system">
277- <field name="instance_id" domain="['&amp;', ('level', '=', 'coordo'), ('instance_to_display_ids','=',True)]"
278- on_change="onchange_instance_id()"/>
279+ <field name="warning_db_name"/>
280+ <group colspan="6" col="2">
281+ <html>
282+ <p id="label_warning_db_name"
283+ style="text-align: center; color: red; font-weight: bold; font-size: 1.1em; display: none">
284+ <translate>The database name is not OCP_HQ. This will impact the DB ID column.</translate>
285+ </p>
286+ <script language="javascript">
287+ var warning_db_name = $('#warning_db_name').val() || $('#warning_db_name').text();
288+ if (warning_db_name) {
289+ $('#label_warning_db_name').show();
290+ }
291+ </script>
292+ </html>
293+ </group>
294+ <field name="instance_id"
295+ domain="['&amp;', ('level', '=', 'coordo'), ('instance_to_display_ids', '=', True)]"
296+ on_change="onchange_instance_id(instance_id)"
297+ attrs="{'required': [('all_missions', '=', False)]}"
298+ />
299 <field name="fiscalyear_id"/>
300- <field name="period_id" domain="[('child_mission_closed', '=', [instance_id, fiscalyear_id]), ('number', '&lt;', 16)]"/>
301- <newline/>
302+ <field name="all_missions"
303+ string="or All Missions"
304+ on_change="onchange_all_missions(all_missions)"
305+ />
306+ <field name="period_id"
307+ domain="[('period_visible', '=', [fiscalyear_id, instance_id, all_missions])]"
308+ />
309 <group colspan="6" col="4">
310 <label string="" colspan="2"/>
311 <button special="cancel" string="Cancel" colspan="1" icon="gtk-cancel"/>
312
313=== modified file 'bin/addons/vertical_integration/wizard/ocp_export.py'
314--- bin/addons/vertical_integration/wizard/ocp_export.py 2021-05-10 10:08:17 +0000
315+++ bin/addons/vertical_integration/wizard/ocp_export.py 2022-02-14 09:44:29 +0000
316@@ -32,23 +32,41 @@
317 _name = "ocp.export.wizard"
318
319 _columns = {
320- 'instance_id': fields.many2one('msf.instance', 'Top proprietary instance', required=True),
321+ 'instance_id': fields.many2one('msf.instance', 'Top proprietary instance'),
322 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal year', required=True),
323 'period_id': fields.many2one('account.period', 'Period', required=True),
324+ 'all_missions': fields.boolean('All Missions', help="Generate the Monthly Export (only) for all missions at once"),
325+ # a warning is displayed in case the DB name is not "OCP_HQ" (export done from a coordo or from a test environment),
326+ # as this impacts the DB ID column
327+ 'warning_db_name': fields.boolean('Display a warning on database name', invisible=True, readonly=True),
328 }
329
330 _defaults = {
331 'fiscalyear_id': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid, strftime('%Y-%m-%d'), context=c),
332+ 'all_missions': False,
333+ 'warning_db_name': lambda self, cr, uid, c: cr.dbname != 'OCP_HQ',
334 }
335
336- def onchange_instance_id(self, cr, uid, ids, context=None):
337- '''
338- Reset the period field when another prop. instance is selected.
339- Cover the case when in HQ the user selects a period mission-closed in a coordo,
340- and then select another coordo in which the period previously selected is not mission-closed
341- '''
342+ def onchange_instance_id(self, cr, uid, ids, instance_id, context=None):
343+ """
344+ - Resets the period field when another prop. instance is selected.
345+ Covers the case when in HQ the user selects a period mission-closed in a coordo,
346+ and then select another coordo in which the period previously selected is not mission-closed.
347+ - Also resets the tick box "All Missions" as soon as a Prop. Instance is selected.
348+ """
349 res = {}
350 res['value'] = {'period_id': False}
351+ if instance_id:
352+ res['value'].update({'all_missions': False})
353+ return res
354+
355+ def onchange_all_missions(self, cr, uid, ids, all_missions, context=None):
356+ """
357+ Resets the Prop. Instance field when "All Missions" is ticked
358+ """
359+ res = {}
360+ if all_missions:
361+ res['value'] = {'instance_id': False}
362 return res
363
364 def button_ocp_export_to_hq(self, cr, uid, ids, context=None):
365@@ -67,27 +85,40 @@
366 # add parameters
367 data['form'] = {}
368 inst = None
369+ all_missions = False
370+ instance_ids = []
371 period = None
372- if wizard.instance_id:
373+ if wizard.all_missions:
374+ all_missions = True
375+ instance_ids = self.pool.get('msf.instance').search(cr, uid, [('level', '!=', 'section')], order='NO_ORDER', context=context)
376+ elif wizard.instance_id:
377 # Get projects below instance
378 inst = wizard.instance_id
379- data['form'].update({'instance_id': inst.id, })
380- data['form'].update(
381- {'instance_ids': [inst.id] + [x.id for x in inst.child_ids]})
382+ instance_ids = [inst.id] + [x.id for x in inst.child_ids]
383+ data['form'].update({
384+ 'instance_id': inst and inst.id or None,
385+ 'instance_ids': instance_ids,
386+ 'all_missions': all_missions,
387+ })
388 if wizard.period_id:
389 period = wizard.period_id
390 data['form'].update({'period_id': period.id})
391 if wizard.fiscalyear_id:
392 data['form'].update({'fiscalyear_id': wizard.fiscalyear_id.id})
393 # The file name is composed of:
394- # - the first 3 digits of the Prop. Instance code
395+ # - the first 3 characters of the Prop. Instance code or "Allinstances"
396 # - the year and month of the selected period
397 # - the current datetime
398 # Ex: KE1_201609_171116110306_Formatted_data_UF_to_OCP_HQ_System
399- instance_code = inst and inst.code[:3] or ''
400+ if all_missions:
401+ prefix = 'Allinstances'
402+ elif inst:
403+ prefix = inst.code[:3]
404+ else:
405+ prefix = ''
406 selected_period = period and strftime('%Y%m', strptime(period.date_start, '%Y-%m-%d')) or ''
407 current_time = time.strftime('%d%m%y%H%M%S')
408- data['target_filename'] = '%s_%s_%s_Formatted_data_UF_to_OCP_HQ_System' % (instance_code, selected_period, current_time)
409+ data['target_filename'] = '%s_%s_%s_Formatted_data_UF_to_OCP_HQ_System' % (prefix, selected_period, current_time)
410
411 background_id = self.pool.get('memory.background.report').create(cr, uid, {
412 'file_name': data['target_filename'],

Subscribers

People subscribed via source and target branches