Merge lp:~unifield-team/unifield-server/us-937 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3901
Proposed branch: lp:~unifield-team/unifield-server/us-937
Merge into: lp:unifield-server
Diff against target: 110 lines (+35/-12)
2 files modified
bin/addons/account_override/period.py (+12/-6)
bin/addons/msf_doc_import/account.py (+23/-6)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-937
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+302147@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/account_override/period.py'
2--- bin/addons/account_override/period.py 2014-03-19 10:26:27 +0000
3+++ bin/addons/account_override/period.py 2016-08-05 13:42:21 +0000
4@@ -26,19 +26,25 @@
5 def get_period_from_date(self, cr, uid, date=False, context=None):
6 """
7 Get period in which this date could go into, otherwise return last open period.
8- Do not select special periods (Period 13, 14 and 15).
9+ By default: Do not select special periods (Period 13, 14 and 15).
10+ except if extend_december to True in context
11 """
12- # Some verifications
13- if not context:
14+ if context is None:
15 context = {}
16 if not date:
17 return False
18+
19+ limit = 1
20+ if context.get('extend_december', False) and date[5:7] == '12':
21+ # extend search to periods 12, 13, 14, 15 for december date
22+ limit = 4
23+
24 # Search period in which this date come from
25- period_ids = self.pool.get('account.period').search(cr, uid, [('date_start', '<=', date), ('date_stop', '>=', date), ('number', '!=', 16)], limit=1,
26+ period_ids = self.pool.get('account.period').search(cr, uid, [('date_start', '<=', date), ('date_stop', '>=', date), ('number', '!=', 16)], limit=limit,
27 order='date_start asc, name asc', context=context) or []
28 # Get last period if no period found
29 if not period_ids:
30- period_ids = self.pool.get('account.period').search(cr, uid, [('state', '=', 'open'), ('number', '!=', 16)], limit=1,
31+ period_ids = self.pool.get('account.period').search(cr, uid, [('state', '=', 'open'), ('number', '!=', 16)], limit=limit,
32 order='date_stop desc, name desc', context=context) or []
33 if isinstance(period_ids, (int, long)):
34 period_ids = [period_ids]
35@@ -50,7 +56,7 @@
36 - if given date is included in period, return the given date
37 - else return the date_stop of given period
38 """
39- if not context:
40+ if context is None:
41 context = {}
42 if not date or not period_id:
43 return False
44
45=== modified file 'bin/addons/msf_doc_import/account.py'
46--- bin/addons/msf_doc_import/account.py 2016-05-24 08:44:23 +0000
47+++ bin/addons/msf_doc_import/account.py 2016-08-05 13:42:21 +0000
48@@ -156,7 +156,7 @@
49 - check integrity of data in files
50 """
51 # Some checks
52- if not context:
53+ if context is None:
54 context = {}
55 # Prepare some values
56 from_yml = False
57@@ -184,16 +184,17 @@
58 self.pool.get('msf.doc.import.accounting.lines').unlink(cr, uid, old_lines_ids)
59
60 # Check wizard data
61+ period_obj = self.pool.get('account.period')
62+ period_ctx = context.copy()
63+ period_ctx['extend_december'] = True
64 for wiz in self.browse(cr, uid, ids):
65 # Update wizard
66 self.write(cr, uid, [wiz.id], {'message': _('Checking file…'), 'progression': 2.00})
67 # UF-2045: Check that the given date is in an open period
68- wiz_period_ids = self.pool.get('account.period').get_period_from_date(cr, uid, wiz.date, context)
69+ wiz_period_ids = period_obj.get_period_from_date(
70+ cr, uid, wiz.date, period_ctx)
71 if not wiz_period_ids:
72 raise osv.except_osv(_('Warning'), _('No period found!'))
73- period = self.pool.get('account.period').browse(cr, uid, wiz_period_ids[0], context)
74- if not period or period.state in ['created', 'done']:
75- raise osv.except_osv(_('Warning'), _('Period is not open!'))
76 date = wiz.date or False
77
78 # Check that a file was given
79@@ -215,7 +216,7 @@
80 self.write(cr, uid, [wiz.id], {'message': _('Reading headers…'), 'progression': 5.00})
81 # Use the first row to find which column to use
82 cols = {}
83- col_names = ['Journal Code', 'Description', 'Reference', 'Document Date', 'Posting Date', 'G/L Account', 'Partner', 'Employee', 'Journal', 'Destination', 'Cost Centre', 'Funding Pool', 'Booking Debit', 'Booking Credit', 'Booking Currency']
84+ col_names = ['Journal Code', 'Description', 'Reference', 'Document Date', 'Posting Date', 'Period', 'G/L Account', 'Partner', 'Employee', 'Journal', 'Destination', 'Cost Centre', 'Funding Pool', 'Booking Debit', 'Booking Credit', 'Booking Currency']
85 for num, r in enumerate(rows):
86 header = [x and x.data for x in r.iter_cells()]
87 for el in col_names:
88@@ -427,6 +428,22 @@
89 errors.append(_('Line %s. Funding Pool %s not found!') % (current_line_num, line[cols['Funding Pool']]))
90 continue
91 r_fp = fp_ids[0]
92+ # US-937: use period of import file
93+ if line[cols['Period']] == 'Period 16':
94+ raise osv.except_osv(_('Warning'), _("You can't import entries in Period 16."))
95+ period_ids = period_obj.search(
96+ cr, uid, [
97+ ('id', 'in', wiz_period_ids),
98+ ('name', '=', line[cols['Period']]),
99+ ], limit=1, context=context)
100+ if not period_ids:
101+ raise osv.except_osv(_('Warning'),
102+ _('The date chosen in the wizard is not in the same period as the imported entries.'))
103+ period = period_obj.browse(
104+ cr, uid, period_ids[0], context=context)
105+ if period.state in ('created', 'done', ):
106+ raise osv.except_osv(_('Warning'), _('%s is not open!') % (period.name, ))
107+
108 # NOTE: There is no need to check G/L account, Cost Center and Destination regarding document/posting date because this check is already done at Journal Entries validation.
109
110 # Registering data regarding these "keys":

Subscribers

People subscribed via source and target branches

to all changes: