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

Proposed by jftempo
Status: Merged
Merged at revision: 5151
Proposed branch: lp:~julie-w/unifield-server/US-2644
Merge into: lp:unifield-server
Diff against target: 978 lines (+480/-68)
11 files modified
bin/addons/account_override/__openerp__.py (+1/-0)
bin/addons/account_override/account_view.xml (+0/-10)
bin/addons/account_override/period.py (+42/-0)
bin/addons/account_override/wizard/__init__.py (+1/-0)
bin/addons/account_override/wizard/integrity_finance_wizard.py (+121/-0)
bin/addons/account_override/wizard/integrity_finance_wizard_view.xml (+63/-0)
bin/addons/board/queries_finance.py (+44/-32)
bin/addons/board/report/integrity.mako (+14/-6)
bin/addons/board/report/integrity_finance.py (+133/-2)
bin/addons/msf_profile/i18n/fr_MF.po (+60/-17)
bin/service/web_services.py (+1/-1)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-2644
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+358433@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_override/__openerp__.py'
2--- bin/addons/account_override/__openerp__.py 2016-02-04 16:43:13 +0000
3+++ bin/addons/account_override/__openerp__.py 2018-11-07 14:15:37 +0000
4@@ -43,6 +43,7 @@
5 'wizard/account_chart.xml',
6 'wizard/import_invoice.xml',
7 'wizard/split_invoice.xml',
8+ 'wizard/integrity_finance_wizard_view.xml',
9 'attachment_view.xml'
10 ],
11 'test': [],
12
13=== modified file 'bin/addons/account_override/account_view.xml'
14--- bin/addons/account_override/account_view.xml 2018-09-06 12:58:16 +0000
15+++ bin/addons/account_override/account_view.xml 2018-11-07 14:15:37 +0000
16@@ -206,15 +206,5 @@
17 menu="False"
18 />
19
20-
21- <menuitem
22- name="Entries Data Integrity"
23- action="board.integrity_finance"
24- id="menu_integrity_finance"
25- parent="account.menu_finance_generic_reporting"
26- sequence="100"
27- type="report.xml"
28- />
29-
30 </data>
31 </openerp>
32
33=== modified file 'bin/addons/account_override/period.py'
34--- bin/addons/account_override/period.py 2017-12-01 16:19:33 +0000
35+++ bin/addons/account_override/period.py 2018-11-07 14:15:37 +0000
36@@ -22,6 +22,8 @@
37 ##############################################################################
38
39 from osv import osv
40+from tools.translate import _
41+
42
43 def get_period_from_date(self, cr, uid, date=False, context=None):
44 """
45@@ -100,6 +102,42 @@
46 period_id = period_id and get_next_period_id(self, cr, uid, period_id, context=context)
47 return period_id or False
48
49+
50+def get_period_range(self, cr, uid, period_from_id, period_to_id, context=None):
51+ """
52+ Returns the ids of all the periods included between 2 other periods.
53+ Special periods 13 to 16 are included, period 0 is excluded.
54+ """
55+ if context is None:
56+ context = {}
57+ field_list = ['number', 'fiscalyear_id', 'date_start']
58+ initial_period = self.browse(cr, uid, period_from_id, fields_to_fetch=field_list, context=context)
59+ final_period = self.browse(cr, uid, period_to_id, fields_to_fetch=field_list, context=context)
60+ initial_fy_id = initial_period.fiscalyear_id.id
61+ initial_number = initial_period.number
62+ final_fy_id = final_period.fiscalyear_id.id
63+ final_number = final_period.number
64+ same_fy = initial_fy_id == final_fy_id
65+ if (final_period.date_start < initial_period.date_start) or \
66+ (same_fy and final_period.number < initial_period.number): # e.g. Period 13 2018 precedes Period 14 2018
67+ raise osv.except_osv(_('Error'), _("The End period can't precede the Start period."))
68+ if same_fy: # all the periods are within the same Fiscal Year
69+ period_dom = [
70+ ('number', '!=', 0),
71+ ('number', '>=', initial_number),
72+ ('number', '<=', final_number),
73+ ('fiscalyear_id', '=', initial_fy_id)]
74+ else:
75+ # ex: from Nov. 2018 to Jan. 2019 => Nov 2018 / Dec 2018 / Periods 13->16 2018 / Jan 2019
76+ period_dom = [
77+ ('number', '!=', 0),
78+ '|',
79+ '&', ('number', '>=', initial_number), ('fiscalyear_id', '=', initial_fy_id),
80+ '&', ('number', '<=', final_number), ('fiscalyear_id', '=', final_fy_id)]
81+ period_ids = self.search(cr, uid, period_dom, order='id', context=context)
82+ return period_ids
83+
84+
85 class account_period(osv.osv):
86 _name = 'account.period'
87 _inherit = 'account.period'
88@@ -116,5 +154,9 @@
89 def get_next_period_id_at_index(self, cr, uid, period_id, index, context=None):
90 return get_next_period_id_at_index(self, cr, uid, period_id, index, context)
91
92+ def get_period_range(self, cr, uid, period_from_id, period_to_id, context=None):
93+ return get_period_range(self, cr, uid, period_from_id, period_to_id, context=context)
94+
95+
96 account_period()
97 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
98
99=== modified file 'bin/addons/account_override/wizard/__init__.py'
100--- bin/addons/account_override/wizard/__init__.py 2017-08-02 09:28:06 +0000
101+++ bin/addons/account_override/wizard/__init__.py 2018-11-07 14:15:37 +0000
102@@ -2,3 +2,4 @@
103 import split_invoice
104 import import_invoice
105 import report_paid_invoices
106+import integrity_finance_wizard
107
108=== added file 'bin/addons/account_override/wizard/integrity_finance_wizard.py'
109--- bin/addons/account_override/wizard/integrity_finance_wizard.py 1970-01-01 00:00:00 +0000
110+++ bin/addons/account_override/wizard/integrity_finance_wizard.py 2018-11-07 14:15:37 +0000
111@@ -0,0 +1,121 @@
112+# -*- coding: utf-8 -*-
113+##############################################################################
114+#
115+# OpenERP, Open Source Management Solution
116+# Copyright (C) 2018 TeMPO Consulting, MSF. All Rights Reserved
117+#
118+# This program is free software: you can redistribute it and/or modify
119+# it under the terms of the GNU Affero General Public License as
120+# published by the Free Software Foundation, either version 3 of the
121+# License, or (at your option) any later version.
122+#
123+# This program is distributed in the hope that it will be useful,
124+# but WITHOUT ANY WARRANTY; without even the implied warranty of
125+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
126+# GNU Affero General Public License for more details.
127+#
128+# You should have received a copy of the GNU Affero General Public License
129+# along with this program. If not, see <http://www.gnu.org/licenses/>.
130+#
131+##############################################################################
132+
133+from osv import fields
134+from osv import osv
135+from tools.translate import _
136+
137+from datetime import datetime
138+
139+
140+class integrity_finance_wizard(osv.osv_memory):
141+ _name = 'integrity.finance.wizard'
142+
143+ _columns = {
144+ 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal year'),
145+ 'filter': fields.selection([
146+ ('filter_no', 'No Filters'),
147+ ('filter_date_doc', 'Document Date'),
148+ ('filter_date', 'Posting Date'),
149+ ('filter_period', 'Period')
150+ ], "Filter by", required=True),
151+ 'period_from': fields.many2one('account.period', 'Start period'),
152+ 'period_to': fields.many2one('account.period', 'End period'),
153+ 'date_from': fields.date("Start date"),
154+ 'date_to': fields.date("End date"),
155+ 'instance_ids': fields.many2many('msf.instance', 'integrity_finance_wizard_instance_rel',
156+ 'wizard_id', 'instance_id',
157+ string='Proprietary Instances'),
158+ }
159+
160+ _defaults = {
161+ 'filter': 'filter_no',
162+ }
163+
164+ def onchange_filter(self, cr, uid, ids, filter, context=None):
165+ """
166+ Adapts the date/period filter according to the selection made in "Filter by"
167+ """
168+ res = {}
169+ if filter == 'filter_no':
170+ res['value'] = {'period_from': False, 'period_to': False, 'date_from': False, 'date_to': False}
171+ elif filter in ('filter_date', 'filter_date_doc', ):
172+ res['value'] = {'period_from': False, 'period_to': False}
173+ elif filter == 'filter_period':
174+ res['value'] = {'date_from': False, 'date_to': False}
175+ return res
176+
177+ def onchange_fiscalyear_id(self, cr, uid, ids, fiscalyear_id, context=None):
178+ """
179+ (Only) if a FY is selected: resets the periods selected and restricts their domain to within the FY
180+ """
181+ res = {}
182+ if fiscalyear_id:
183+ res = {
184+ 'value': {
185+ 'period_from': False,
186+ 'period_to': False,
187+ },
188+ 'domain': {
189+ 'period_from': [('fiscalyear_id', '=', fiscalyear_id)],
190+ 'period_to': [('fiscalyear_id', '=', fiscalyear_id)],
191+ }
192+ }
193+ return res
194+
195+ def print_integrity_finance_report(self, cr, uid, ids, context=None):
196+ """
197+ Prints the "Entries Data Integrity" report
198+ """
199+ if context is None:
200+ context = {}
201+ if isinstance(ids, (int, long)):
202+ ids = [ids]
203+ user_obj = self.pool.get('res.users')
204+ wiz = self.browse(cr, uid, ids[0], context=context)
205+ data = {
206+ 'form': {},
207+ 'context': context,
208+ }
209+ # store the selected criteria
210+ data['form'].update({
211+ 'fiscalyear_id': wiz.fiscalyear_id and wiz.fiscalyear_id.id or False,
212+ 'filter': wiz.filter,
213+ 'period_from': wiz.period_from and wiz.period_from.id or False,
214+ 'period_to': wiz.period_to and wiz.period_to.id or False,
215+ 'date_from': wiz.date_from or False,
216+ 'date_to': wiz.date_to or False,
217+ 'instance_ids': wiz.instance_ids and [inst.id for inst in wiz.instance_ids],
218+ })
219+ company = user_obj.browse(cr, uid, uid, fields_to_fetch=['company_id'], context=context).company_id
220+ current_instance = company.instance_id and company.instance_id.code or ''
221+ current_date = datetime.today().strftime('%Y%m%d')
222+ data['target_filename'] = "%s %s %s" % (_('Entries Data Integrity'), current_instance, current_date)
223+ return {
224+ 'type': 'ir.actions.report.xml',
225+ 'report_name': 'integrity.finance',
226+ 'datas': data,
227+ 'context': context,
228+ }
229+
230+
231+integrity_finance_wizard()
232+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
233
234=== added file 'bin/addons/account_override/wizard/integrity_finance_wizard_view.xml'
235--- bin/addons/account_override/wizard/integrity_finance_wizard_view.xml 1970-01-01 00:00:00 +0000
236+++ bin/addons/account_override/wizard/integrity_finance_wizard_view.xml 2018-11-07 14:15:37 +0000
237@@ -0,0 +1,63 @@
238+<?xml version="1.0" encoding="utf-8"?>
239+<openerp>
240+ <data>
241+
242+ <!-- Entries Data Integrity - Wizard -->
243+ <record id="integrity_finance_wizard_view" model="ir.ui.view">
244+ <field name="name">Entries Data Integrity</field>
245+ <field name="model">integrity.finance.wizard</field>
246+ <field name="type">form</field>
247+ <field name="arch" type="xml">
248+ <form>
249+ <field name="instance_ids" domain="[('instance_to_display_ids', '=', True)]">
250+ <tree noteditable="1">
251+ <field name="code"/>
252+ <field name="name"/>
253+ </tree>
254+ </field>
255+ <field name="fiscalyear_id" on_change="onchange_fiscalyear_id(fiscalyear_id)"/>
256+ <notebook tabpos="up" colspan="4">
257+ <page string="Filters" name="filters">
258+ <field name="filter" on_change="onchange_filter(filter)" colspan="4"/>
259+ <separator string="Dates" colspan="4"/>
260+ <field name="date_from" attrs="{'readonly': [('filter', 'not in', ('filter_date', 'filter_date_doc'))],
261+ 'required': [('filter', 'in', ('filter_date', 'filter_date_doc'))]}" colspan="4"/>
262+ <field name="date_to" attrs="{'readonly': [('filter', 'not in', ('filter_date', 'filter_date_doc'))],
263+ 'required': [('filter', 'in', ('filter_date', 'filter_date_doc'))]}" colspan="4"/>
264+ <separator string="Periods" colspan="4"/>
265+ <field name="period_from"
266+ attrs="{'readonly': [('filter', '!=', 'filter_period')],
267+ 'required':[('filter', '=', 'filter_period')]}" colspan="4"/>
268+ <field name="period_to"
269+ attrs="{'readonly': [('filter', '!=', 'filter_period')],
270+ 'required':[('filter', '=', 'filter_period')]}" colspan="4"/>
271+ </page>
272+ </notebook>
273+ <group colspan="6" col="4">
274+ <button icon="gtk-cancel" string="Cancel" special="cancel" colspan="2"/>
275+ <button icon="gtk-print" string="Print" name="print_integrity_finance_report" type="object"
276+ default_focus="1" colspan="2"/>
277+ </group>
278+ </form>
279+ </field>
280+ </record>
281+
282+ <!-- Entries Data Integrity - Menu Entry -->
283+ <record id="action_integrity_finance_report" model="ir.actions.act_window">
284+ <field name="name">Entries Data Integrity</field>
285+ <field name="res_model">integrity.finance.wizard</field>
286+ <field name="type">ir.actions.act_window</field>
287+ <field name="view_type">form</field>
288+ <field name="view_mode">form</field>
289+ <field name="view_id" ref="integrity_finance_wizard_view"/>
290+ <field name="target">new</field>
291+ </record>
292+ <menuitem
293+ name="Entries Data Integrity"
294+ action="action_integrity_finance_report"
295+ id="menu_integrity_finance_report"
296+ parent="account.menu_finance_generic_reporting"
297+ sequence="100"/>
298+
299+ </data>
300+</openerp>
301
302=== modified file 'bin/addons/board/queries_finance.py'
303--- bin/addons/board/queries_finance.py 2018-02-19 16:13:36 +0000
304+++ bin/addons/board/queries_finance.py 2018-11-07 14:15:37 +0000
305@@ -7,6 +7,7 @@
306
307 queries = [
308 {
309+ 'ref': 'ji_unbalanced_booking',
310 'title': _('Journal Items that are not balanced in booking currency'),
311 'headers': [_('Period'), _('Entry Sequence'), _('Difference')],
312 'query': """select p.name period, m.name, sum(l.credit_currency-l.debit_currency) difference
313@@ -20,12 +21,14 @@
314 m.state='posted' and
315 m.journal_id = j.id and
316 j.type != 'system'
317+%s
318 group by p.name, m.name, l.move_id, p.date_start
319 having abs(sum(l.credit_currency-l.debit_currency)) > 0.00001
320-order by p.date_start, m.name
321+order by p.date_start, m.name;
322 """
323 },
324 {
325+ 'ref': 'ji_unbalanced_fctal',
326 'title': _('Journal Items that are not balanced in functional currency'),
327 'headers': [_('Period'), _('Entry Sequence'), _('Difference')],
328 'query': """select p.name period, m.name, sum(l.credit-l.debit) difference
329@@ -39,82 +42,91 @@
330 m.state='posted' and
331 m.journal_id = j.id and
332 j.type != 'system'
333+%s
334 group by p.name, m.name, l.move_id, p.date_start
335 having abs(sum(l.credit-l.debit)) > 0.00001
336-order by p.date_start, m.name"""
337+order by p.date_start, m.name;"""
338 },
339 {
340+ 'ref': 'mismatch_ji_aji_booking',
341 'title': _('P&L Journal Items vs Analytic Journal Items mismatch in booking currency (except FXA and REV)'),
342 'headers': [_('Period'), _('Entry Sequence'), _('Account Code'), _('JI Book. Amount'), _('AJI Book. Amount'), _('Difference')],
343 'query': """SELECT
344 account_period.name,
345-account_move.name,
346+m.name,
347 account_account.code,
348-avg(account_move_line.credit_currency-account_move_line.debit_currency) JI,
349+avg(l.credit_currency - l.debit_currency) JI,
350 sum(COALESCE(account_analytic_line.amount_currency, 0)) AJI,
351-abs(abs(avg(account_move_line.debit_currency-account_move_line.credit_currency)) - abs(sum(COALESCE(account_analytic_line.amount_currency, 0)))) difference
352+abs(abs(avg(l.debit_currency - l.credit_currency)) - abs(sum(COALESCE(account_analytic_line.amount_currency, 0)))) difference
353 FROM
354-account_move_line
355-JOIN account_move ON account_move.id = account_move_line.move_id
356-JOIN account_account ON account_account.id = account_move_line.account_id
357-JOIN account_journal ON account_journal.id = account_move.journal_id
358-JOIN account_period ON account_move.period_id = account_period.id
359-LEFT JOIN account_analytic_line on account_analytic_line.move_id = account_move_line.id
360+account_move_line l
361+JOIN account_move m ON m.id = l.move_id
362+JOIN account_account ON account_account.id = l.account_id
363+JOIN account_journal ON account_journal.id = m.journal_id
364+JOIN account_period ON m.period_id = account_period.id
365+LEFT JOIN account_analytic_line on account_analytic_line.move_id = l.id
366 LEFT JOIN account_analytic_account ON account_analytic_line.account_id = account_analytic_account.id
367 WHERE
368 account_journal.type not in ('system', 'revaluation', 'cur_adj') AND
369 account_account.is_analytic_addicted = 't' AND
370 account_analytic_account.category not in ('FREE1', 'FREE2')
371-GROUP BY account_period.name, account_move.name, account_move_line.id, account_period.date_start, account_account.code
372-HAVING abs(abs(avg(account_move_line.debit_currency-account_move_line.credit_currency)) - abs(sum(COALESCE(account_analytic_line.amount_currency, 0)))) > 0.00001
373-ORDER BY account_period.date_start, account_move.name"""
374+%s
375+GROUP BY account_period.name, m.name, l.id, account_period.date_start, account_account.code
376+HAVING abs(abs(avg(l.debit_currency - l.credit_currency)) - abs(sum(COALESCE(account_analytic_line.amount_currency, 0)))) > 0.00001
377+ORDER BY account_period.date_start, m.name;"""
378 },
379 {
380+ 'ref': 'mismatch_ji_aji_fctal',
381 'title': _('P&L Journal Items vs Analytic Journal Items mismatch in functional currency (FXA and REV only)'),
382 'headers': [_('Period'), _('Entry Sequence'), _('Account Code'), _('JI Func. Amount'), _('AJI Func. Amount'), _('Difference')],
383 'query': """SELECT
384 account_period.name,
385-account_move.name,
386+m.name,
387 account_account.code,
388-avg(account_move_line.credit-account_move_line.debit) JI,
389+avg(l.credit - l.debit) JI,
390 sum(COALESCE(account_analytic_line.amount, 0)) AJI,
391-abs(avg(account_move_line.credit-account_move_line.debit) - sum(COALESCE(account_analytic_line.amount, 0))) difference
392+abs(avg(l.credit - l.debit) - sum(COALESCE(account_analytic_line.amount, 0))) difference
393 FROM
394-account_move_line
395-JOIN account_move ON account_move.id = account_move_line.move_id
396-JOIN account_account ON account_account.id = account_move_line.account_id
397-JOIN account_journal ON account_move.journal_id = account_journal.id
398-JOIN account_period ON account_period.id = account_move.period_id
399-LEFT JOIN account_analytic_line ON account_analytic_line.move_id = account_move_line.id
400+account_move_line l
401+JOIN account_move m ON m.id = l.move_id
402+JOIN account_account ON account_account.id = l.account_id
403+JOIN account_journal ON m.journal_id = account_journal.id
404+JOIN account_period ON account_period.id = m.period_id
405+LEFT JOIN account_analytic_line ON account_analytic_line.move_id = l.id
406 LEFT JOIN account_analytic_account ON account_analytic_line.account_id = account_analytic_account.id
407 WHERE
408 account_journal.type in ('revaluation', 'cur_adj') AND
409 account_account.is_analytic_addicted = 't' AND
410 account_analytic_account.category not in ('FREE1', 'FREE2')
411-GROUP BY account_period.name, account_move.name, account_move_line.id, account_period.date_start, account_account.code
412-HAVING abs(avg(account_move_line.credit-account_move_line.debit) - sum(COALESCE(account_analytic_line.amount, 0))) > 0.00001
413-order by account_period.date_start, account_move.name"""
414+%s
415+GROUP BY account_period.name, m.name, l.id, account_period.date_start, account_account.code
416+HAVING abs(avg(l.credit - l.debit) - sum(COALESCE(account_analytic_line.amount, 0))) > 0.00001
417+order by account_period.date_start, m.name;"""
418 },
419 {
420+ 'ref': 'unbalanced_rec_fctal',
421 'title': _('Unbalanced reconciliations in functional currency'),
422- 'headers': [_('Reconcile number'), _('Difference')],
423- 'query': """SELECT rec.name, sum(l.credit-l.debit)
424+ 'headers': [_('Reconcile number'), _('Reconcile date'), _('Difference')],
425+ 'query': """SELECT rec.name, 'rec_date', sum(l.credit-l.debit)
426 from account_move_line l, account_move_reconcile rec
427 where l.reconcile_id=rec.id
428+%s
429 group by rec.id, rec.name
430 having(abs(sum(l.credit-l.debit)) > 0.0001)
431-order by rec.name
432+order by rec.name;
433 """
434 },
435 {
436+ 'ref': 'unbalanced_rec_booking',
437 'title': _('Unbalanced reconciliations in booking currency'),
438- 'headers': [_('Reconcile number'), _('Difference')],
439- 'query': """SELECT rec.name, sum(l.credit_currency-l.debit_currency)
440+ 'headers': [_('Reconcile number'), _('Reconcile date'), _('Difference')],
441+ 'query': """SELECT rec.name, 'rec_date', sum(l.credit_currency-l.debit_currency)
442 from account_move_line l, account_move_reconcile rec
443 where l.reconcile_id=rec.id
444+%s
445 group by rec.id, rec.name
446 having(abs(sum(l.credit_currency-l.debit_currency)) > 0.0001 and count(distinct(l.currency_id))=1)
447-order by rec.name
448+order by rec.name;
449 """
450 },
451 ]
452
453=== modified file 'bin/addons/board/report/integrity.mako'
454--- bin/addons/board/report/integrity.mako 2016-11-09 16:46:03 +0000
455+++ bin/addons/board/report/integrity.mako 2018-11-07 14:15:37 +0000
456@@ -93,16 +93,24 @@
457 <Cell ss:StyleID="ssH"><Data ss:Type="String">${_t(header)|x}</Data></Cell>
458 % endfor
459 </Row>
460-% for result in get_results(check.get('query')):
461+% for result in get_results(check.get('query'), check.get('ref')):
462 <Row>
463 % for cell in result:
464- <Cell ss:StyleID="ssBorder">
465- % if isinstance(cell, (int, float, long)):
466- <Data ss:Type="Number">${cell}</Data>
467+ % if cell == 'rec_date':
468+ <%
469+ reconcile_ref = result[0]
470+ reconcile_date = get_reconcile_date(reconcile_ref)
471+ %>
472+ % if reconcile_date:
473+ <Cell ss:StyleID="sShortDate"><Data ss:Type="DateTime">${reconcile_date|n}T00:00:00.000</Data></Cell>
474+ % else:
475+ <Cell ss:StyleID="ssBorder"></Cell>
476+ % endif
477+ % elif isinstance(cell, (int, float, long)):
478+ <Cell ss:StyleID="ssBorder"><Data ss:Type="Number">${cell}</Data></Cell>
479 % else:
480- <Data ss:Type="String">${cell|x}</Data>
481+ <Cell ss:StyleID="ssBorder"><Data ss:Type="String">${cell|x}</Data></Cell>
482 % endif
483- </Cell>
484 %endfor
485 </Row>
486 % endfor
487
488=== modified file 'bin/addons/board/report/integrity_finance.py'
489--- bin/addons/board/report/integrity_finance.py 2016-11-02 09:29:48 +0000
490+++ bin/addons/board/report/integrity_finance.py 2018-11-07 14:15:37 +0000
491@@ -3,31 +3,162 @@
492 from report import report_sxw
493 from spreadsheet_xml.spreadsheet_xml_write import SpreadsheetReport
494 from board import queries_finance
495+from osv import osv
496 from tools.translate import _
497
498
499 class integrity_finance(report_sxw.rml_parse):
500 def __init__(self, cr, uid, name, context):
501 super(integrity_finance, self).__init__(cr, uid, name, context=context)
502+ self.sql_additional = "" # to add the criteria from the wizard filters
503+ self.sql_params = []
504+ self.sql_rec_additional = "" # specific to queries related to reconciliations
505+ self.sql_rec_params = []
506 self.localcontext.update({
507 'get_title': self.get_title,
508 'list_checks': self.list_checks,
509 'get_results': self.get_results,
510+ 'get_reconcile_date': self.get_reconcile_date,
511 '_t': self._t,
512 })
513
514+ def set_context(self, objects, data, ids, report_type=None):
515+ """
516+ Fills in:
517+ - self.sql_additional and self.sql_rec_additional with the part of SQL request corresponding to the criteria selected (string)
518+ - self.sql_params and self.sql_rec_params with the related parameters (list)
519+
520+ For reconciliation queries the reconciliation dates must be within the FY/periods/dates selected.
521+ For other queries the JI dates are used.
522+ """
523+ period_obj = self.pool.get('account.period')
524+ fy_obj = self.pool.get('account.fiscalyear')
525+ if data.get('form', False):
526+ # note: the JE id is used and not the JI one to make sure whole entries are retrieved (cf. JI doc dates can differ within a JE)
527+ sql_additional_subreq = """
528+ AND m.id IN
529+ (
530+ SELECT DISTINCT (m.id)
531+ FROM account_move m, account_move_line l
532+ WHERE l.move_id = m.id
533+ %s
534+ )
535+ """
536+ sql_rec_additional_subreq = """
537+ AND l.reconcile_id IN
538+ (
539+ SELECT DISTINCT (reconcile_id)
540+ FROM account_move_line
541+ WHERE reconcile_id IS NOT NULL
542+ %s
543+ )
544+ """
545+ # instances
546+ instance_ids = data['form'].get('instance_ids', False)
547+ if instance_ids:
548+ self.sql_additional += " AND l.instance_id IN %s "
549+ self.sql_params.append(tuple(instance_ids,))
550+ self.sql_rec_additional += " AND instance_id IN %s "
551+ self.sql_rec_params.append(tuple(instance_ids,))
552+ # FY
553+ fiscalyear_id = data['form'].get('fiscalyear_id', False)
554+ if fiscalyear_id:
555+ self.sql_additional += " AND l.period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s) "
556+ self.sql_params.append(fiscalyear_id)
557+ fiscalyear = fy_obj.browse(self.cr, self.uid, fiscalyear_id, fields_to_fetch=['date_start', 'date_stop'], context=data.get('context', {}))
558+ self.sql_rec_additional += " AND reconcile_date >= %s AND reconcile_date <= %s "
559+ self.sql_rec_params.append(fiscalyear.date_start)
560+ self.sql_rec_params.append(fiscalyear.date_stop)
561+ wiz_filter = data['form'].get('filter', '')
562+ # periods
563+ if wiz_filter == 'filter_period':
564+ period_from = data['form'].get('period_from', False)
565+ period_to = data['form'].get('period_to', False)
566+ if not period_from or not period_to:
567+ raise osv.except_osv(_('Error'), _('Either the Start period or the End period is missing.'))
568+ else:
569+ period_ids = period_obj.get_period_range(self.cr, self.uid, period_from, period_to, context=data.get('context', {}))
570+ if not period_ids:
571+ raise osv.except_osv(_('Error'), _('No period matches the selected criteria.'))
572+ self.sql_additional += " AND l.period_id IN %s "
573+ self.sql_params.append(tuple(period_ids,))
574+ per_from = period_obj.browse(self.cr, self.uid, period_from, fields_to_fetch=['date_start'], context=data.get('context', {}))
575+ per_to = period_obj.browse(self.cr, self.uid, period_to, fields_to_fetch=['date_stop'], context=data.get('context', {}))
576+ self.sql_rec_additional += " AND reconcile_date >= %s AND reconcile_date <= %s "
577+ self.sql_rec_params.append(per_from.date_start)
578+ self.sql_rec_params.append(per_to.date_stop)
579+ # dates
580+ if wiz_filter in ('filter_date_doc', 'filter_date'):
581+ date_from = data['form'].get('date_from', False)
582+ date_to = data['form'].get('date_to', False)
583+ if not date_from or not date_to:
584+ raise osv.except_osv(_('Error'), _('Either the Start date or the End date is missing.'))
585+ else:
586+ if wiz_filter == 'filter_date_doc':
587+ # JI doc dates
588+ self.sql_additional += " AND l.document_date >= %s AND l.document_date <= %s "
589+ else:
590+ # JI posting dates
591+ self.sql_additional += " AND l.date >= %s AND l.date <= %s "
592+ self.sql_params.append(date_from)
593+ self.sql_params.append(date_to)
594+ # reconciliation dates
595+ self.sql_rec_additional += " AND reconcile_date >= %s AND reconcile_date <= %s "
596+ self.sql_rec_params.append(date_from)
597+ self.sql_rec_params.append(date_to)
598+ # LAST STEP: if the request additional parts aren't empty: add the related subrequests
599+ if self.sql_additional:
600+ self.sql_additional = sql_additional_subreq % self.sql_additional
601+ if self.sql_rec_additional:
602+ self.sql_rec_additional = sql_rec_additional_subreq % self.sql_rec_additional
603+ return super(integrity_finance, self).set_context(objects, data, ids, report_type=report_type)
604+
605 def get_title(self):
606 return _('Entries Data Integrity')
607
608 def list_checks(self):
609 return queries_finance.queries
610
611- def get_results(self, sql):
612+ def get_results(self, sql, query_ref):
613 if not sql:
614 return []
615- self.cr.execute(sql)
616+ # reconciliation queries
617+ if query_ref in ('unbalanced_rec_fctal', 'unbalanced_rec_booking'):
618+ sql = sql % self.sql_rec_additional
619+ if self.sql_rec_params:
620+ self.cr.execute(sql, tuple(self.sql_rec_params))
621+ else:
622+ self.cr.execute(sql)
623+ # other queries
624+ else:
625+ sql = sql % self.sql_additional
626+ if self.sql_params:
627+ self.cr.execute(sql, tuple(self.sql_params))
628+ else:
629+ self.cr.execute(sql)
630 return self.cr.fetchall()
631
632+ def get_reconcile_date(self, reconcile_ref):
633+ """
634+ Returns the reconcile_date of the reconciliation in parameter (or None if the reconciled entries have no reconcile_date).
635+ Note that this date isn't retrieved directly in the original requests as there are old entries for which within a same reconciliation
636+ some lines have a reconcile_date and some others haven't any, so to be consistent the results can't be "grouped by" reconcile date.
637+ """
638+ reconcile_date = None
639+ if reconcile_ref:
640+ rec_date_sql = """
641+ SELECT reconcile_date
642+ FROM account_move_line
643+ WHERE reconcile_date IS NOT NULL
644+ AND reconcile_id = (SELECT id FROM account_move_reconcile WHERE name = %s LIMIT 1)
645+ LIMIT 1;
646+ """
647+ self.cr.execute(rec_date_sql, (reconcile_ref,))
648+ rec_date_res = self.cr.fetchone()
649+ if rec_date_res:
650+ reconcile_date = rec_date_res[0]
651+ return reconcile_date
652+
653 def _t(self, source):
654 return _(source)
655
656
657=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
658--- bin/addons/msf_profile/i18n/fr_MF.po 2018-10-30 10:56:14 +0000
659+++ bin/addons/msf_profile/i18n/fr_MF.po 2018-11-07 14:15:37 +0000
660@@ -10256,7 +10256,7 @@
661 msgid "Back Order of :"
662 msgstr "Back Order of :"
663
664-#. modules: purchase, account, msf_outgoing, financing_contract, register_accounting, sale, product_expiry, stock
665+#. modules: purchase, account, msf_outgoing, financing_contract, register_accounting, sale, product_expiry, stock, account_override
666 #: view:account.bank.statement:0
667 #: view:account.common.report:0
668 #: view:account.move:0
669@@ -10272,6 +10272,7 @@
670 #: view:stock.move:0
671 #: view:stock.picking:0
672 #: view:free.allocation.wizard:0
673+#: view:integrity.finance.wizard:0
674 msgid "Dates"
675 msgstr "Dates"
676
677@@ -10322,7 +10323,7 @@
678 #: code:addons/board/queries_finance.py:47
679 #, python-format
680 msgid "P&L Journal Items vs Analytic Journal Items mismatch in booking currency (except FXA and REV)"
681-msgstr "Différence en devise d'enregistrement entre entrées comptables et analytiques (exceptés FAX et REV)"
682+msgstr "Différence en devise d'enregistrement entre entrées comptables et analytiques (exceptés FXA et REV)"
683
684 #. modules: sale, msf_supply_doc_export
685 #: report:po.follow.up_rml:0
686@@ -17716,7 +17717,7 @@
687 msgid "Create Access"
688 msgstr "Créer l'Accès "
689
690-#. modules: account, base, procurement_request
691+#. modules: account, base, procurement_request, account_override
692 #: view:account.common.report:0
693 #: view:ir.actions.act_window:0
694 #: model:ir.actions.act_window,name:base.actions_ir_filters_view
695@@ -17724,6 +17725,7 @@
696 #: model:ir.model,name:base.model_ir_filters
697 #: model:ir.ui.menu,name:base.menu_ir_filters
698 #: view:sale.order:0
699+#: view:integrity.finance.wizard:0
700 msgid "Filters"
701 msgstr "Filtres"
702
703@@ -20061,7 +20063,9 @@
704 msgstr "MANIFESTE DE FRET"
705
706 #. modules: account_override, board
707-#: model:ir.ui.menu,name:account_override.menu_integrity_finance
708+#: model:ir.actions.act_window,name:account_override.action_integrity_finance_report
709+#: model:ir.ui.menu,name:account_override.menu_integrity_finance_report
710+#: code:addons/account_override/wizard/integrity_finance_wizard.py:111
711 #: code:addons/board/report/integrity_finance.py:20
712 #, python-format
713 msgid "Entries Data Integrity"
714@@ -22622,7 +22626,7 @@
715 msgid "Populate fields order"
716 msgstr "Remplir les champs commande"
717
718-#. modules: account, finance
719+#. modules: account, finance, account_override
720 #: field:account.aged.trial.balance,filter:0
721 #: field:account.balance.report,filter:0
722 #: field:account.bs.report,filter:0
723@@ -22639,6 +22643,7 @@
724 #: field:account.report.general.ledger,filter:0
725 #: field:account.vat.declaration,filter:0
726 #: field:wizard.account.partner.balance.tree,filter:0
727+#: field:integrity.finance.wizard,filter:0
728 msgid "Filter by"
729 msgstr "Filtrer par"
730
731@@ -24255,7 +24260,7 @@
732 msgid "Create Composition List"
733 msgstr "Créer une Liste de Composition"
734
735-#. modules: account, res_currency_tables, finance
736+#. modules: account, res_currency_tables, finance, account_override
737 #: field:account.common.partner.report,period_from:0
738 #: field:account.partner.balance,period_from:0
739 #: field:account.partner.ledger,period_from:0
740@@ -24274,6 +24279,7 @@
741 #: field:account.vat.declaration,period_from:0
742 #: field:wizard.report.currency.table,start_period_id:0
743 #: field:wizard.report.rates.table,start_period_id:0
744+#: field:integrity.finance.wizard,period_from:0
745 msgid "Start period"
746 msgstr "Période de début"
747
748@@ -25353,6 +25359,7 @@
749 #: report:addons/consumption_calculation/report/product_likely_expire_xls.mako:86
750 #: report:addons/account/report/free_allocation_report.mako:171
751 #: field:free.allocation.wizard,period_id:0
752+#: selection:integrity.finance.wizard,filter:0
753 #, python-format
754 msgid "Period"
755 msgstr "Période"
756@@ -27281,11 +27288,12 @@
757 msgid "The number of packages by layer"
758 msgstr "Le nombre de colis par couche"
759
760-#. modules: account_reconciliation, account
761+#. modules: account_reconciliation, account, board
762 #: selection:account.journal.column,field:0
763 #: field:account.move.line,reconcile_date:0
764+#: code:addons/board/queries_finance.py:100
765 msgid "Reconcile date"
766-msgstr "Reconcile date"
767+msgstr "Date de lettrage"
768
769 #. module: account
770 #: report:account.vat.declaration:0
771@@ -28368,7 +28376,7 @@
772 msgid "XML Identifier"
773 msgstr "Identifiant XML"
774
775-#. modules: msf_budget, account, stock_move_tracking, product, sale, stock_forecast, purchase_allocation_report, order_types
776+#. modules: msf_budget, account, stock_move_tracking, product, sale, stock_forecast, purchase_allocation_report, order_types, account_override
777 #: view:account.aged.trial.balance:0
778 #: view:account.analytic.Journal.report:0
779 #: view:account.analytic.balance:0
780@@ -28385,6 +28393,7 @@
781 #: view:wizard.fo.allocation.report:0
782 #: view:stock.forecast:0
783 #: view:stock.move.tracking:0
784+#: view:integrity.finance.wizard:0
785 msgid "Print"
786 msgstr "Imprimer"
787
788@@ -29745,10 +29754,11 @@
789 msgid "Fiscal Position Template"
790 msgstr "Modèle de Position Fiscale"
791
792-#. modules: account, finance
793+#. modules: account, finance, account_override
794 #: field:account.partner.balance,period_to:0
795 #: field:account.partner.ledger,period_to:0
796 #: field:wizard.account.partner.balance.tree,period_to:0
797+#: field:integrity.finance.wizard,period_to:0
798 msgid "End period"
799 msgstr "Période de fin"
800
801@@ -35001,7 +35011,7 @@
802 msgid "Shipment Date:"
803 msgstr "Shipment Date:"
804
805-#. modules: sales_followup, sync_client, procurement_request, sale, mission_stock, msf_doc_import, purchase_followup
806+#. modules: sales_followup, sync_client, procurement_request, sale, mission_stock, msf_doc_import, purchase_followup, account_override
807 #: field:msr_in_progress,start_date:0
808 #: field:abstract.wizard.import,start_date:0
809 #: field:wizard.import.batch,start_date:0
810@@ -35014,6 +35024,7 @@
811 #: field:po.track.changes.wizard,start_date:0
812 #: field:sale.loan.stock.moves,start_date:0
813 #: field:ir.track.changes.wizard,start_date:0
814+#: field:integrity.finance.wizard,date_from:0
815 msgid "Start date"
816 msgstr "Date de début"
817
818@@ -41033,7 +41044,7 @@
819 msgid "Name of the batch will be ignored because the batch is 'Internal' so name is created by the system"
820 msgstr "Le nom du batch sera ignoré car le batch est 'Interne' donc son nom sera créé par le système"
821
822-#. modules: account, msf_instance, finance, account_mcdb
823+#. modules: account, msf_instance, finance, account_mcdb, account_override
824 #: report:account.general.ledger_landscape:0
825 #: report:account.general.ledger_landscape_tb:0
826 #: report:account.partner.balance:0
827@@ -41058,6 +41069,7 @@
828 #: model:ir.actions.act_window,name:msf_instance.action_msf_instance_tree
829 #: model:ir.ui.menu,name:msf_instance.menu_action_msf_instance_tree
830 #: view:msf.instance:0
831+#: field:integrity.finance.wizard,instance_ids:0
832 msgid "Proprietary Instances"
833 msgstr "Instances Propriétaires"
834
835@@ -44422,13 +44434,14 @@
836 msgid "Reordering Mode"
837 msgstr "Mode de Réapprovisionnement"
838
839-#. modules: msf_doc_import, sale, sales_followup
840+#. modules: msf_doc_import, sale, sales_followups, account_override
841 #: field:abstract.wizard.import,end_date:0
842 #: field:wizard.import.batch,end_date:0
843 #: field:sale.donation.stock.moves,end_date:0
844 #: field:sale.order.sourcing.progress,end_date:0
845 #: field:ir.followup.location.wizard,end_date:0
846 #: field:sale.followup.multi.wizard,end_date:0
847+#: field:integrity.finance.wizard,date_to:0
848 msgid "End date"
849 msgstr "Date de fin"
850
851@@ -51614,7 +51627,7 @@
852 msgid "Donation Line"
853 msgstr "Donation Line"
854
855-#. module: account
856+#. modules: account, account_override
857 #: selection:account.aged.trial.balance,filter:0
858 #: selection:account.balance.report,filter:0
859 #: selection:account.bs.report,filter:0
860@@ -51630,6 +51643,7 @@
861 #: selection:account.print.journal,filter:0
862 #: selection:account.report.general.ledger,filter:0
863 #: selection:account.vat.declaration,filter:0
864+#: selection:integrity.finance.wizard,filter:0
865 msgid "No Filters"
866 msgstr "Aucun Filtre"
867
868@@ -54842,7 +54856,7 @@
869 msgid "Africa/Timbuktu"
870 msgstr "Africa/Timbuktu"
871
872-#. modules: account, finance, account_mcdb, analytic_distribution
873+#. modules: account, finance, account_mcdb, analytic_distribution, account_override
874 #: selection:account.aged.trial.balance,filter:0
875 #: selection:account.balance.report,filter:0
876 #: selection:account.bs.report,filter:0
877@@ -54879,6 +54893,7 @@
878 #: selection:wizard.account.partner.balance.tree,filter:0
879 #: view:account.period.state:0
880 #: view:account.analytic.chart:0
881+#: view:integrity.finance.wizard:0
882 #, python-format
883 msgid "Periods"
884 msgstr "Périodes"
885@@ -65785,7 +65800,7 @@
886 msgid "PO line to confirm"
887 msgstr "PO line to confirm"
888
889-#. modules: account, finance, account_mcdb, register_accounting, account_hq_entries, account_override, analytic, msf_accrual, vertical_integration
890+#. modules: account, finance, account_mcdb, register_accounting, account_hq_entries, account_override, analytic, msf_accrual, vertical_integration, board
891 #: field:account.bank.statement.line,date:0
892 #: field:account.invoice,date_invoice:0
893 #: report:combined.journals.report.pdf:0
894@@ -65826,6 +65841,7 @@
895 #: report:addons/register_accounting/report/pending_cheque_xls.mako:218
896 #: report:addons/vertical_integration/report/open_invoices_xls.mako:291
897 #: field:hq.entries.split,date:0
898+#: selection:integrity.finance.wizard,filter:0
899 #, python-format
900 msgid "Posting Date"
901 msgstr "Date de Comptabilisation"
902@@ -75641,7 +75657,7 @@
903 msgid "Update Sent Monitor"
904 msgstr "Surveillance des Mises à jour Envoyées"
905
906-#. modules: msf_budget, account, account_period_closing_level, finance, vertical_integration, msf_currency_revaluation, analytic_distribution
907+#. modules: msf_budget, account, account_period_closing_level, finance, vertical_integration, msf_currency_revaluation, analytic_distribution, account_override
908 #: field:account.aged.trial.balance,fiscalyear_id:0
909 #: field:account.balance.report,fiscalyear_id:0
910 #: field:account.bs.report,fiscalyear_id:0
911@@ -75672,6 +75688,7 @@
912 #: field:ocp.matching.export.wizard,fiscalyear_id:0
913 #: field:wizard.hq.report.oca,fiscalyear_id:0
914 #: field:wizard.hq.report.ocg,fiscalyear_id:0
915+#: field:integrity.finance.wizard,fiscalyear_id:0
916 #, python-format
917 msgid "Fiscal year"
918 msgstr "Exercice Comptable"
919@@ -97048,6 +97065,7 @@
920 #: selection:account.balance.report,filter:0
921 #: selection:account.journal.column,field:0
922 #: selection:account.report.general.ledger,filter:0
923+#: selection:integrity.finance.wizard,filter:0
924 #: code:addons/account/report/common_report_header.py:166
925 #: report:addons/account_mcdb/report/report_account_analytic_line_free_xls.mako:78
926 #: report:addons/account_override/report/open_invoices_xls.mako:330
927@@ -97764,6 +97782,7 @@
928 #: view:wizard.import.mapping:0
929 #: view:automated.export.job:0
930 #: view:free.allocation.wizard:0
931+#: view:integrity.finance.wizard:0
932 #, python-format
933 msgid "Cancel"
934 msgstr "Annuler"
935@@ -101982,6 +102001,30 @@
936 msgid "Related entries"
937 msgstr "Ecritures associées"
938
939+#. module: board
940+#: code:addons/board/report/integrity_finance.py:46
941+#, python-format
942+msgid "Either the Start period or the End period is missing."
943+msgstr "Il manque soit la Période de début soit la Période de fin."
944+
945+#. module: board
946+#: code:addons/board/report/integrity_finance.py:62
947+#, python-format
948+msgid "No period matches the selected criteria."
949+msgstr "Aucune période ne correspond aux critères sélectionnés."
950+
951+#. module: account_override
952+#: code:addons/account_override/period.py:129
953+#, python-format
954+msgid "The End period can't precede the Start period."
955+msgstr "La Période de fin ne peut pas précéder la Période de début."
956+
957+#. module: board
958+#: code:addons/board/report/integrity_finance.py:57
959+#, python-format
960+msgid "Either the Start date or the End date is missing."
961+msgstr "Il manque soit la Date de début soit la Date de fin."
962+
963 #. module: stock
964 #: code:addons/stock/physical_inventory.py:938
965 #, python-format
966
967=== modified file 'bin/service/web_services.py'
968--- bin/service/web_services.py 2018-10-05 08:17:24 +0000
969+++ bin/service/web_services.py 2018-11-07 14:15:37 +0000
970@@ -1104,7 +1104,7 @@
971 tb_s = "".join(traceback.format_exception(*tb))
972 logger = netsvc.Logger()
973 logger.notifyChannel('web-services', netsvc.LOG_ERROR,
974- 'Exception: %s\n%s' % (str(exception), tb_s))
975+ 'Exception: %s\n%s' % (tools.ustr(exception), tb_s))
976 if hasattr(exception, 'name') and hasattr(exception, 'value'):
977 self._reports[id]['exception'] = ExceptionWithTraceback(tools.ustr(exception.name), tools.ustr(exception.value))
978 else:

Subscribers

People subscribed via source and target branches