Merge lp:~julie-w/unifield-server/US-5756 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5357
Proposed branch: lp:~julie-w/unifield-server/US-5756
Merge into: lp:unifield-server
Diff against target: 249 lines (+72/-45) (has conflicts)
2 files modified
bin/addons/msf_doc_import/account.py (+48/-36)
bin/addons/msf_profile/i18n/fr_MF.po (+24/-9)
Text conflict in bin/addons/msf_profile/i18n/fr_MF.po
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-5756
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+367327@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/msf_doc_import/account.py'
2--- bin/addons/msf_doc_import/account.py 2019-01-03 09:17:52 +0000
3+++ bin/addons/msf_doc_import/account.py 2019-05-13 07:25:22 +0000
4@@ -71,33 +71,34 @@
5 # Browse result
6 b_entries = self.pool.get('msf.doc.import.accounting.lines').browse(cr, uid, entries)
7 # Update wizard
8- self.write(cr, uid, [w.id], {'message': _('Grouping by currencies…'), 'progression': 10.0})
9- # Search all currencies (to create moves)
10- available_currencies = {}
11+ self.write(cr, uid, [w.id], {'message': _('Grouping by currency and date…'), 'progression': 10.0})
12+ # Group entries by currency, period and doc date (to create moves)
13+ curr_date_group = {}
14 for entry in b_entries:
15- if (entry.currency_id.id, entry.period_id.id) not in available_currencies:
16- available_currencies[(entry.currency_id.id, entry.period_id.id)] = []
17- available_currencies[(entry.currency_id.id, entry.period_id.id)].append(entry)
18+ # note: having different periods is possible only for December dates (ex: Period 13 and 14)
19+ if (entry.currency_id.id, entry.period_id.id, entry.document_date) not in curr_date_group:
20+ curr_date_group[(entry.currency_id.id, entry.period_id.id, entry.document_date)] = []
21+ curr_date_group[(entry.currency_id.id, entry.period_id.id, entry.document_date)].append(entry)
22 # Update wizard
23- self.write(cr, uid, ids, {'message': _('Writing a move for each currency…'), 'progression': 20.0})
24+ self.write(cr, uid, ids, {'message': _('Writing of the Journal Entries…'), 'progression': 20.0})
25 num = 1
26- nb_currencies = float(len(available_currencies))
27+ nb_entries = float(len(curr_date_group))
28 remaining_percent = 80.0
29- step = float(remaining_percent / nb_currencies)
30- for c_id, p_id in available_currencies:
31+ step = float(remaining_percent / nb_entries)
32+ for currency_id, period_id, document_date in curr_date_group:
33 # Create a move
34 move_vals = {
35- 'currency_id': c_id,
36- 'manual_currency_id': c_id,
37+ 'currency_id': currency_id,
38+ 'manual_currency_id': currency_id,
39 'journal_id': journal_id,
40- 'document_date': w.date,
41+ 'document_date': document_date,
42 'date': w.date,
43- 'period_id': p_id,
44+ 'period_id': period_id,
45 'status': 'manu',
46 'imported': True,
47 }
48 move_id = self.pool.get('account.move').create(cr, uid, move_vals, context)
49- for l_num, l in enumerate(available_currencies[(c_id, p_id)]):
50+ for l_num, l in enumerate(curr_date_group[(currency_id, period_id, document_date)]):
51 # Update wizard
52 progression = 20.0 + ((float(l_num) / float(len(b_entries))) * step) + (float(num - 1) * step)
53 self.write(cr, uid, [w.id], {'progression': progression})
54@@ -107,7 +108,7 @@
55 distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {}, context)
56 common_vals = {
57 'distribution_id': distrib_id,
58- 'currency_id': c_id,
59+ 'currency_id': currency_id,
60 'percentage': 100.0,
61 'date': l.date,
62 'source_date': l.date,
63@@ -123,13 +124,13 @@
64 'name': l.description,
65 'reference': l.ref,
66 'account_id': l.account_id.id,
67- 'period_id': p_id,
68+ 'period_id': period_id,
69 'document_date': l.document_date,
70 'date': l.date,
71 'journal_id': journal_id,
72 'debit_currency': l.debit,
73 'credit_currency': l.credit,
74- 'currency_id': c_id,
75+ 'currency_id': currency_id,
76 'analytic_distribution_id': distrib_id,
77 'partner_id': l.partner_id and l.partner_id.id or False,
78 'employee_id': l.employee_id and l.employee_id.id or False,
79@@ -246,6 +247,7 @@
80 raise osv.except_osv(_('Error'), _("'%s' column not found in file.") % (el or '',))
81 # All lines
82 money = {}
83+ doc_date_periods = set()
84 # Update wizard
85 self.write(cr, uid, [wiz.id], {'message': _('Reading lines…'), 'progression': 6.00})
86 # Check file's content
87@@ -284,6 +286,9 @@
88 errors.append(_('Line %s, the column \'Document Date\' have to be of type DateTime. Check the spreadsheet format (or export a document to have an example).') % (current_line_num,))
89 continue
90 r_document_date = line[cols['Document Date']].strftime('%Y-%m-%d')
91+ doc_date_period_ids = period_obj.get_period_from_date(cr, uid, r_document_date, context=context)
92+ if doc_date_period_ids:
93+ doc_date_periods.add(doc_date_period_ids[0])
94 # Check on booking amounts: ensure that one (and only one) value exists and that its amount isn't negative
95 book_debit = 0
96 book_credit = 0
97@@ -325,29 +330,32 @@
98 if not line[cols['Booking Currency']]:
99 errors.append(_('Line %s. No currency specified!') % (current_line_num,))
100 continue
101- curr_ids = self.pool.get('res.currency').search(cr, uid, [('name', '=', line[cols['Booking Currency']])])
102+ booking_curr = line[cols['Booking Currency']]
103+ curr_ids = self.pool.get('res.currency').search(cr, uid, [('name', '=', booking_curr)])
104 if not curr_ids:
105- errors.append(_('Line %s. Currency not found: %s') % (current_line_num, line[cols['Booking Currency']],))
106+ errors.append(_('Line %s. Currency not found: %s') % (current_line_num, booking_curr,))
107 continue
108 for c in self.pool.get('res.currency').browse(cr, uid, curr_ids):
109 if not c.active:
110- errors.append(_('Line %s. Currency is not active: %s') % (current_line_num, line[cols['Booking Currency']],))
111+ errors.append(_('Line %s. Currency is not active: %s') % (current_line_num, booking_curr,))
112 continue
113 r_currency = curr_ids[0]
114- if not line[cols['Booking Currency']] in money:
115- money[line[cols['Booking Currency']]] = {}
116- if not 'debit' in money[line[cols['Booking Currency']]]:
117- money[line[cols['Booking Currency']]]['debit'] = 0
118- if not 'credit' in money[line[cols['Booking Currency']]]:
119- money[line[cols['Booking Currency']]]['credit'] = 0
120- if not 'name' in money[line[cols['Booking Currency']]]:
121- money[line[cols['Booking Currency']]]['name'] = line[cols['Booking Currency']]
122+ if not line[cols['Period']]:
123+ errors.append(_('Line %s. Period is missing.') % (current_line_num))
124+ continue
125+ period_name = line[cols['Period']]
126+ if not (booking_curr, period_name, r_document_date) in money:
127+ money[(booking_curr, period_name, r_document_date)] = {}
128+ if not 'debit' in money[(booking_curr, period_name, r_document_date)]:
129+ money[(booking_curr, period_name, r_document_date)]['debit'] = 0
130+ if not 'credit' in money[(booking_curr, period_name, r_document_date)]:
131+ money[(booking_curr, period_name, r_document_date)]['credit'] = 0
132 # Increment global debit/credit
133 if book_debit:
134- money[line[cols['Booking Currency']]]['debit'] += book_debit
135+ money[(booking_curr, period_name, r_document_date)]['debit'] += book_debit
136 r_debit = book_debit
137 if book_credit:
138- money[line[cols['Booking Currency']]]['credit'] += book_credit
139+ money[(booking_curr, period_name, r_document_date)]['credit'] += book_credit
140 r_credit = book_credit
141
142 # Check which journal it is to be posted to: should be of type OD, MIG or INT
143@@ -504,12 +512,12 @@
144 continue
145
146 # US-937: use period of import file
147- if line[cols['Period']].startswith('Period 16'):
148+ if period_name.startswith('Period 16'):
149 raise osv.except_osv(_('Warning'), _("You can't import entries in Period 16."))
150 period_ids = period_obj.search(
151 cr, uid, [
152 ('id', 'in', wiz_period_ids),
153- ('name', '=', line[cols['Period']]),
154+ ('name', '=', period_name),
155 ], limit=1, context=context)
156 if not period_ids:
157 raise osv.except_osv(_('Warning'),
158@@ -603,12 +611,16 @@
159 continue
160 created += 1
161 # Check if all is ok for the file
162+ if len(doc_date_periods) > 1:
163+ errors.append(_('All Document Dates should be in the same period.'))
164 ## The lines should be balanced for each currency
165 if not errors:
166 # to compare the right amounts do the check only if no line has been ignored because of an error
167- for c in money:
168- if abs(money[c]['debit'] - money[c]['credit']) > 10**-3:
169- raise osv.except_osv(_('Error'), _('Currency %s is not balanced: %s') % (money[c]['name'], (money[c]['debit'] - money[c]['credit']),))
170+ for curr, per, doc_date in money:
171+ amount = money[(curr, per, doc_date)]['debit'] - money[(curr, per, doc_date)]['credit']
172+ if abs(amount) > 10**-3:
173+ raise osv.except_osv(_('Error'), _('Amount unbalanced for the Currency %s and the Document Date %s (Period: %s): %s') %
174+ (curr, doc_date, per, amount,))
175 # Update wizard
176 self.write(cr, uid, ids, {'message': _('Check complete. Reading potential errors or write needed changes.'), 'progression': 100.0})
177
178
179=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
180--- bin/addons/msf_profile/i18n/fr_MF.po 2019-05-10 15:26:36 +0000
181+++ bin/addons/msf_profile/i18n/fr_MF.po 2019-05-13 07:25:22 +0000
182@@ -23872,10 +23872,10 @@
183 msgstr "Derniers taux de change"
184
185 #. module: msf_doc_import
186-#: code:addons/msf_doc_import/account.py:73
187+#: code:addons/msf_doc_import/account.py:74
188 #, python-format
189-msgid "Grouping by currencies…"
190-msgstr "Regroupement par monnaies…"
191+msgid "Grouping by currency and date…"
192+msgstr "Regroupement par devise et date…"
193
194 #. module: stock_override
195 #: field:stock.picking,incoming_id:0
196@@ -41335,10 +41335,10 @@
197 msgstr "Retry from time"
198
199 #. module: msf_doc_import
200-#: code:addons/msf_doc_import/account.py:588
201+#: code:addons/msf_doc_import/account.py:622
202 #, python-format
203-msgid "Currency %s is not balanced: %s"
204-msgstr "La devise %s n'est pas équilibrée : %s"
205+msgid "Amount unbalanced for the Currency %s and the Document Date %s (Period: %s): %s"
206+msgstr "Montant non équilibré pour la Devise %s et la Date de Document %s (Période : %s) : %s"
207
208 #. module: msf_partner
209 #: code:addons/msf_partner/partner.py:754
210@@ -58195,10 +58195,10 @@
211 msgstr "Valeurs d'origine"
212
213 #. module: msf_doc_import
214-#: code:addons/msf_doc_import/account.py:81
215+#: code:addons/msf_doc_import/account.py:83
216 #, python-format
217-msgid "Writing a move for each currency…"
218-msgstr "Enregistrement d'une écriture comptable pour chaque monnaie…"
219+msgid "Writing of the Journal Entries…"
220+msgstr "Enregistrement des Écritures Comptables…"
221
222 #. module: base
223 #: code:addons/base/ir/ir_actions.py:677
224@@ -105896,6 +105896,7 @@
225 #: field:product.mass.update,empty_status:0
226 msgid "Set Status as empty"
227 msgstr "Mettre le Statut à vide"
228+<<<<<<< TREE
229
230 #. module: sourcing
231 #: code:addons/sourcing/sale_order_line.py:1606
232@@ -105941,3 +105942,17 @@
233 #, python-format
234 msgid "Please ensure that you selected the correct Source document because once the line is saved you will not be able to edit this field anymore. In case of mistake, the only option will be to Cancel the line and Create a new one with the correct Source document."
235 msgstr "Veuillez vous assurer que vous avez selectionné la bonne valeur pour le champ \"Document d'origine\". Une fois enregistrée cette valeur ne sera plus modifiable. En cas d'erreur la seule solution sera d'Annuler cette ligne et d'en créer une nouvelle."
236+=======
237+
238+#. module: msf_doc_import
239+#: code:addons/msf_doc_import/account.py:343
240+#, python-format
241+msgid "Line %s. Period is missing."
242+msgstr "Ligne %s. Il manque la Période."
243+
244+#. module: msf_doc_import
245+#: code:addons/msf_doc_import/account.py:615
246+#, python-format
247+msgid "All Document Dates should be in the same period."
248+msgstr "Toutes les Dates de Document doivent être dans la même période."
249+>>>>>>> MERGE-SOURCE

Subscribers

People subscribed via source and target branches