Merge lp:~julie-w/unifield-server/US-5788 into lp:unifield-server/uf12
- US-5788
- Merge into uf12
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 5307 |
Proposed branch: | lp:~julie-w/unifield-server/US-5788 |
Merge into: | lp:unifield-server/uf12 |
Diff against target: |
214 lines (+74/-16) 4 files modified
bin/addons/msf_homere_interface/wizard/hr_payroll_import.py (+24/-10) bin/addons/msf_homere_interface/wizard/hr_payroll_validation.py (+21/-6) bin/addons/msf_profile/i18n/fr_MF.po (+28/-0) bin/addons/sync_client/orm.py (+1/-0) |
To merge this branch: | bzr merge lp:~julie-w/unifield-server/US-5788 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Dev Team | Pending | ||
Review via email: mp+365218@code.launchpad.net |
Commit message
Description of the change
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/msf_homere_interface/wizard/hr_payroll_import.py' |
2 | --- bin/addons/msf_homere_interface/wizard/hr_payroll_import.py 2018-12-07 13:34:24 +0000 |
3 | +++ bin/addons/msf_homere_interface/wizard/hr_payroll_import.py 2019-03-28 11:11:55 +0000 |
4 | @@ -503,6 +503,7 @@ |
5 | xyargv = self._get_homere_password(cr, uid, pass_type='payroll') |
6 | |
7 | filename = "" |
8 | + error_msg = "" |
9 | wiz_state = False |
10 | # Browse all given wizard |
11 | for wiz in self.browse(cr, uid, ids): |
12 | @@ -525,10 +526,11 @@ |
13 | if zipobj.namelist(): |
14 | namelist = zipobj.namelist() |
15 | # Search CSV |
16 | - csvfile = None |
17 | + csvfiles = [] |
18 | + currency_list = [] |
19 | for name in namelist: |
20 | if name.split(file_ext_separator) and name.split(file_ext_separator)[-1] == file_ext: |
21 | - csvfile = name |
22 | + csvfiles.append(name) |
23 | if not 'envoi.ini' in namelist: |
24 | raise osv.except_osv(_('Warning'), _('No envoi.ini file found in given ZIP file!')) |
25 | # Read information from 'envoi.ini' file |
26 | @@ -542,8 +544,8 @@ |
27 | raise osv.except_osv(_('Error'), _('Could not read envoi.ini file in given ZIP file.')) |
28 | if not field: |
29 | raise osv.except_osv(_('Warning'), _('Field not found in envoi.ini file.')) |
30 | - # Read CSV file |
31 | - if csvfile: |
32 | + # Read CSV files |
33 | + for csvfile in csvfiles: |
34 | try: |
35 | reader = csv.reader(zipobj.open(csvfile, 'r', xyargv), delimiter=';', quotechar='"', doublequote=False, escapechar='\\') |
36 | reader.next() |
37 | @@ -553,8 +555,10 @@ |
38 | res = True |
39 | res_amount = 0.0 |
40 | amount = 0.0 |
41 | - error_msg = "" |
42 | + num_line = 1 # the header line is not taken into account |
43 | + file_error_msg = "" # store the error/warning messages for the current file |
44 | for line in reader: |
45 | + num_line += 1 |
46 | processed += 1 |
47 | update, amount, nb_created, vals, ccy, msg = self.update_payroll_entries( |
48 | cr, uid, data=line, field=field, |
49 | @@ -563,13 +567,22 @@ |
50 | res_amount += round(amount, 2) |
51 | if not update: |
52 | res = False |
53 | - if created == 0: |
54 | + if num_line == 2: # the first line containing data |
55 | header_vals = vals |
56 | - header_vals['currency_code'] = ccy |
57 | + header_vals['currency_code'] = ccy # note that the curr. is different from one file to another |
58 | + if ccy in currency_list: |
59 | + raise osv.except_osv(_('Error'), _('Several files contain lines with the currency %s. ' |
60 | + 'Please use one file per currency.') % ccy) |
61 | + currency_list.append(ccy) |
62 | created += nb_created |
63 | |
64 | if msg: |
65 | - error_msg += "Line " + str(processed) + ": " + msg + " \n" |
66 | + file_error_msg += _("Line %s: %s\n") % (str(num_line), msg) |
67 | + |
68 | + # complete the list of error messages with the ones from this file if any |
69 | + if file_error_msg: |
70 | + # add a line break between files |
71 | + error_msg += _("%sFile %s:\n%s") % (error_msg and "\n" or "", csvfile, file_error_msg) |
72 | |
73 | # Check balance |
74 | res_amount_rounded = round(res_amount, 2) |
75 | @@ -585,7 +598,8 @@ |
76 | pr_ids = self.pool.get('hr.payroll.msf').search( |
77 | cr, uid, [ |
78 | ('state', '=', 'draft'), |
79 | - ('name', '=', 'Payroll rounding') |
80 | + ('name', '=', 'Payroll rounding'), |
81 | + ('currency_id', '=', header_vals['currency_id']), |
82 | ]) |
83 | if not pr_ids: |
84 | # no SAGA BALANCE rounding line in file |
85 | @@ -611,7 +625,7 @@ |
86 | # - add both |
87 | new_amount = round(pr.amount, 2) + (-1 * res_amount_rounded) |
88 | self.pool.get('hr.payroll.msf').write(cr, uid, pr_ids[0], {'amount': round(new_amount, 2),}) |
89 | - else: |
90 | + if not csvfiles: |
91 | raise osv.except_osv(_('Error'), _('Right CSV is not present in this zip file. Please use "File > File sending > Monthly" in Homère.')) |
92 | fileobj.close() |
93 | |
94 | |
95 | === modified file 'bin/addons/msf_homere_interface/wizard/hr_payroll_validation.py' |
96 | --- bin/addons/msf_homere_interface/wizard/hr_payroll_validation.py 2017-10-24 08:45:55 +0000 |
97 | +++ bin/addons/msf_homere_interface/wizard/hr_payroll_validation.py 2019-03-28 11:11:55 +0000 |
98 | @@ -159,8 +159,12 @@ |
99 | self.check(cr, uid, context=context) # check expense lines |
100 | account_partner_not_compat_log = [] |
101 | self._update_message(cr, uid, ids, _('Checking account/partner compatibility...'), context, use_new_cursor) |
102 | + currency_list = [] |
103 | for line in self.pool.get('hr.payroll.msf').read(cr, uid, line_ids, |
104 | - ['name', 'ref', 'partner_id', 'account_id', 'amount', 'employee_id', ]): |
105 | + ['name', 'ref', 'partner_id', 'account_id', 'amount', 'employee_id', 'currency_id']): |
106 | + # store all the currencies used |
107 | + if line['currency_id'] and line['currency_id'][0] not in currency_list: |
108 | + currency_list.append(line['currency_id'][0]) |
109 | account_id = line.get('account_id', False) and line.get('account_id')[0] or False |
110 | if not account_id: |
111 | raise osv.except_osv(_('Error'), _('No account found!')) |
112 | @@ -206,7 +210,12 @@ |
113 | 'date': period_obj.get_date_in_period(cr, uid, move_date, period_id) or False, |
114 | 'ref': 'Salaries' + ' ' + field, |
115 | } |
116 | - move_id = self.pool.get('account.move').create(cr, uid, move_vals, context=context) |
117 | + # create one JE per currency (note that the JE currency_id depends on the currency of its lines) |
118 | + am_by_curr = {} |
119 | + for curr in currency_list: |
120 | + move_vals_copy = move_vals.copy() # avoids using the same Sequence for the different moves |
121 | + move_id = self.pool.get('account.move').create(cr, uid, move_vals_copy, context=context) |
122 | + am_by_curr[curr] = move_id |
123 | |
124 | # Create lines into this move |
125 | current_line_position = 0 |
126 | @@ -275,8 +284,9 @@ |
127 | |
128 | # UTP-1042: Specific partner's accounts are not needed. |
129 | # create move line values |
130 | + line_curr = line.get('currency_id')[0] # mandatory field |
131 | line_vals = { |
132 | - 'move_id': move_id, |
133 | + 'move_id': am_by_curr.get(line_curr), |
134 | 'name': line.get('name', ''), |
135 | 'date': line.get('date', ''), |
136 | 'document_date': line.get('date', ''), |
137 | @@ -289,14 +299,19 @@ |
138 | 'credit_currency': credit, |
139 | 'journal_id': journal_id, |
140 | 'period_id': line.get('period_id', False) and line.get('period_id')[0] or period_id, |
141 | - 'currency_id': line.get('currency_id', False) and line.get('currency_id')[0] or False, |
142 | + 'currency_id': line_curr, |
143 | 'analytic_distribution_id': distrib_id or False, |
144 | } |
145 | # create move line |
146 | self.pool.get('account.move.line').create(cr, uid, line_vals, check=False) |
147 | - self._update_message(cr, uid, ids, _('Posting of the Journal Entry. This may take a while...'), context, use_new_cursor) |
148 | + if len(am_by_curr) > 1: |
149 | + msg = _('Posting of the Journal Entries. This may take a while...') |
150 | + else: |
151 | + msg = _('Posting of the Journal Entry. This may take a while...') |
152 | + self._update_message(cr, uid, ids, msg, context, use_new_cursor) |
153 | context['do_not_create_analytic_line'] = True |
154 | - self.pool.get('account.move').post(cr, uid, [move_id], context=context) |
155 | + for am_curr in am_by_curr: |
156 | + self.pool.get('account.move').post(cr, uid, am_by_curr[am_curr], context=context) |
157 | # Update payroll lines status |
158 | self._update_percent(cr, uid, ids, 90, context, use_new_cursor) # 90% of the total process time |
159 | self._update_message(cr, uid, ids, _('Updating the status of the Journal Items...'), context, use_new_cursor) |
160 | |
161 | === modified file 'bin/addons/msf_profile/i18n/fr_MF.po' |
162 | --- bin/addons/msf_profile/i18n/fr_MF.po 2019-03-04 11:05:48 +0000 |
163 | +++ bin/addons/msf_profile/i18n/fr_MF.po 2019-03-28 11:11:55 +0000 |
164 | @@ -47622,6 +47622,12 @@ |
165 | msgid "Posting of the Journal Entry. This may take a while..." |
166 | msgstr "Comptabilisation de l'Ecriture Comptable. Cela peut prendre un certain temps..." |
167 | |
168 | +#. module: msf_homere_interface |
169 | +#: code:addons/msf_homere_interface/wizard/hr_payroll_validation.py:307 |
170 | +#, python-format |
171 | +msgid "Posting of the Journal Entries. This may take a while..." |
172 | +msgstr "Comptabilisation des Ecritures Comptables. Cela peut prendre un certain temps..." |
173 | + |
174 | #. module: account |
175 | #: model:process.transition,note:account.process_transition_statemententries0 |
176 | msgid "Manual or automatic creation of payment entries according to the statements" |
177 | @@ -105335,3 +105341,25 @@ |
178 | msgstr "\n" |
179 | " Attention: Les lignes suivantes ont des qté ou des montants sur plus de 15 chiffres. Veuillez vérifier la qté et le prix unitaire pour éviter des pertes d'information:\n" |
180 | " " |
181 | + |
182 | +#. module: msf_homere_interface |
183 | +#: code:addons/msf_homere_interface/wizard/hr_payroll_import.py:580 |
184 | +#, python-format |
185 | +msgid "Line %s: %s\n" |
186 | +"" |
187 | +msgstr "Ligne %s : %s\n" |
188 | +"" |
189 | + |
190 | +#. module: msf_homere_interface |
191 | +#: code:addons/msf_homere_interface/wizard/hr_payroll_import.py:585 |
192 | +#, python-format |
193 | +msgid "%sFile %s:\n" |
194 | +"%s" |
195 | +msgstr "%sFichier %s :\n" |
196 | +"%s" |
197 | + |
198 | +#. module: msf_homere_interface |
199 | +#: code:addons/msf_homere_interface/wizard/hr_payroll_import.py:574 |
200 | +#, python-format |
201 | +msgid "Several files contain lines with the currency %s. Please use one file per currency." |
202 | +msgstr "Plusieurs fichiers contiennent des lignes avec la devise %s. Veuillez utiliser un fichier par devise." |
203 | |
204 | === modified file 'bin/addons/sync_client/orm.py' |
205 | --- bin/addons/sync_client/orm.py 2019-03-04 11:05:48 +0000 |
206 | +++ bin/addons/sync_client/orm.py 2019-03-28 11:11:55 +0000 |
207 | @@ -132,6 +132,7 @@ |
208 | FROM ir_model_data |
209 | WHERE module = 'sd' AND |
210 | model = %s AND |
211 | + COALESCE(touched, '') != '[]' AND |
212 | """+add_sql+""" |
213 | ("""+field+""" < last_modification OR """+field+""" IS NULL)""", |
214 | sql_params) # not_a_user_entry |