Merge lp:~unifield-team/unifield-server/us-816 into lp:unifield-server
- us-816
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 3872 |
Proposed branch: | lp:~unifield-team/unifield-server/us-816 |
Merge into: | lp:unifield-server |
Diff against target: |
529 lines (+223/-121) 2 files modified
bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation.py (+214/-117) bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation_view.xml (+9/-4) |
To merge this branch: | bzr merge lp:~unifield-team/unifield-server/us-816 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+300703@code.launchpad.net |
Commit message
Description of the change
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/msf_currency_revaluation/wizard/wizard_currency_revaluation.py' |
2 | --- bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation.py 2016-04-26 09:32:48 +0000 |
3 | +++ bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation.py 2016-07-21 08:16:38 +0000 |
4 | @@ -30,41 +30,45 @@ |
5 | _name = 'wizard.currency.revaluation' |
6 | |
7 | _columns = { |
8 | - 'revaluation_method': fields.selection( |
9 | - [('liquidity_month', _("Liquidity (Month-end)")), |
10 | - ('liquidity_year', _("Liquidity (Year-end)")), |
11 | - ('other_bs', _("Other B/S (Year-end)")), |
12 | - ], |
13 | - string=_("Revaluation method"), required=True), |
14 | - 'fiscalyear_id': fields.many2one( |
15 | - 'account.fiscalyear', string=_("Fiscal year"), |
16 | - domain=[('state', '=', 'draft')], |
17 | - required=True), |
18 | - 'period_id': fields.many2one( |
19 | - 'account.period', string=_("Period"), |
20 | - domain="[('fiscalyear_id', '=', fiscalyear_id)]"), |
21 | - 'currency_table_id': fields.many2one( |
22 | - 'res.currency.table', string=_("Currency table"), |
23 | - domain=[('state', '=', 'valid')]), |
24 | - 'journal_id': fields.many2one( |
25 | - 'account.journal', string=_("Entry journal"), |
26 | - help=_("Journal used for revaluation entries."), |
27 | - readonly=True), |
28 | - 'result_period_id': fields.many2one( |
29 | - 'account.period', string=_(u"Entry period"), required=True, |
30 | - domain="[('fiscalyear_id', '=', fiscalyear_id), ('state', '!=', 'created')]", |
31 | - help=_("Period used for revaluation entries."), |
32 | - readonly=True), |
33 | - 'posting_date': fields.date( |
34 | - _('Entry date'), readonly=True, |
35 | - help=_("Revaluation entry date (document and posting date)")), |
36 | - 'label': fields.char( |
37 | - 'Entry description', |
38 | - size=100, |
39 | - help="This label will be inserted in entries description." |
40 | - " You can use %(account)s, %(currency)s" |
41 | - " and %(rate)s keywords.", |
42 | - required=True), |
43 | + 'revaluation_method': fields.selection( |
44 | + [('liquidity_month', _("Liquidity (Month-end)")), |
45 | + ('liquidity_year', _("Liquidity (Year-end)")), |
46 | + ('other_bs', _("Other B/S (Year-end)")), |
47 | + ], |
48 | + string=_("Revaluation method"), required=True), |
49 | + 'fiscalyear_id': fields.many2one( |
50 | + 'account.fiscalyear', string=_("Fiscal year"), |
51 | + domain=[('state', '=', 'draft')], |
52 | + required=True), |
53 | + 'period_id': fields.many2one( |
54 | + 'account.period', string=_("Period"), |
55 | + domain="[('fiscalyear_id', '=', fiscalyear_id)]"), |
56 | + 'currency_table_id': fields.many2one( |
57 | + 'res.currency.table', string=_("Currency table"), |
58 | + domain=[('state', '=', 'valid')]), |
59 | + 'journal_id': fields.many2one( |
60 | + 'account.journal', string=_("Entry journal"), |
61 | + help=_("Journal used for revaluation entries."), |
62 | + readonly=True), |
63 | + 'result_period_id': fields.many2one( |
64 | + 'account.period', string=_(u"Entry period"), required=True, |
65 | + domain="[('fiscalyear_id', '=', fiscalyear_id)," \ |
66 | + " ('state', '!=', 'created')]"), |
67 | + 'result_period_internal_id': fields.many2one( |
68 | + 'account.period', string=_(u"Entry period"), invisible=True), |
69 | + 'result_period_yearly_editable': fields.boolean( |
70 | + 'Yearly revaluation applied ?', invisible=True), |
71 | + 'posting_date': fields.date( |
72 | + _('Entry date'), readonly=True, |
73 | + help=_("Revaluation entry date (document and posting date)")), |
74 | + 'label': fields.char( |
75 | + 'Entry description', |
76 | + size=100, |
77 | + help="This label will be inserted in entries description." |
78 | + " You can use %(account)s, %(currency)s" |
79 | + " and %(rate)s keywords.", |
80 | + required=True), |
81 | + 'msg': fields.text('Message'), |
82 | } |
83 | |
84 | def _get_default_fiscalyear_id(self, cr, uid, context=None): |
85 | @@ -88,7 +92,51 @@ |
86 | 'label': "%(currency)s %(account)s %(rate)s", |
87 | 'revaluation_method': lambda *args: 'liquidity_month', |
88 | 'fiscalyear_id': _get_default_fiscalyear_id, |
89 | + 'result_period_yearly_editable': True, |
90 | } |
91 | + |
92 | + def _get_last_yearly_reval_period_id(self, cr, uid, fy_id, context=None): |
93 | + """ |
94 | + for given fy has been any revaluation liquidity/BS processed ? |
95 | + :return tuple period/False, is liquidity |
96 | + :rtype: tuple (account.period/False, boolean) |
97 | + """ |
98 | + res = False |
99 | + |
100 | + # get rev journal of instance |
101 | + instance_id = self.pool.get('res.users').browse(cr, uid, uid, |
102 | + context=context).company_id.instance_id.id |
103 | + domain = [ |
104 | + ('type', '=', 'revaluation'), |
105 | + ('instance_id', '=', instance_id), |
106 | + ] |
107 | + rev_journal_id = self.pool.get('account.journal').search( |
108 | + cr, uid, domain, context=context)[0] |
109 | + |
110 | + # get potential target periods (13, 14, 15) |
111 | + domain = [ |
112 | + ('fiscalyear_id', '=', fy_id), |
113 | + ('state', '!=', 'created'), |
114 | + ('number', '>', 12), |
115 | + ('number', '<', 16), |
116 | + ] |
117 | + period_ids = self.pool.get('account.period').search( |
118 | + cr, uid, domain, context=context) |
119 | + |
120 | + # end year REV moves ? |
121 | + ji_obj = self.pool.get('account.move.line') |
122 | + fy_rec = self.pool.get('account.fiscalyear').browse( |
123 | + cr, uid, fy_id, context=context) |
124 | + domain = [ |
125 | + ('period_id', 'in', period_ids), |
126 | + ('name', 'like', "Revaluation - %s" % (fy_rec.name, )), |
127 | + ] |
128 | + ids = ji_obj.search(cr, uid, domain, context=context) |
129 | + if ids: |
130 | + # any moves: get period of last yearly reval (liquidity or bs) |
131 | + res = ji_obj.browse(cr, uid, ids[0], context=context).period_id |
132 | + |
133 | + return res |
134 | |
135 | def _is_revaluated(self, cr, uid, period_id, revaluation_method=False, |
136 | context=None): |
137 | @@ -127,12 +175,14 @@ |
138 | if comp_id.revaluation_default_account: |
139 | # do not count rev default account itself |
140 | account_ids_domain = [ |
141 | - ('account_id', '!=', comp_id.revaluation_default_account.id), |
142 | + ('account_id', '!=', |
143 | + comp_id.revaluation_default_account.id), |
144 | ] |
145 | else: |
146 | account_ids_domain = [] |
147 | if account_liquidity_ids: |
148 | - op = 'in' if revaluation_method == 'liquidity_year' else 'not in' |
149 | + op = 'in' if revaluation_method == 'liquidity_year' \ |
150 | + else 'not in' |
151 | account_ids_domain += [ |
152 | ('account_id', op, account_liquidity_ids), |
153 | ] |
154 | @@ -190,7 +240,8 @@ |
155 | period_ids = period_obj.get_period_from_date( |
156 | cr, uid, period_date.strftime('%Y-%m-%d')) |
157 | res['period_id'] = period_ids and period_ids[0] or False |
158 | - res['result_period_id'] = res['period_id'] |
159 | + res['result_period_internal_id'] = \ |
160 | + res['result_period_id'] = res['period_id'] |
161 | |
162 | # Journal |
163 | # UFTP-44: journal of instance and of type 'revaluation' |
164 | @@ -210,9 +261,11 @@ |
165 | # Book revaluation account check |
166 | revaluation_account = cp.revaluation_default_account |
167 | if not revaluation_account: |
168 | - raise osv.except_osv(_('Settings Error!'), _('Revaluation account is not set in company settings')) |
169 | + raise osv.except_osv(_('Settings Error!'), |
170 | + _('Revaluation account is not set in company settings')) |
171 | if not self.pool.get('res.company').check_revaluation_default_account_has_sup_destination(cr, uid, cp, context=context): |
172 | - raise osv.except_osv(_('Settings Error!'),_('The default revaluation account must have a default destination SUP')) |
173 | + raise osv.except_osv(_('Settings Error!'), |
174 | + _('The default revaluation account must have a default destination SUP')) |
175 | # Entry period |
176 | # Posting date |
177 | res['posting_date'] = False |
178 | @@ -221,55 +274,33 @@ |
179 | cr, uid, res['period_id'], context=context) |
180 | res['posting_date'] = period.date_stop |
181 | return res |
182 | - |
183 | - |
184 | - def on_change_revaluation_method( |
185 | - self, cr, uid, ids, method, fiscalyear_id, period_id): |
186 | - """'on_change' method for the 'revaluation_method', 'fiscalyear_id' and |
187 | - 'period_id' fields. |
188 | - """ |
189 | - if not method or not fiscalyear_id or not period_id: |
190 | - return {} |
191 | - value = {} |
192 | + |
193 | + def on_change_reval(self, cr, uid, ids, method, fiscalyear_id, period_id, |
194 | + from_field): |
195 | + res = {} |
196 | + if not method or not fiscalyear_id: |
197 | + return res |
198 | + |
199 | + value = { |
200 | + 'result_period_yearly_editable': True, |
201 | + 'msg': False, |
202 | + } |
203 | warning = {} |
204 | + domain = { |
205 | + 'result_period_id': [ |
206 | + ('fiscalyear_id', '=', fiscalyear_id), |
207 | + ('state', '!=', 'created'), |
208 | + ], |
209 | + } |
210 | + |
211 | fiscalyear_obj = self.pool.get('account.fiscalyear') |
212 | period_obj = self.pool.get('account.period') |
213 | move_obj = self.pool.get('account.move') |
214 | + |
215 | fiscalyear = fiscalyear_obj.browse(cr, uid, fiscalyear_id) |
216 | - |
217 | - # Set values according to the user input |
218 | value['result_period_id'] = period_id |
219 | - |
220 | - period = period_obj.browse(cr, uid, period_id, context=None) |
221 | - value['posting_date'] = period.date_stop |
222 | - value['period_id'] = period_id |
223 | - if method != 'liquidity_month': |
224 | - value['posting_date'] = fiscalyear.date_stop |
225 | - check_period13_res = self._check_period_opened(cr, uid, |
226 | - fiscalyear.id, 13) # UFTP-385 period 13 for year end |
227 | - if check_period13_res[1]: |
228 | - value['result_period_id'] = check_period13_res[1] |
229 | - else: |
230 | - value['result_period_id'] = False |
231 | - if not check_period13_res[0] and check_period13_res[2]: |
232 | - warning = { |
233 | - 'title': _('Warning!'), |
234 | - 'message': check_period13_res[2] |
235 | - } |
236 | - res = {'value': value, 'warning': warning} |
237 | - return res |
238 | - |
239 | - def on_change_fiscalyear_id(self, cr, uid, ids, method, fiscalyear_id): |
240 | - """'on_change' method for the 'fiscalyear_id' field.""" |
241 | - |
242 | - if not method or not fiscalyear_id: |
243 | - return {} |
244 | - value = {} |
245 | - warning = {} |
246 | - fiscalyear_obj = self.pool.get('account.fiscalyear') |
247 | - period_obj = self.pool.get('account.period') |
248 | - fiscalyear = fiscalyear_obj.browse(cr, uid, fiscalyear_id) |
249 | - if method in ['liquidity_month']: |
250 | + |
251 | + if from_field == 'fiscalyear_id': |
252 | if fiscalyear_id: |
253 | # If the current fiscal year is the actual one, we get the |
254 | # previous month as the right period (except for january) |
255 | @@ -291,19 +322,62 @@ |
256 | value['result_period_id'] = period_id |
257 | period = period_obj.browse(cr, uid, period_id) |
258 | value['posting_date'] = period.date_stop |
259 | - elif method in ('other_bs', 'liquidity_year'): |
260 | - value['posting_date'] = fiscalyear.date_stop |
261 | - period_ids = period_obj.search( |
262 | - cr, uid, |
263 | - [('state', '!=', 'created'), |
264 | - ('fiscalyear_id', '=', fiscalyear.id), |
265 | - ('number', '=', 13)]) |
266 | - if period_ids: |
267 | - value['result_period_id'] = period_ids[0] |
268 | - res = {'value': value, 'warning': warning} |
269 | + |
270 | + if from_field != 'period_id': |
271 | + # from fiscalyear_id or not from period_id |
272 | + if method != 'liquidity_month': |
273 | + # yearly reval: |
274 | + # recompute entry target period from method/fy change |
275 | + value['posting_date'] = fiscalyear.date_stop |
276 | + |
277 | + # get last 1st yearly reval period (liquidity or bs) |
278 | + period_number = 13 |
279 | + last_reval_period = self._get_last_yearly_reval_period_id( |
280 | + cr, uid, fiscalyear_id) |
281 | + if last_reval_period: |
282 | + # US-816: liquidity or BS can be processed in any order |
283 | + # but the 2nd should always use the same period |
284 | + period_number = last_reval_period.number |
285 | + value['result_period_id'] = last_reval_period.id |
286 | + value['result_period_yearly_editable'] = False |
287 | + value['msg'] = _('One of the year-end revaluations has' \ |
288 | + ' already been processed. The next one will be' \ |
289 | + ' processed on the same period: %s.') % ( |
290 | + last_reval_period.name, ) |
291 | + |
292 | + # check period opened |
293 | + check_period_res = self._check_period_opened(cr, uid, |
294 | + fiscalyear.id, period_number) |
295 | + if check_period_res[1]: |
296 | + value['result_period_id'] = check_period_res[1] |
297 | + else: |
298 | + value['result_period_id'] = False |
299 | + if not check_period_res[0] and check_period_res[2]: |
300 | + warning = { |
301 | + 'title': _('Warning!'), |
302 | + 'message': check_period_res[2] |
303 | + } |
304 | + # US-816: end year reval restrict to periods 13, 14, 15 |
305 | + domain['result_period_id'] += [ |
306 | + ('number', '>', 12), |
307 | + ('number', '<', 16), |
308 | + ] |
309 | + value['result_period_id'] = check_period_res[0] and \ |
310 | + check_period_res[1] or False |
311 | + else: |
312 | + if period_id: |
313 | + period = period_obj.browse(cr, uid, period_id) |
314 | + value['posting_date'] = period.date_stop |
315 | + value['period_id'] = period_id |
316 | + value['result_period_id'] = period_id |
317 | + |
318 | + # result_period_internal_id: real target period wrapper |
319 | + value['result_period_internal_id'] = value['result_period_id'] |
320 | + res = {'value': value, 'warning': warning, 'domain': domain, } |
321 | return res |
322 | |
323 | - def on_change_result_period_id(self, cr, uid, ids, result_period_id, context=None): |
324 | + def on_change_result_period_id(self, cr, uid, ids, result_period_id, |
325 | + context=None): |
326 | """'on_change' method for the 'result_period_id' field.""" |
327 | if context is None: |
328 | context = {} |
329 | @@ -311,9 +385,12 @@ |
330 | warning = {} |
331 | if result_period_id: |
332 | period_obj = self.pool.get('account.period') |
333 | - period = period_obj.browse(cr, uid, result_period_id, context=context) |
334 | + period = period_obj.browse(cr, uid, result_period_id, |
335 | + context=context) |
336 | value['posting_date'] = period.date_stop |
337 | value['result_period_id'] = result_period_id |
338 | + # result_period_internal_id: real target period wrapper |
339 | + value['result_period_internal_id'] = value['result_period_id'] |
340 | return {'value': value, 'warning': warning} |
341 | |
342 | def _compute_unrealized_currency_gl(self, cr, uid, |
343 | @@ -339,11 +416,13 @@ |
344 | ctx_rate = context.copy() |
345 | ctx_rate['date'] = revaluation_date |
346 | user_obj = self.pool.get('res.users') |
347 | - cp_currency_id = user_obj.browse(cr, uid, uid, context=context).company_id.currency_id.id |
348 | + cp_currency_id = user_obj.browse(cr, uid, uid, |
349 | + context=context).company_id.currency_id.id |
350 | |
351 | currency = currency_obj.browse(cr, uid, currency_id, context=ctx_rate) |
352 | |
353 | - foreign_balance = adjusted_balance = balances.get('foreign_balance', 0.0) |
354 | + foreign_balance = adjusted_balance = balances.get( |
355 | + 'foreign_balance', 0.0) |
356 | balance = balances.get('balance', 0.0) |
357 | unrealized_gain_loss = 0.0 |
358 | if foreign_balance: |
359 | @@ -410,7 +489,8 @@ |
360 | cr, uid, currency_id, context=context) |
361 | |
362 | base_move = {'name': label, |
363 | - 'ref': "%s-%s-%s" % (currency.name, account.code, rate), |
364 | + 'ref': "%s-%s-%s" % ( |
365 | + currency.name, account.code, rate), |
366 | 'journal_id': form.journal_id.id, |
367 | 'period_id': form.period_id.id, |
368 | 'document_date': form.posting_date, |
369 | @@ -431,7 +511,8 @@ |
370 | base_line.update(line_data) |
371 | base_line['gl_foreign_balance'] = sums.get('foreign_balance', 0.0) |
372 | base_line['gl_balance'] = sums.get('balance', 0.0) |
373 | - base_line['gl_revaluated_balance'] = sums.get('revaluated_balance', 0.0) |
374 | + base_line['gl_revaluated_balance'] = sums.get('revaluated_balance', |
375 | + 0.0) |
376 | base_line['gl_currency_rate'] = sums.get('currency_rate', 0.0) |
377 | return move_line_obj.create(cr, uid, base_line, context=context) |
378 | |
379 | @@ -450,7 +531,8 @@ |
380 | revaluation_account = user[0].company_id.revaluation_default_account |
381 | revaluation_account_id = revaluation_account.id |
382 | else: |
383 | - raise osv.except_osv(_('Settings Error!'), _('Revaluation account is not set in company settings')) |
384 | + raise osv.except_osv(_('Settings Error!'), |
385 | + _('Revaluation account is not set in company settings')) |
386 | |
387 | # Prepare the analytic distribution for the account revaluation entry |
388 | # if the account has a 'expense' or 'income' type |
389 | @@ -561,15 +643,22 @@ |
390 | ids = [ids] |
391 | form = self.browse(cr, uid, ids[0], context=context) |
392 | |
393 | - period_13_id = False |
394 | + year_end_entry_period_id = False |
395 | if form.revaluation_method in ('liquidity_year', 'other_bs'): |
396 | - # check if period 13 is valid for end year reval |
397 | + # since US-816, end year reval entries period is extended from |
398 | + # period 13, to 13, 14, 15 |
399 | + |
400 | + # check if entry period is valid for end year reval |
401 | # (must exist and must be opened) |
402 | - check_period13_res = self._check_period_opened(cr, uid, |
403 | - form.fiscalyear_id.id, 13) |
404 | - if not check_period13_res[0] and check_period13_res[2]: |
405 | - raise osv.except_osv(_('Warning!'), check_period13_res[2]) |
406 | - period_13_id = check_period13_res[1] |
407 | + if not form.result_period_internal_id: |
408 | + return |
409 | + check_period_end_year_res = self._check_period_opened(cr, uid, |
410 | + form.fiscalyear_id.id, form.result_period_internal_id.number) |
411 | + if not check_period_end_year_res[0] \ |
412 | + and check_period_end_year_res[2]: |
413 | + raise osv.except_osv(_('Warning!'), |
414 | + check_period_end_year_res[2]) |
415 | + year_end_entry_period_id = check_period_end_year_res[1] |
416 | |
417 | # period 13 is opened but check if N+1 FY 1st period is opened |
418 | # as it is used for reversal lines |
419 | @@ -603,9 +692,9 @@ |
420 | # Get posting date (as the field is readonly, its value is not sent |
421 | # to the server by the web client |
422 | # and get revaluation date |
423 | - if period_13_id: |
424 | - # period_13_id set: end of year revaluation |
425 | - form.period_id.id = period_13_id |
426 | + if year_end_entry_period_id: |
427 | + # year_end_entry_period_id set: end of year revaluation |
428 | + form.period_id.id = year_end_entry_period_id |
429 | form.posting_date = form.fiscalyear_id.date_stop |
430 | revaluation_date = form.fiscalyear_id.date_stop # compute reval for FY |
431 | else: |
432 | @@ -639,8 +728,8 @@ |
433 | if p.special == True and p.number != 0 ] |
434 | if not special_period_ids: |
435 | raise osv.except_osv(_('Error!'), |
436 | - _('No special period found for the fiscalyear %s') % |
437 | - form.fiscalyear_id.code) |
438 | + _('No special period found for the fiscalyear %s') % |
439 | + form.fiscalyear_id.code) |
440 | |
441 | period_ids = [] |
442 | if form.revaluation_method == 'liquidity_month': |
443 | @@ -671,11 +760,17 @@ |
444 | # check if revaluation has already been run for this period |
445 | # UFTP-385 not checked for year end as is it over months revaluation |
446 | # in this case to check revaluation year already done we check only |
447 | - # period 13 |
448 | + # period 13 AND 14, 15 since US-816 |
449 | if form.revaluation_method == 'liquidity_month': |
450 | revalcheck_period_ids = period_ids |
451 | else: |
452 | - revalcheck_period_ids = [period_13_id] |
453 | + domain = [ |
454 | + ('fiscalyear_id', '=', form.fiscalyear_id.id), |
455 | + ('number', '>', 12), |
456 | + ('number', '<', 16), |
457 | + ] |
458 | + revalcheck_period_ids = period_obj.search(cr, uid, domain, |
459 | + context=context) |
460 | for period_id in revalcheck_period_ids: |
461 | if self._is_revaluated(cr, uid, period_id, form.revaluation_method, |
462 | context=None): |
463 | @@ -900,7 +995,7 @@ |
464 | # search for opened period |
465 | period_ids = period_obj.search(cr, uid, domain, context=context) |
466 | if period_ids: |
467 | - # period 13 opened found |
468 | + # period opened found |
469 | res = (True, period_ids[0], False) |
470 | else: |
471 | # not found, check if exist with any state to get its id |
472 | @@ -910,9 +1005,11 @@ |
473 | ] |
474 | period_ids = period_obj.search(cr, uid, domain, context=context) |
475 | if not period_ids: |
476 | - res = (False, False, _('Period 13 is not found')) |
477 | + res = (False, False, _('Period %d is not found') % ( |
478 | + period_number, )) |
479 | else: |
480 | - res = (False, period_ids[0], _('Period 13 is not opened')) |
481 | + res = (False, period_ids[0], _('Period %d not opened') % ( |
482 | + period_number, )) |
483 | return res |
484 | |
485 | WizardCurrencyrevaluation() |
486 | |
487 | === modified file 'bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation_view.xml' |
488 | --- bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation_view.xml 2014-11-03 13:00:13 +0000 |
489 | +++ bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation_view.xml 2016-07-21 08:16:38 +0000 |
490 | @@ -9,23 +9,26 @@ |
491 | <field name="arch" type="xml"> |
492 | <form string="Revaluation" col="4"> |
493 | <field name="revaluation_method" |
494 | - on_change="on_change_revaluation_method(revaluation_method, fiscalyear_id, period_id)"/> |
495 | + on_change="on_change_reval(revaluation_method, fiscalyear_id, period_id, 'revaluation_method')"/> |
496 | <newline/> |
497 | <newline/> |
498 | <field name="fiscalyear_id" |
499 | - on_change="on_change_fiscalyear_id(revaluation_method, fiscalyear_id)"/> |
500 | + on_change="on_change_reval(revaluation_method, fiscalyear_id, False, 'fiscalyear_id')"/> |
501 | <newline/> |
502 | <field name="period_id" |
503 | - attrs="{'invisible': ['|', ('revaluation_method', '=', 'other_bs'), ('revaluation_method', '=', 'liquidity_year')], |
504 | + attrs="{'invisible': [('revaluation_method', '!=', 'liquidity_month')], |
505 | 'required': [('revaluation_method', '=', 'liquidity_month')]}" |
506 | - on_change="on_change_revaluation_method(revaluation_method, fiscalyear_id, period_id)"/> |
507 | + on_change="on_change_reval(revaluation_method, fiscalyear_id, period_id, 'period_id')" /> |
508 | <newline/> |
509 | <field name="currency_table_id" |
510 | attrs="{'invisible': [('revaluation_method', '=', 'liquidity_month')], |
511 | 'required': [('revaluation_method', 'in', ['liquidity_year', 'other_bs'])]}"/> |
512 | <newline/> |
513 | <separator string="" colspan="6"/> |
514 | + <field name="result_period_yearly_editable" /> |
515 | + <field name="result_period_internal_id" /> |
516 | <field name="result_period_id" |
517 | + attrs="{'readonly': ['|', ('revaluation_method', '=', 'liquidity_month'), ('result_period_yearly_editable', '=', False)]}" |
518 | on_change="on_change_result_period_id(result_period_id)"/> |
519 | <newline/> |
520 | <field name="posting_date"/> |
521 | @@ -36,6 +39,8 @@ |
522 | <newline/> |
523 | <button special="cancel" string="Cancel" icon="gtk-cancel" /> |
524 | <button name="revaluate_currency" string="Validate" type="object" icon="gtk-execute"/> |
525 | + <newline/> |
526 | + <field name="msg" nolabel="1" colspan="4" readonly="1" attrs="{'invisible': [('msg', '=', False)]}"/> |
527 | </form> |
528 | </field> |
529 | </record> |