Merge lp:~unifield-team/unifield-wm/utp-928 into lp:unifield-wm

Proposed by jftempo
Status: Needs review
Proposed branch: lp:~unifield-team/unifield-wm/utp-928
Merge into: lp:unifield-wm
Diff against target: 82 lines (+37/-0)
1 file modified
account_hq_entries/wizard/hq_entries_import.py (+37/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/utp-928
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+196099@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

1838. By Vincent GREINER

[utp-928] [FIX] Make it impossible to import HQ entries where Doc Date > Posting Date, it will spare trouble at HQ entry validation.

1837. By Vincent GREINER

[utp-928] [UPD] hq entry import block entry allocated to CC, FP, DEST of type view

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_hq_entries/wizard/hq_entries_import.py'
2--- account_hq_entries/wizard/hq_entries_import.py 2013-04-09 13:44:09 +0000
3+++ account_hq_entries/wizard/hq_entries_import.py 2013-11-21 13:06:48 +0000
4@@ -86,12 +86,20 @@
5 raise osv.except_osv(_('Warning'), _('More than one period found for given date: %s') % (line_date,))
6 period_id = period_ids[0]
7 vals.update({'period_id': period_id, 'date': line_date})
8+ dd = False
9 if document_date:
10 try:
11 dd = self.parse_date(document_date)
12 vals.update({'document_date': dd})
13 except ValueError, e:
14 raise osv.except_osv(_('Error'), _('Wrong format for date: %s: %s') % (document_date, e))
15+ # [utp-928]
16+ # Make it impossible to import HQ entries where Doc Date > Posting Date,
17+ # it will spare trouble at HQ entry validation.
18+ if dd and line_date and dd > line_date:
19+ raise osv.except_osv(_('Error'),
20+ _('Document date "%s" is greater than Posting date "%s"') % (document_date, line_date)
21+ )
22 # Retrieve account
23 if account_description:
24 account_data = account_description.split(' ')
25@@ -105,6 +113,7 @@
26 else:
27 raise osv.except_osv(_('Error'), _('No account code found!'))
28 # Retrieve Destination
29+ aa_check_ids = []
30 destination_id = False
31 account = acc_obj.browse(cr, uid, account_ids[0])
32 if account.user_type.code == 'expense':
33@@ -119,6 +128,8 @@
34 destination_id = dest_id[0]
35 else:
36 raise osv.except_osv(_('Error'), _('Destination "%s" doesn\'t exist!') % (destination,))
37+ if destination_id:
38+ aa_check_ids.append(destination_id)
39 # Retrieve Cost Center and Funding Pool
40 cc_id = False
41 if cost_center:
42@@ -126,6 +137,8 @@
43 if not cc_id:
44 raise osv.except_osv(_('Error'), _('Cost Center "%s" doesn\'t exist!') % (cost_center,))
45 cc_id = cc_id[0]
46+ if cc_id:
47+ aa_check_ids.append(cc_id)
48 # Retrieve Funding Pool
49 if funding_pool:
50 fp_id = anacc_obj.search(cr, uid, ['|', ('code', '=', funding_pool), ('name', '=', funding_pool)])
51@@ -137,7 +150,31 @@
52 fp_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'analytic_distribution', 'analytic_account_msf_private_funds')[1]
53 except ValueError:
54 fp_id = 0
55+ if fp_id:
56+ aa_check_ids.append(fp_id)
57 vals.update({'destination_id_first_value': destination_id, 'destination_id': destination_id, 'cost_center_id': cc_id, 'analytic_id': fp_id, 'cost_center_id_first_value': cc_id, 'analytic_id_first_value': fp_id,})
58+
59+ # [utp-928] do not import line with a
60+ # 'Destination' or 'Cost Center' or 'Funding Pool',
61+ # of type 'view'
62+ aa_check_errors = []
63+ aa_check_category_map = {
64+ 'OC': 'Cost Center',
65+ 'FUNDING': 'Funding Pool',
66+ 'DEST': 'Destination',
67+ }
68+ if aa_check_ids:
69+ for aa_r in anacc_obj.read(cr, uid, aa_check_ids,
70+ ['code', 'name', 'type', 'category']):
71+ if aa_r['type'] and aa_r['type'] == 'view':
72+ category = ''
73+ if aa_r['category']:
74+ if aa_r['category'] in aa_check_category_map:
75+ category += aa_check_category_map[aa_r['category']] + ' '
76+ aa_check_errors.append('%s"%s - %s" of type "view" is not allowed for import' % (category, aa_r['code'], aa_r['name']))
77+ if aa_check_errors:
78+ raise osv.except_osv(_('Error'), ", ".join(aa_check_errors))
79+
80 # Fetch description
81 if description:
82 vals.update({'name': description})

Subscribers

People subscribed via source and target branches