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

Proposed by jftempo
Status: Merged
Merged at revision: 5048
Proposed branch: lp:~julie-w/unifield-server/US-4359
Merge into: lp:unifield-server
Diff against target: 311 lines (+72/-45)
6 files modified
bin/addons/account_mcdb/account_view.xml (+2/-0)
bin/addons/account_override/account_move_line.py (+6/-0)
bin/addons/msf_currency_revaluation/account.py (+27/-15)
bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation.py (+19/-20)
bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation_view.xml (+1/-2)
bin/addons/msf_profile/i18n/fr_MF.po (+17/-8)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-4359
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+349144@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_mcdb/account_view.xml'
2--- bin/addons/account_mcdb/account_view.xml 2018-04-20 14:30:11 +0000
3+++ bin/addons/account_mcdb/account_view.xml 2018-07-09 08:36:14 +0000
4@@ -284,6 +284,8 @@
5 <field name="reconcile_date" invisible="1"/>
6 <field name="unreconcile_date" invisible="1"/>
7 <field name="unreconcile_txt" invisible="1"/>
8+ <field name="revaluation_reference" invisible="1"/>
9+ <field name="revaluation_date" invisible="1"/>
10 <field name="state"/>
11 </tree>
12 </field>
13
14=== modified file 'bin/addons/account_override/account_move_line.py'
15--- bin/addons/account_override/account_move_line.py 2018-03-28 09:49:33 +0000
16+++ bin/addons/account_override/account_move_line.py 2018-07-09 08:36:14 +0000
17@@ -340,6 +340,9 @@
18 'imported': fields.related('move_id', 'imported', string='Imported', type='boolean', required=False, readonly=True),
19 'is_si_refund': fields.boolean('Is a SI refund line', help="In case of a refund Cancel or Modify all the lines linked "
20 "to the original SI and to the SR created are marked as 'is_si_refund'"),
21+ 'revaluation_date': fields.datetime(string='Revaluation date'),
22+ 'revaluation_reference': fields.char(string='Revaluation reference', size=64,
23+ help="Entry sequence of the related Revaluation Entry"),
24 }
25
26 _defaults = {
27@@ -634,6 +637,7 @@
28 - the unreconciliation date
29 - the old reconciliation ref (unreconcile_txt)
30 - the tag 'is_si_refund'
31+ - the fields related to revaluation
32 """
33 if context is None:
34 context = {}
35@@ -645,6 +649,8 @@
36 'unreconcile_date': None,
37 'unreconcile_txt': '',
38 'is_si_refund': False,
39+ 'revaluation_date': None,
40+ 'revaluation_reference': '',
41 })
42 return super(account_move_line, self).copy(cr, uid, aml_id, default, context=context)
43
44
45=== modified file 'bin/addons/msf_currency_revaluation/account.py'
46--- bin/addons/msf_currency_revaluation/account.py 2017-07-25 08:03:34 +0000
47+++ bin/addons/msf_currency_revaluation/account.py 2018-07-09 08:36:14 +0000
48@@ -63,16 +63,16 @@
49 _defaults = {'currency_revaluation': False}
50
51 _sql_mapping = {
52- 'balance': "COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance",
53- 'debit': "COALESCE(SUM(l.debit), 0) as debit",
54- 'credit': "COALESCE(SUM(l.credit), 0) as credit",
55- # US-1251: booking balance mapping: use directly booking balance vs JI amount_currency as we have discrepedencies
56- 'foreign_balance': "COALESCE(SUM(l.debit_currency),0) - COALESCE(SUM(l.credit_currency), 0) as foreign_balance"
57- #'foreign_balance': "COALESCE(SUM(l.amount_currency), 0) as foreign_balance"
58+ 'balance': "COALESCE(l.debit, 0) - COALESCE(l.credit, 0) as balance",
59+ 'debit': "COALESCE(l.debit, 0) as debit",
60+ 'credit': "COALESCE(l.credit, 0) as credit",
61+ # US-1251: booking balance mapping: use directly booking balance vs JI amount_currency as we have discrepancies
62+ 'foreign_balance': "COALESCE(l.debit_currency, 0) - COALESCE(l.credit_currency, 0) as foreign_balance"
63 }
64
65 def _revaluation_query(self, cr, uid, ids, revaluation_date, context=None):
66- query = ("SELECT l.account_id as id, l.currency_id, l.reconcile_id, " +
67+ query = ("SELECT l.account_id as id, l.currency_id, l.reconcile_id, "
68+ " l.id AS aml_id, " +
69 ', '.join(self._sql_mapping.values()) +
70 " FROM account_move_line l"
71 " inner join account_period p on p.id = l.period_id"
72@@ -80,8 +80,7 @@
73 " l.date <= %(revaluation_date)s AND"
74 " l.currency_id IS NOT NULL AND"
75 " l.state <> 'draft' AND"
76- " p.number != 0" # US-1251 exclude IB entries period 0 for monthly and yearly
77- " GROUP BY l.account_id, l.currency_id, l.reconcile_id")
78+ " p.number != 0;") # US-1251 exclude IB entries period 0 for monthly and yearly
79 params = {'revaluation_date': revaluation_date,
80 'account_ids': tuple(ids)}
81 return query, params
82@@ -92,6 +91,8 @@
83 if context is None:
84 context = {}
85 accounts = {}
86+ entries_included = {}
87+ reconciliations = {}
88 aml_obj = self.pool.get('account.move.line')
89
90 # Compute for each account the balance/debit/credit from the move lines
91@@ -115,12 +116,23 @@
92 if len(period_ids) == 1 or not l['reconcile_id']:
93 line_to_keep = True
94 elif l['reconcile_id']:
95- # get the JIs with the same reconcile_id
96- aml_list = aml_obj.search(cr, uid, [('reconcile_id', '=', l['reconcile_id'])], order='NO_ORDER', context=context)
97- # check that at least one of them has a posting date later than the FY
98- if aml_obj.search_exist(cr, uid, [('id', 'in', aml_list), ('date', '>', revaluation_date)], context=context):
99- line_to_keep = True
100+ if l['reconcile_id'] in reconciliations:
101+ line_to_keep = reconciliations[l['reconcile_id']]
102+ else:
103+ # get the JIs with the same reconcile_id
104+ aml_list = aml_obj.search(cr, uid, [('reconcile_id', '=', l['reconcile_id'])], order='NO_ORDER', context=context)
105+ # check that at least one of them has a posting date later than the FY
106+ if aml_obj.search_exist(cr, uid, [('id', 'in', aml_list), ('date', '>', revaluation_date)], context=context):
107+ line_to_keep = True
108+ # store the result for this rec. to avoid re-doing the same computation several times
109+ reconciliations.update({l['reconcile_id']: line_to_keep})
110 if line_to_keep:
111+ # store by account and currency all the entries included in the reval
112+ if l['id'] not in entries_included: # l['id'] is the id of the account
113+ entries_included[l['id']] = {}
114+ if l['currency_id'] not in entries_included[l['id']]:
115+ entries_included[l['id']][l['currency_id']] = []
116+ entries_included[l['id']][l['currency_id']].append(l['aml_id'])
117 # generate a tree
118 # - account_id
119 # -- currency_id
120@@ -139,7 +151,7 @@
121 accounts[l['id']][l['currency_id']]['debit'] += l['debit']
122 accounts[l['id']][l['currency_id']]['balance'] += l['balance']
123
124- return accounts
125+ return accounts, entries_included
126
127 account_account()
128
129
130=== modified file 'bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation.py'
131--- bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation.py 2017-08-18 13:15:14 +0000
132+++ bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation.py 2018-07-09 08:36:14 +0000
133@@ -55,8 +55,6 @@
134 domain="[('fiscalyear_id', '=', fiscalyear_id), ('state', '!=', 'created')]"),
135 'result_period_internal_id': fields.many2one(
136 'account.period', string=_(u"Entry period"), invisible=True),
137- 'result_period_yearly_editable': fields.boolean(
138- 'Yearly revaluation applied ?', invisible=True),
139 'posting_date': fields.date(
140 _('Entry date'), readonly=True,
141 help=_("Revaluation entry date (document and posting date)")),
142@@ -91,7 +89,6 @@
143 'label': "%(currency)s %(account)s %(rate)s",
144 'revaluation_method': lambda *args: 'liquidity_month',
145 'fiscalyear_id': _get_default_fiscalyear_id,
146- 'result_period_yearly_editable': True,
147 }
148
149 def _get_last_yearly_reval_period_id(self, cr, uid, fy_id, context=None):
150@@ -279,7 +276,6 @@
151 return res
152
153 value = {
154- 'result_period_yearly_editable': True,
155 'msg': False,
156 }
157 warning = {}
158@@ -331,24 +327,15 @@
159 last_reval_period = self._get_last_yearly_reval_period_id(
160 cr, uid, fiscalyear_id)
161 if last_reval_period:
162- # US-816: liquidity or BS can be processed in any order
163- # but the 2nd should always use the same period
164 period_number = last_reval_period.number
165- value['result_period_id'] = last_reval_period.id
166- value['result_period_yearly_editable'] = False
167- value['msg'] = _('One of the year-end revaluations has' \
168- ' already been processed. The next one will be' \
169- ' processed on the same period: %s.') % (
170- last_reval_period.name, )
171+ value['msg'] = _('One of the year-end revaluations has already been processed in the period "%s". '
172+ 'The next one will be processed in the selected period.') % (last_reval_period.name,)
173
174 # check period opened
175 check_period_res = self._check_period_opened(cr, uid,
176 fiscalyear.id, period_number)
177- if check_period_res[1]:
178- value['result_period_id'] = check_period_res[1]
179- else:
180- value['result_period_id'] = False
181 if not check_period_res[0] and check_period_res[2]:
182+ # non-blocking warning
183 warning = {
184 'title': _('Warning!'),
185 'message': check_period_res[2]
186@@ -358,8 +345,8 @@
187 ('number', '>', 12),
188 ('number', '<', 16),
189 ]
190- value['result_period_id'] = check_period_res[0] and \
191- check_period_res[1] or False
192+ # pre-select the period if it is opened
193+ value['result_period_id'] = check_period_res[0] and check_period_res[1] or False
194 else:
195 if period_id:
196 period = period_obj.browse(cr, uid, period_id)
197@@ -629,6 +616,7 @@
198 period_state_obj = self.pool.get('account.period.state')
199 account_obj = self.pool.get('account.account')
200 currency_obj = self.pool.get('res.currency')
201+ move_obj = self.pool.get('account.move')
202
203 company = user_obj.browse(cr, uid, uid).company_id
204
205@@ -820,8 +808,8 @@
206 msg = _(u"End year revaluation already performed")
207 raise osv.except_osv(_(u"Error"), msg)
208
209- # Get balance sums
210- account_sums = account_obj.compute_revaluations(
211+ # Get balance sums and entries included in the reval
212+ account_sums, entries_included = account_obj.compute_revaluations(
213 cr, uid, account_ids, period_ids, form.fiscalyear_id.id,
214 revaluation_date, form.revaluation_method, context=context)
215 for account_id, account_tree in account_sums.iteritems():
216@@ -845,6 +833,7 @@
217 context=context)
218 account_sums[account_id][currency_id].update(diff_balances)
219 # Create entries only after all computation have been done
220+ current_dt = datetime.datetime.now()
221 for account_id, account_tree in account_sums.iteritems():
222 for currency_id, sums in account_tree.iteritems():
223 # (US-1682) The adj_balance is rounded, otherwise the booking amount of the first reval entry would be
224@@ -862,13 +851,23 @@
225 account_id, currency_id, False, adj_balance,
226 label, rate, form, sums, context=context)
227 if move_id:
228+ move_name = move_obj.read(cr, uid, move_id, ['name'], context=context)['name']
229+ to_tag_ids = account_id in entries_included and currency_id in entries_included[account_id] and \
230+ entries_included[account_id][currency_id] or []
231+ to_tag_ids.extend(new_ids)
232 created_ids.extend(new_ids)
233 # Create a second journal entry that will offset the first one
234 # if the revaluation method is 'Other B/S'
235 if form.revaluation_method in ['liquidity_year', 'other_bs']:
236 move_id, rev_line_ids = self._reverse_other_bs_move_lines(
237 cr, uid, form, move_id, new_ids, context=context)
238+ to_tag_ids.extend(rev_line_ids)
239 created_ids.extend(rev_line_ids)
240+ # tag the entries revaluated, and the reval entry and reversal reval entry (only the leg on the revaluated account)
241+ cr.execute('UPDATE account_move_line '
242+ 'SET revaluation_date = %s, revaluation_reference = %s '
243+ 'WHERE id IN %s '
244+ 'AND account_id = %s;', (current_dt, move_name, tuple(to_tag_ids), account_id,))
245
246 if created_ids:
247 # Set all booking amount to 0 for revaluation lines
248
249=== modified file 'bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation_view.xml'
250--- bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation_view.xml 2016-06-08 09:53:49 +0000
251+++ bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation_view.xml 2018-07-09 08:36:14 +0000
252@@ -25,10 +25,9 @@
253 'required': [('revaluation_method', 'in', ['liquidity_year', 'other_bs'])]}"/>
254 <newline/>
255 <separator string="" colspan="6"/>
256- <field name="result_period_yearly_editable" />
257 <field name="result_period_internal_id" />
258 <field name="result_period_id"
259- attrs="{'readonly': ['|', ('revaluation_method', '=', 'liquidity_month'), ('result_period_yearly_editable', '=', False)]}"
260+ attrs="{'readonly': [('revaluation_method', '=', 'liquidity_month')]}"
261 on_change="on_change_result_period_id(result_period_id)"/>
262 <newline/>
263 <field name="posting_date"/>
264
265=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
266--- bin/addons/msf_profile/i18n/fr_MF.po 2018-06-15 12:30:42 +0000
267+++ bin/addons/msf_profile/i18n/fr_MF.po 2018-07-09 08:36:14 +0000
268@@ -46521,10 +46521,10 @@
269 msgstr "La Séquence Principale doit être différente de la séquence en cours !"
270
271 #. module: msf_currency_revaluation
272-#: code:addons/msf_currency_revaluation/wizard/wizard_currency_revaluation.py:339
273+#: code:addons/msf_currency_revaluation/wizard/wizard_currency_revaluation.py:330
274 #, python-format
275-msgid "One of the year-end revaluations has already been processed. The next one will be processed on the same period: %s."
276-msgstr "One of the year-end revaluations has already been processed. The next one will be processed on the same period: %s."
277+msgid "One of the year-end revaluations has already been processed in the period \"%s\". The next one will be processed in the selected period."
278+msgstr "L'une des réévaluations annuelles a déjà été effectuée dans la période \"%s\". La prochaine sera effectuée dans la période sélectionnée."
279
280 #. module: msf_tools
281 #: code:addons/msf_tools/automated_export.py:260
282@@ -76217,11 +76217,6 @@
283 msgid "State of Move Line"
284 msgstr "Statut de la Ligne de Transaction"
285
286-#. module: msf_currency_revaluation
287-#: field:wizard.currency.revaluation,result_period_yearly_editable:0
288-msgid "Yearly revaluation applied ?"
289-msgstr "Yearly revaluation applied ?"
290-
291 #. modules: account, msf_instance, account_override, msf_audittrail, sync_so, account_period_closing_level
292 #: model:ir.model,name:account.model_account_period
293 #: model:ir.model,name:account_override.model_account_period
294@@ -101265,3 +101260,17 @@
295 msgid "Not Invoice"
296 msgstr "Pas de Facture"
297
298+#. module: account_override
299+#: field:account.move.line,revaluation_date:0
300+msgid "Revaluation date"
301+msgstr "Date de la réévaluation"
302+
303+#. module: account_override
304+#: field:account.move.line,revaluation_reference:0
305+msgid "Revaluation reference"
306+msgstr "Référence de la réévaluation"
307+
308+#. module: account_override
309+#: help:account.move.line,revaluation_reference:0
310+msgid "Entry sequence of the related Revaluation Entry"
311+msgstr "Séquence de l'Entrée de Réévaluation associée"

Subscribers

People subscribed via source and target branches