Merge lp:~unifield-team/unifield-wm/us-900 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 2756
Proposed branch: lp:~unifield-team/unifield-wm/us-900
Merge into: lp:unifield-wm
Diff against target: 67 lines (+18/-6)
1 file modified
account_corrections/wizard/analytic_distribution_wizard.py (+18/-6)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/us-900
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+285315@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 'account_corrections/wizard/analytic_distribution_wizard.py'
2--- account_corrections/wizard/analytic_distribution_wizard.py 2015-12-02 16:33:50 +0000
3+++ account_corrections/wizard/analytic_distribution_wizard.py 2016-02-08 10:51:17 +0000
4@@ -112,6 +112,19 @@
5 """
6 For each given wizard compare old (distrib_id) and new analytic distribution. Then adapt analytic lines.
7 """
8+ # US-900: get the next OD journal sequence only 1st time it is needed
9+ # for the correction transaction
10+ def get_entry_seq(entry_seq_data):
11+ res = entry_seq_data.get('sequence', False)
12+ if not res:
13+ seqnum = self.pool.get('ir.sequence').get_id(
14+ cr, uid, journal.sequence_id.id,
15+ context={'fiscalyear_id': period.fiscalyear_id.id})
16+ res = "%s-%s-%s" % (move_prefix, code, seqnum)
17+ entry_seq_data['sequence'] = res
18+ return res
19+
20+
21 if context is None:
22 context = {}
23 # Prepare some values
24@@ -143,8 +156,7 @@
25 raise osv.except_osv(_('Warning'), _('No period found for creating sequence on the given date: %s') % (wizard.date or ''))
26 period = self.pool.get('account.period').browse(cr, uid, period_ids)[0]
27 move_prefix = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.instance_id.move_prefix
28- seqnum = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context={'fiscalyear_id': period.fiscalyear_id.id})
29- entry_seq = "%s-%s-%s" % (move_prefix, code, seqnum)
30+ entry_seq_data = {}
31
32 # US-676: check wizard lines total matches JI amount
33 # the wizard already check distri is 100% allocated
34@@ -237,7 +249,7 @@
35 # Set right journal and right entry sequence
36 ana_obj.write(cr, uid, reversed_ids, {'journal_id': correction_journal_id})
37 for reversed_id in reversed_ids:
38- cr.execute('update account_analytic_line set entry_sequence = %s where id = %s', (entry_seq, reversed_id) )
39+ cr.execute('update account_analytic_line set entry_sequence = %s where id = %s', (get_entry_seq(entry_seq_data), reversed_id) )
40 # delete the distribution line
41 wiz_line.unlink()
42 any_reverse = True
43@@ -304,7 +316,7 @@
44 self.pool.get('account.analytic.line').write(cr, uid, [reversed_id], {'reversal_origin': to_reverse_ids[0], 'last_corrected_id': False, 'journal_id': correction_journal_id, 'ref': orig_line.entry_sequence})
45 # Mark old lines as non reallocatable (ana_ids): why reverse() don't set this flag ?
46 self.pool.get('account.analytic.line').write(cr, uid, [to_reverse_ids[0]], {'is_reallocated': True})
47- cr.execute('update account_analytic_line set entry_sequence = %s where id = %s', (entry_seq, reversed_id) )
48+ cr.execute('update account_analytic_line set entry_sequence = %s where id = %s', (get_entry_seq(entry_seq_data), reversed_id) )
49
50 # update the distrib line
51 name = False
52@@ -330,13 +342,13 @@
53 # Add link to first analytic lines
54 for ret_id in ret:
55 self.pool.get('account.analytic.line').write(cr, uid, [ret[ret_id]], {'last_corrected_id': to_reverse_ids[0], 'journal_id': correction_journal_id, 'ref': orig_line.entry_sequence })
56- cr.execute('update account_analytic_line set entry_sequence = %s where id = %s', (entry_seq, ret[ret_id]) )
57+ cr.execute('update account_analytic_line set entry_sequence = %s where id = %s', (get_entry_seq(entry_seq_data), ret[ret_id]) )
58 if ret and greater_amount['gap_amount'] and greater_amount['wl'] and greater_amount['wl'].id == line.id:
59 greater_amount['aji_id'] = ret[ret.keys()[0]]
60 greater_amount['date'] = wizard.date
61 # UFTP-194: Set missing entry sequence for created analytic lines
62 if have_been_created:
63- cr.execute('update account_analytic_line set entry_sequence = %s, last_corrected_id = %s where id in %s', (entry_seq, to_reverse_ids[0], tuple(have_been_created)))
64+ cr.execute('update account_analytic_line set entry_sequence = %s, last_corrected_id = %s where id in %s', (get_entry_seq(entry_seq_data), to_reverse_ids[0], tuple(have_been_created)))
65
66 #####
67 ## FP: TO OVERRIDE

Subscribers

People subscribed via source and target branches