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

Proposed by jftempo
Status: Merged
Merged at revision: 4993
Proposed branch: lp:~julie-w/unifield-server/US-4688
Merge into: lp:unifield-server
Diff against target: 228 lines (+103/-22)
3 files modified
bin/addons/msf_doc_import/account.py (+45/-13)
bin/addons/msf_doc_import/import_tools.py (+11/-5)
bin/addons/msf_profile/i18n/fr_MF.po (+47/-4)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-4688
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+349129@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 2018-05-16 09:47:27 +0000
3+++ bin/addons/msf_doc_import/account.py 2018-07-09 08:35:57 +0000
4@@ -267,7 +267,7 @@
5 r_document_date = False
6 current_line_num = num + base_num
7 # Fetch all XML row values
8- line = self.pool.get('import.cell.data').get_line_values(cr, uid, ids, r)
9+ line = self.pool.get('import.cell.data').get_line_values(cr, uid, ids, r, context=context)
10
11 # ignore empty lines
12 if not self._check_has_data(line):
13@@ -283,11 +283,41 @@
14 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,))
15 continue
16 r_document_date = line[cols['Document Date']].strftime('%Y-%m-%d')
17- # Bypass this line if NO debit AND NO credit
18+ # Check on booking amounts: ensure that one (and only one) value exists and that its amount isn't negative
19+ book_debit = 0
20+ book_credit = 0
21 try:
22- if not line[cols['Booking Debit']] and not line[cols['Booking Credit']]:
23+ book_debit = line[cols['Booking Debit']]
24+ book_credit = line[cols['Booking Credit']]
25+ if book_debit and book_credit:
26+ errors.append(_('Line %s. Only one value (Booking Debit or Booking Credit) should be filled in.') % (current_line_num,))
27+ continue
28+ if not book_debit and not book_credit:
29+ # /!\ display different messages depending if values are zero or empty
30+ debit_is_zero = book_debit is 0 or book_debit is 0.0
31+ credit_is_zero = book_credit is 0 or book_credit is 0.0
32+ if debit_is_zero and credit_is_zero:
33+ errors.append(_('Line %s. Booking Debit and Booking Credit at 0, please change.') % (current_line_num,))
34+ continue
35+ elif not debit_is_zero and not credit_is_zero:
36+ # empty cells
37+ errors.append(_('Line %s. Please fill in either a Booking Debit or a Booking Credit value.') % (current_line_num,))
38+ continue
39+ else:
40+ amount_zero_str = debit_is_zero and _('Booking Debit') or _('Booking Credit')
41+ amount_empty_str = debit_is_zero and _('Booking Credit') or _('Booking Debit')
42+ errors.append(_('Line %s. %s at 0, %s empty, please change.') % (current_line_num,
43+ amount_zero_str, amount_empty_str))
44+ continue
45+ if (book_debit and not isinstance(book_debit, (int, long, float))) or \
46+ (book_credit and not isinstance(book_credit, (int, long, float))):
47+ errors.append(_('Line %s. The Booking Debit or Credit amount is invalid and should be a number.') % (current_line_num,))
48+ continue
49+ if (book_debit and book_debit < 0) or (book_credit and book_credit < 0):
50+ errors.append(_('Line %s. Negative numbers are forbidden for the Booking Debit and Credit amounts.') % (current_line_num,))
51 continue
52 except IndexError:
53+ errors.append(_('Line %s. The Booking Debit and Credit amounts are missing.') % (current_line_num,))
54 continue
55 processed += 1
56 # Check that currency is active
57@@ -312,12 +342,12 @@
58 if not 'name' in money[line[cols['Booking Currency']]]:
59 money[line[cols['Booking Currency']]]['name'] = line[cols['Booking Currency']]
60 # Increment global debit/credit
61- if line[cols['Booking Debit']]:
62- money[line[cols['Booking Currency']]]['debit'] += line[cols['Booking Debit']]
63- r_debit = line[cols['Booking Debit']]
64- if line[cols['Booking Credit']]:
65- money[line[cols['Booking Currency']]]['credit'] += line[cols['Booking Credit']]
66- r_credit = line[cols['Booking Credit']]
67+ if book_debit:
68+ money[line[cols['Booking Currency']]]['debit'] += book_debit
69+ r_debit = book_debit
70+ if book_credit:
71+ money[line[cols['Booking Currency']]]['credit'] += book_credit
72+ r_credit = book_credit
73
74 # Check which journal it is to be posted to: should be of type OD, MIG or INT
75 if not line[cols['Journal Code']]:
76@@ -336,7 +366,7 @@
77 errors.append(_('Line %s. Import of entries only allowed on the following journal(s): %s') % (current_line_num, journal_list))
78 continue
79 aj_id = aj_ids[0]
80- if num == 0:
81+ if file_journal_id == 0: # take the journal from the first line where there was no "continue"
82 file_journal_id = aj_id
83 else:
84 if file_journal_id != aj_id:
85@@ -573,9 +603,11 @@
86 created += 1
87 # Check if all is ok for the file
88 ## The lines should be balanced for each currency
89- for c in money:
90- if abs(money[c]['debit'] - money[c]['credit']) >= 10**-2:
91- raise osv.except_osv(_('Error'), _('Currency %s is not balanced: %s') % (money[c]['name'], (money[c]['debit'] - money[c]['credit']),))
92+ if not errors:
93+ # to compare the right amounts do the check only if no line has been ignored because of an error
94+ for c in money:
95+ if abs(money[c]['debit'] - money[c]['credit']) >= 10**-2:
96+ raise osv.except_osv(_('Error'), _('Currency %s is not balanced: %s') % (money[c]['name'], (money[c]['debit'] - money[c]['credit']),))
97 # Update wizard
98 self.write(cr, uid, ids, {'message': _('Check complete. Reading potential errors or write needed changes.'), 'progression': 100.0})
99
100
101=== modified file 'bin/addons/msf_doc_import/import_tools.py'
102--- bin/addons/msf_doc_import/import_tools.py 2017-04-19 13:07:44 +0000
103+++ bin/addons/msf_doc_import/import_tools.py 2018-07-09 08:35:57 +0000
104@@ -28,14 +28,18 @@
105 '''
106 _name = 'import.cell.data'
107
108- def get_cell_data(self, cr, uid, ids, row, cell_nb):
109+ def get_cell_data(self, cr, uid, ids, row, cell_nb, context=None):
110+ if context is None:
111+ context = {}
112 cell_data = False
113 try:
114 line_content = row.cells
115 except ValueError:
116 line_content = row.cells
117- if line_content and len(line_content)-1>=cell_nb and row.cells[cell_nb] and row.cells[cell_nb].data:
118- cell_data = row.cells[cell_nb].data
119+ if line_content and len(line_content) - 1 >= cell_nb and row.cells[cell_nb]:
120+ if row.cells[cell_nb].data or context.get('from_je_import', False):
121+ # at JE import store the exact value: 0.00 and False are handled differently
122+ cell_data = row.cells[cell_nb].data
123 return cell_data
124
125 def get_purchase_id(self, cr, uid, ids, row, cell_nb, line_num, error_list, context=None):
126@@ -130,10 +134,12 @@
127 return False
128 return False
129
130- def get_line_values(self, cr, uid, ids, row):
131+ def get_line_values(self, cr, uid, ids, row, context=None):
132+ if context is None:
133+ context = {}
134 list_of_values = []
135 for cell_nb in range(len(row)):
136- cell_data = self.get_cell_data(cr, uid, ids, row, cell_nb)
137+ cell_data = self.get_cell_data(cr, uid, ids, row, cell_nb, context=context)
138 # cells filled with whitespace should behave the same as cells that are empty
139 if isinstance(cell_data, basestring) and cell_data.isspace():
140 cell_data = ''
141
142=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
143--- bin/addons/msf_profile/i18n/fr_MF.po 2018-06-15 12:30:42 +0000
144+++ bin/addons/msf_profile/i18n/fr_MF.po 2018-07-09 08:35:57 +0000
145@@ -23962,10 +23962,11 @@
146 msgid "Line %s. Only a single Journal Code can be specified per file"
147 msgstr "Line %s. Only a single Journal Code can be specified per file"
148
149-#. modules: account, account_mcdb, register_accounting
150+#. modules: account, account_mcdb, register_accounting, msf_doc_import
151 #: report:combined.journals.report.pdf:0
152 #: report:addons/account_mcdb/report/combined_journals_report.mako:247
153 #: report:addons/register_accounting/report/open_advances_xls.mako:154
154+#: code:addons/msf_doc_import/account.py:308
155 msgid "Booking Credit"
156 msgstr "Crédit Devise d'enreg."
157
158@@ -26375,10 +26376,11 @@
159 msgid "Number to Ship"
160 msgstr "Nombre à Expédier"
161
162-#. modules: account, account_mcdb, register_accounting
163+#. modules: account, account_mcdb, register_accounting, msf_doc_import
164 #: report:combined.journals.report.pdf:0
165 #: report:addons/account_mcdb/report/combined_journals_report.mako:244
166 #: report:addons/register_accounting/report/open_advances_xls.mako:153
167+#: code:addons/msf_doc_import/account.py:307
168 msgid "Booking Debit"
169 msgstr "Débit Devise d'enreg."
170
171@@ -41334,10 +41336,10 @@
172 msgstr "Retry from time"
173
174 #. module: msf_doc_import
175-#: code:addons/msf_doc_import/account.py:578
176+#: code:addons/msf_doc_import/account.py:588
177 #, python-format
178 msgid "Currency %s is not balanced: %s"
179-msgstr "Currency %s is not balanced: %s"
180+msgstr "La devise %s n'est pas équilibrée : %s"
181
182 #. module: msf_partner
183 #: code:addons/msf_partner/partner.py:754
184@@ -101265,3 +101267,44 @@
185 msgid "Not Invoice"
186 msgstr "Pas de Facture"
187
188+#. module: msf_doc_import
189+#: code:addons/msf_doc_import/account.py:290
190+#, python-format
191+msgid "Line %s. Only one value (Booking Debit or Booking Credit) should be filled in."
192+msgstr "Ligne %s. Seule une valeur (Débit ou Crédit en devise d'enregistrement) doit être renseignée."
193+
194+#. module: msf_doc_import
195+#: code:addons/msf_doc_import/account.py:293
196+#, python-format
197+msgid "Line %s. The Booking Debit or Credit amount is invalid and should be a number."
198+msgstr "Ligne %s. Le montant Débit ou Crédit en devise d'enregistrement est invalide et devrait être un nombre."
199+
200+#. module: msf_doc_import
201+#: code:addons/msf_doc_import/account.py:296
202+#, python-format
203+msgid "Line %s. Negative numbers are forbidden for the Booking Debit and Credit amounts."
204+msgstr "Ligne %s. Les nombres négatifs sont interdits pour les montants Débit et Crédit en devise d'enregistrement."
205+
206+#. module: msf_doc_import
207+#: code:addons/msf_doc_import/account.py:299
208+#, python-format
209+msgid "Line %s. The Booking Debit and Credit amounts are missing."
210+msgstr "Ligne %s. Il manque les montants Débit et Crédit en devise d'enregistrement."
211+
212+#. module: msf_doc_import
213+#: code:addons/msf_doc_import/account.py:309
214+#, python-format
215+msgid "Line %s. %s at 0, %s empty, please change."
216+msgstr "Ligne %s. %s à 0, %s vide, veuillez modifier."
217+
218+#. module: msf_doc_import
219+#: code:addons/msf_doc_import/account.py:300
220+#, python-format
221+msgid "Line %s. Booking Debit and Booking Credit at 0, please change."
222+msgstr "Ligne %s. Les montants Débit et Crédit en devise d'enregistrement sont à zéro, veuillez modifier."
223+
224+#. module: msf_doc_import
225+#: code:addons/msf_doc_import/account.py:304
226+#, python-format
227+msgid "Line %s. Please fill in either a Booking Debit or a Booking Credit value."
228+msgstr "Ligne %s. Veuillez renseigner une valeur en devise d'enregistrement, soit en débit soit en crédit."

Subscribers

People subscribed via source and target branches