Merge lp:~jfb-tempo-consulting/unifield-wm/us-933 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 2781
Proposed branch: lp:~jfb-tempo-consulting/unifield-wm/us-933
Merge into: lp:unifield-wm
Diff against target: 93 lines (+19/-6)
2 files modified
account_corrections/wizard/analytic_distribution_wizard.py (+18/-5)
analytic_distribution/analytic_line.py (+1/-1)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-wm/us-933
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+287285@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 2016-02-11 09:58:49 +0000
3+++ account_corrections/wizard/analytic_distribution_wizard.py 2016-02-26 10:12:41 +0000
4@@ -108,6 +108,16 @@
5 del to_override[oline.id]
6 return True, _("All is OK."), to_reverse, to_override
7
8+ def _check_period_closed_on_fp_distrib_line(self, cr, uid, distrib_line_id, context=None):
9+ ana_obj = self.pool.get('account.analytic.line')
10+ period_obj = self.pool.get('account.period')
11+ aa_ids = ana_obj.search(cr, uid, [('distrib_line_id', '=', 'funding.pool.distribution.line,%d'%distrib_line_id), ('is_reversal', '=', False), ('is_reallocated', '=', False)], context=context)
12+ if aa_ids:
13+ for ana in ana_obj.browse(cr, uid, aa_ids, context=context):
14+ if ana.period_id and ana.period_id.state in ('done', 'mission-closed'):
15+ return True
16+ return False
17+
18 def do_analytic_distribution_changes(self, cr, uid, wizard_id, distrib_id, context=None):
19 """
20 For each given wizard compare old (distrib_id) and new analytic distribution. Then adapt analytic lines.
21@@ -143,7 +153,7 @@
22 to_reverse = []
23 old_line_ok = []
24 any_reverse = False
25- period_closed = ml.period_id and ml.period_id.state and ml.period_id.state in ['done', 'mission-closed'] or False
26+ #period_closed = ml.period_id and ml.period_id.state and ml.period_id.state in ['done', 'mission-closed'] or False
27 ana_obj = self.pool.get('account.analytic.line')
28 # Prepare journal and period information for entry sequences
29 cr.execute("select id, code from account_journal where type = 'correction' and is_current_instance = true")
30@@ -218,7 +228,7 @@
31 if (old_line.cost_center_id.id != wiz_line.cost_center_id.id or
32 old_line.destination_id.id != wiz_line.destination_id.id or
33 old_line.percentage != wiz_line.percentage):
34- if period_closed:
35+ if self._check_period_closed_on_fp_distrib_line(cr, uid, old_line.id):
36 to_reverse.append(wiz_line)
37 else:
38 to_override.append(wiz_line)
39@@ -240,7 +250,7 @@
40 # distribution line deleted by user
41 if self.pool.get('account.analytic.account').is_blocked_by_a_contract(cr, uid, [wiz_line.analytic_id.id]):
42 raise osv.except_osv(_('Error'), _("Funding pool is on a soft/hard closed contract: %s")%(wiz_line.analytic_id.code))
43- if period_closed:
44+ if self._check_period_closed_on_fp_distrib_line(cr, uid, wiz_line.id):
45 # reverse the line
46 to_reverse_ids = ana_obj.search(cr, uid, [('distrib_line_id', '=', 'funding.pool.distribution.line,%d'%wiz_line.id)])
47 reversed_ids = ana_obj.reverse(cr, uid, to_reverse_ids, posting_date=wizard.date)
48@@ -277,6 +287,8 @@
49 create_date = ml.date
50 # create the ana line (pay attention to take original date as posting date as UF-2199 said it.
51 name = False
52+ #period_closed = self._check_period_closed_on_fp_distrib_line(cr, uid, wiz_line.id)
53+ period_closed = ml.period_id and ml.period_id.state and ml.period_id.state in ['done', 'mission-closed'] or False
54 if period_closed:
55 create_date = wizard.date
56 name = self.pool.get('account.analytic.line').join_without_redundancy(ml.name, 'COR')
57@@ -296,12 +308,13 @@
58 # delete distrib line
59 self.pool.get('funding.pool.distribution.line').unlink(cr, uid, [line.id])
60 # delete associated analytic line
61- to_delete_ids = self.pool.get('account.analytic.line').search(cr, uid, [('distrib_line_id', '=', 'funding.pool.distribution.line,%d'%line.id)])
62+ to_delete_ids = self.pool.get('account.analytic.line').search(cr, uid, [('distrib_line_id', '=', 'funding.pool.distribution.line,%d'%line.id), ('is_reversal', '=', False), ('is_reallocated', '=', False)])
63 self.pool.get('account.analytic.line').unlink(cr, uid, to_delete_ids)
64
65 #####
66 ## FP: TO REVERSE
67 ###
68+ to_reverse_ids = []
69 for line in to_reverse:
70 # reverse the line
71 to_reverse_ids = self.pool.get('account.analytic.line').search(cr, uid, [('distrib_line_id', '=', 'funding.pool.distribution.line,%d'%line.distribution_line_id.id), ('is_reversal', '=', False), ('is_reallocated', '=', False)])
72@@ -347,7 +360,7 @@
73 greater_amount['aji_id'] = ret[ret.keys()[0]]
74 greater_amount['date'] = wizard.date
75 # UFTP-194: Set missing entry sequence for created analytic lines
76- if have_been_created:
77+ if have_been_created and to_reverse_ids:
78 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)))
79
80 #####
81
82=== modified file 'analytic_distribution/analytic_line.py'
83--- analytic_distribution/analytic_line.py 2016-02-04 17:03:55 +0000
84+++ analytic_distribution/analytic_line.py 2016-02-26 10:12:41 +0000
85@@ -263,7 +263,7 @@
86 for aline in self.browse(cr, uid, ids, context=context):
87 if account.category in ['OC', 'DEST']:
88 # Period verification
89- period = aline.move_id and aline.move_id.period_id or False
90+ period = aline.period_id
91 # Prepare some values
92 fieldname = 'cost_center_id'
93 if account.category == 'DEST':

Subscribers

People subscribed via source and target branches