Merge lp:~jfb-tempo-consulting/unifield-server/us-1191 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3703
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/us-1191
Merge into: lp:unifield-server
Diff against target: 83 lines (+17/-5)
3 files modified
bin/addons/analytic_distribution/analytic_line.py (+9/-1)
bin/addons/analytic_distribution/wizard/mass_reallocation_wizard.py (+2/-1)
bin/addons/analytic_override/analytic_line.py (+6/-3)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/us-1191
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+291644@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/analytic_distribution/analytic_line.py'
2--- bin/addons/analytic_distribution/analytic_line.py 2016-03-15 16:35:21 +0000
3+++ bin/addons/analytic_distribution/analytic_line.py 2016-04-12 15:35:58 +0000
4@@ -338,7 +338,7 @@
5 self.pool.get('account.move.line').corrected_upstream_marker(cr, uid, [aline.move_id.id], context=context)
6 return True
7
8- def check_analytic_account(self, cr, uid, ids, account_id, context=None):
9+ def check_analytic_account(self, cr, uid, ids, account_id, wiz_date, context=None):
10 """
11 Analytic distribution validity verification with given account for given ids.
12 Return all valid ids.
13@@ -372,6 +372,14 @@
14 # since US-711 date_stop is to be excluded itself as a frontier
15 # => >= date_stop vs > date_stop
16 # => http://jira.unifield.org/browse/US-711?focusedCommentId=45744&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-45744
17+ if account_type in ['OC', 'DEST']:
18+ if aline.journal_id.type == 'hq' or aline.period_id and aline.period_id.state in ['done', 'mission-closed']:
19+ aline_cmp_date = wiz_date
20+ # these lines will be reverted, check if the reverted line is active
21+ oc_dest_date_start = max(aline.cost_center_id.date_start, aline.destination_id.date_start)
22+ oc_dest_date_stop = min(aline.cost_center_id.date or '9999-01-01', aline.destination_id.date or '9999-01-01')
23+ if (oc_dest_date_start and wiz_date < oc_dest_date_start) or (oc_dest_date_stop and wiz_date >= oc_dest_date_stop):
24+ expired_date_ids.append(aline.id)
25 if (date_start and aline_cmp_date < date_start) or (date_stop and aline_cmp_date >= date_stop):
26 expired_date_ids.append(aline.id)
27 # Process regarding account_type
28
29=== modified file 'bin/addons/analytic_distribution/wizard/mass_reallocation_wizard.py'
30--- bin/addons/analytic_distribution/wizard/mass_reallocation_wizard.py 2016-02-05 13:28:03 +0000
31+++ bin/addons/analytic_distribution/wizard/mass_reallocation_wizard.py 2016-04-12 15:35:58 +0000
32@@ -327,6 +327,7 @@
33 for wiz in self.browse(cr, uid, ids, context=context):
34 to_process = [x.id for x in wiz.line_ids] or []
35 account_id = wiz.account_id.id
36+
37 date = wiz.date or strftime('%Y-%m-%d')
38 # Don't process lines:
39 # - that have same account (or cost_center_id)
40@@ -366,7 +367,7 @@
41 # Delete non_supported element from to_process and write them to tmp_process_ids
42 tmp_to_process = [x for x in to_process if x not in non_supported_ids]
43 if tmp_to_process:
44- valid_ids = self.pool.get('account.analytic.line').check_analytic_account(cr, uid, tmp_to_process, account_id, context=context)
45+ valid_ids = self.pool.get('account.analytic.line').check_analytic_account(cr, uid, tmp_to_process, account_id, date, context=context)
46 process_ids.extend(valid_ids)
47 error_ids.extend([x for x in tmp_to_process if x not in valid_ids])
48 vals = {'account_id': account_id, 'date': date,}
49
50=== modified file 'bin/addons/analytic_override/analytic_line.py'
51--- bin/addons/analytic_override/analytic_line.py 2016-02-24 10:22:18 +0000
52+++ bin/addons/analytic_override/analytic_line.py 2016-04-12 15:35:58 +0000
53@@ -135,24 +135,27 @@
54 if not 'account_id' in vals:
55 raise osv.except_osv(_('Error'), _('No account_id found in given values!'))
56
57+ account_obj = self.pool.get('account.analytic.account')
58+
59 #US-419: Use the document date and not posting date when checking the validity of analytic account
60 # tech: replaced all date by document_date
61 if 'document_date' in vals and vals['document_date'] is not False:
62- account_obj = self.pool.get('account.analytic.account')
63 document_date = vals['document_date']
64 account = account_obj.browse(cr, uid, vals['account_id'], context=context)
65 # FIXME: refactoring of next code
66 if document_date < account.date_start or (account.date != False and document_date >= account.date):
67 if 'from' not in context or context.get('from') != 'mass_reallocation':
68 raise osv.except_osv(_('Error'), _("The analytic account selected '%s' is not active.") % (account.name or '',))
69+ if 'date' in vals and vals['date'] is not False:
70+ date = vals['date']
71 if vals.get('cost_center_id', False):
72 cc = account_obj.browse(cr, uid, vals['cost_center_id'], context=context)
73- if document_date < cc.date_start or (cc.date != False and document_date >= cc.date):
74+ if date < cc.date_start or (cc.date != False and date >= cc.date):
75 if 'from' not in context or context.get('from') != 'mass_reallocation':
76 raise osv.except_osv(_('Error'), _("The analytic account selected '%s' is not active.") % (cc.name or '',))
77 if vals.get('destination_id', False):
78 dest = account_obj.browse(cr, uid, vals['destination_id'], context=context)
79- if document_date < dest.date_start or (dest.date != False and document_date >= dest.date):
80+ if date < dest.date_start or (dest.date != False and date >= dest.date):
81 if 'from' not in context or context.get('from') != 'mass_reallocation':
82 raise osv.except_osv(_('Error'), _("The analytic account selected '%s' is not active.") % (dest.name or '',))
83 return True

Subscribers

People subscribed via source and target branches