Merge lp:~unifield-team/unifield-server/us-1279 into lp:unifield-server
- us-1279
- Merge into trunk
Proposed by
Quentin THEURET @Amaris
Status: | Merged |
---|---|
Merged at revision: | 4024 |
Proposed branch: | lp:~unifield-team/unifield-server/us-1279 |
Merge into: | lp:unifield-server |
Diff against target: |
373 lines (+132/-20) (has conflicts) 9 files modified
bin/addons/msf_doc_import/check_line.py (+25/-1) bin/addons/msf_doc_import/purchase_order.py (+8/-1) bin/addons/msf_doc_import/view/purchase_order_import_line_view.xml (+4/-1) bin/addons/msf_doc_import/wizard/__init__.py (+2/-2) bin/addons/msf_doc_import/wizard/wizard_import_po_line.py (+80/-15) bin/addons/msf_profile/i18n/fr_MF.po (+9/-0) bin/addons/msf_supply_doc_export/report/report_request_for_quotation_xls.mako (+2/-0) bin/addons/purchase_override/purchase.py (+1/-0) bin/addons/purchase_override/purchase_view.xml (+1/-0) Text conflict in bin/addons/msf_profile/i18n/fr_MF.po |
To merge this branch: | bzr merge lp:~unifield-team/unifield-server/us-1279 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Dev Team | Pending | ||
Review via email: mp+308611@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_doc_import/check_line.py' |
2 | --- bin/addons/msf_doc_import/check_line.py 2016-04-19 09:48:16 +0000 |
3 | +++ bin/addons/msf_doc_import/check_line.py 2016-10-26 10:53:26 +0000 |
4 | @@ -286,7 +286,9 @@ |
5 | except IndexError: |
6 | comment += _(' Product Code to be defined') |
7 | error_list.append(_('The Product\'s Code has to be defined')) |
8 | - return {'default_code': default_code, 'proc_type': proc_type, 'comment': comment, 'error_list': error_list, 'price_unit': price_unit, 'cost_price': cost_price} |
9 | + return { |
10 | + 'default_code': default_code, 'proc_type': proc_type, 'comment': comment, 'error_list': error_list, 'price_unit': price_unit, |
11 | + 'cost_price': cost_price, 'product_code':product_code} |
12 | |
13 | |
14 | def quantity_value(**kwargs): |
15 | @@ -611,6 +613,28 @@ |
16 | warning_list.append(_("No comment was defined")) |
17 | return {'comment': comment, 'warning_list': warning_list} |
18 | |
19 | + |
20 | +def line_number_value(**kwargs): |
21 | + ''' |
22 | + Retrives line number from Excel file |
23 | + ''' |
24 | + row = kwargs["row"] |
25 | + cell_nb = kwargs['cell_nb'] |
26 | + line_number = kwargs['to_write']['line_number'] |
27 | + error_list = kwargs['to_write']['error_list'] |
28 | + try: |
29 | + if not row.cells[cell_nb]: |
30 | + error_list.append(_("No line number was defined")) |
31 | + elif row.cells[cell_nb].type != 'int': |
32 | + error_list.append(_("The line number must be an integer")) |
33 | + else: |
34 | + line_number = row.cells[cell_nb].data |
35 | + except IndexError: |
36 | + error_list.append(_("No line number was defined")) |
37 | + return {'line_number': line_number, 'error_list':error_list} |
38 | + |
39 | + |
40 | + |
41 | def check_lines_currency(rows, ccy_col_index, ccy_expected_code): |
42 | """ |
43 | check rows currency |
44 | |
45 | === modified file 'bin/addons/msf_doc_import/purchase_order.py' |
46 | --- bin/addons/msf_doc_import/purchase_order.py 2016-08-18 08:32:03 +0000 |
47 | +++ bin/addons/msf_doc_import/purchase_order.py 2016-10-26 10:53:26 +0000 |
48 | @@ -268,6 +268,13 @@ |
49 | if isinstance(ids, (int, long)): |
50 | ids = [ids] |
51 | context.update({'active_id': ids[0]}) |
52 | + |
53 | + # Check if we are in the case of update of sent RfQ |
54 | + po = self.browse(cr, uid, [ids[0]], context=context)[0] |
55 | + columns = columns_for_po_line_import |
56 | + if not po.rfq_ok or po.state != 'rfq_sent': |
57 | + columns = columns_for_po_line_import[1:] |
58 | + |
59 | columns_header = [(_(f[0]), f[1]) for f in columns_header_for_po_line_import] |
60 | default_template = SpreadsheetCreator('Template of import', columns_header, []) |
61 | file = base64.encodestring(default_template.get_xml(default_filters=['decode.utf8'])) |
62 | @@ -275,7 +282,7 @@ |
63 | 'filename_template': 'template.xls', |
64 | 'filename': 'Lines_Not_Imported.xls', |
65 | 'po_id': ids[0], |
66 | - 'message': """%s %s""" % (_(GENERIC_MESSAGE), ', '.join([_(f) for f in columns_for_po_line_import]),), |
67 | + 'message': """%s %s""" % (_(GENERIC_MESSAGE), ', '.join([_(f) for f in columns]),), |
68 | 'state': 'draft', }, |
69 | context) |
70 | return {'type': 'ir.actions.act_window', |
71 | |
72 | === modified file 'bin/addons/msf_doc_import/view/purchase_order_import_line_view.xml' |
73 | --- bin/addons/msf_doc_import/view/purchase_order_import_line_view.xml 2016-05-26 08:58:45 +0000 |
74 | +++ bin/addons/msf_doc_import/view/purchase_order_import_line_view.xml 2016-10-26 10:53:26 +0000 |
75 | @@ -25,7 +25,7 @@ |
76 | <field name="soq_updated" invisible="1" readonly="1" /> |
77 | </xpath> |
78 | <xpath expr="/form/notebook/page/field[@name='order_line']/tree" position="attributes" > |
79 | - <attribute name="colors">red:to_correct_ok == True or inactive_product == True; #C8C8C8: fake_state == 'cancel'; orange:product_qty == 0.00;blue: soq_updated == True</attribute> |
80 | + <attribute name="colors">red:to_correct_ok == True or inactive_product == True or red_color == True; #C8C8C8: fake_state == 'cancel'; orange:product_qty == 0.00;blue: soq_updated == True</attribute> |
81 | </xpath> |
82 | <xpath expr="/form/notebook/page[@string='Notes']/field[@name='notes']" position="before"> |
83 | <field name="import_in_progress" readonly="1" invisible="0" /> |
84 | @@ -42,6 +42,9 @@ |
85 | </field> |
86 | </xpath> |
87 | <xpath expr="/form/notebook/page[@string='Purchase Order']/field[@name='order_line']" position="before" > |
88 | + <button name="wizard_import_po_line" string="Import RfQ lines" icon="gtk-dnd" type="object" attrs="{'invisible':[('state', '!=', 'rfq_sent')]}"/> |
89 | + </xpath> |
90 | + <xpath expr="/form/notebook/page[@string='Purchase Order']/field[@name='order_line']" position="before" > |
91 | <group name="import" string=" Import Lines " colspan="1" col="4" attrs="{'invisible':[('state', '!=', 'draft')]}"> |
92 | <button name="wizard_import_po_line" string="Import lines" icon="gtk-dnd" col="1" type="object" attrs="{'invisible':[('state', '!=', 'draft')]}"/> |
93 | <button name="button_remove_lines" string="Delete Lines" icon="gtk-remove" colspan="1" type="object" attrs="{'invisible': ['|', ('po_from_fo', '=', True), ('po_from_ir', '=', True)]}" /> |
94 | |
95 | === modified file 'bin/addons/msf_doc_import/wizard/__init__.py' |
96 | --- bin/addons/msf_doc_import/wizard/__init__.py 2016-09-12 08:55:55 +0000 |
97 | +++ bin/addons/msf_doc_import/wizard/__init__.py 2016-10-26 10:53:26 +0000 |
98 | @@ -54,8 +54,8 @@ |
99 | #Important NOTE: I didn't set the fields of type date with the attribute 'date' (2nd part of the tuple) because for Excel, when a date is empty, the field becomes '1899-30-12' as default. So I set 'string' instead for the fields date. |
100 | |
101 | PO_COLUMNS_HEADER_FOR_IMPORT=[ |
102 | -(_('Product Code'), 'string'), (_('Product Description'), 'string'), (_('Quantity'), 'number'), (_('UoM'), 'string'), (_('Price'), 'number'), |
103 | -(_('Delivery Request Date'), 'date'), (_('Currency'), 'string'), (_('Comment'), 'string'), (_('Justification Code'), 'string'), (_('Justification Coordination'), 'string'), (_('HQ Remarks'), 'string'), (_('Justification Y/N'), 'string')] |
104 | +(_('Line Number'), 'number'), (_('Product Code'), 'string'), (_('Product Description'), 'string'), (_('Quantity'), 'number'), (_('UoM'), 'string'), (_('Price'), 'number'), |
105 | +(_('Delivery Request Date'), 'date'), (_('Currency'), 'string'), (_('Comment'), 'string'), (_('Justification Code'), 'string'), (_('Justification Coordination'), 'string'), (_('HQ Remarks'), 'string'), (_('Justification Y/N'), 'string'),] |
106 | PO_LINE_COLUMNS_FOR_IMPORT = [x for (x, y) in PO_COLUMNS_HEADER_FOR_IMPORT] |
107 | |
108 | FO_COLUMNS_HEADER_FOR_IMPORT=[ |
109 | |
110 | === modified file 'bin/addons/msf_doc_import/wizard/wizard_import_po_line.py' |
111 | --- bin/addons/msf_doc_import/wizard/wizard_import_po_line.py 2016-08-26 10:10:58 +0000 |
112 | +++ bin/addons/msf_doc_import/wizard/wizard_import_po_line.py 2016-10-26 10:53:26 +0000 |
113 | @@ -96,30 +96,38 @@ |
114 | or not wiz.po_id.pricelist_id.currency_id: |
115 | raise osv.except_osv(_("Error!"), _("Order currency not found!")) |
116 | |
117 | - ignore_lines, complete_lines, lines_to_correct = 0, 0, 0 |
118 | + ignore_lines, complete_lines, lines_to_correct, created_lines = 0, 0, 0, 0 |
119 | line_ignored_num, error_list = [], [] |
120 | error_log, message = '', '' |
121 | header_index = context['header_index'] |
122 | template_col_count = len(header_index) |
123 | - mandatory_col_count = 7 |
124 | + is_rfq = wiz.po_id.rfq_ok and wiz.po_id.state == 'rfq_sent' |
125 | + mandatory_col_count = 8 if is_rfq else 7 |
126 | |
127 | file_obj = SpreadsheetXML(xmlstring=base64.decodestring(wiz.file)) |
128 | |
129 | """ |
130 | 1st path: check currency in lines in phasis with document |
131 | REF-94: BECAREFUL WHEN CHANGING THE ORDER OF CELLS IN THE IMPORT FILE!!!!! |
132 | - CCY COL INDEX: 6 |
133 | + CCY COL INDEX: 6 (PO) or 7 (RfQ) |
134 | """ |
135 | order_currency_code = wiz.po_id.pricelist_id.currency_id.name |
136 | - currency_index = 6 |
137 | + currency_index = 7 if is_rfq else 6 |
138 | row_iterator = file_obj.getRows() |
139 | |
140 | # don't use the original |
141 | row_iterator, row_iterator_line_check = itertools.tee(row_iterator) |
142 | |
143 | row_iterator_line_check.next() # skip header line |
144 | - lines_to_correct = check_line.check_lines_currency(row_iterator_line_check, |
145 | - currency_index, order_currency_code) |
146 | + try: |
147 | + lines_to_correct = check_line.check_lines_currency(row_iterator_line_check, currency_index, order_currency_code) |
148 | + except Exception as e: |
149 | + message = _("""An error occurs during the check of the currency: %s""") % e |
150 | + categ_log = '' |
151 | + line_num = 0 |
152 | + error_list.append(message) |
153 | + logging.getLogger('import purchase order').error('Error %s' % e) |
154 | + |
155 | if lines_to_correct > 0: |
156 | categ_log = '' |
157 | line_num = 0 |
158 | @@ -129,6 +137,7 @@ |
159 | error_list.append(msg) |
160 | |
161 | if not error_list: |
162 | + line_number_set = set() |
163 | to_write = {} |
164 | total_line_num = file_obj.getNbRows() |
165 | # ignore the header line |
166 | @@ -153,13 +162,14 @@ |
167 | 'proc_type': 'make_to_order', |
168 | 'default_code': False, |
169 | 'confirmed_delivery_date': False, |
170 | + 'line_number':'', |
171 | } |
172 | |
173 | col_count = len(row) |
174 | if col_count != template_col_count and col_count != mandatory_col_count: |
175 | message += _("Line %s: You should have exactly %s columns in this order: %s \n") % ( |
176 | line_num, template_col_count, |
177 | - ','.join(columns_for_po_line_import)) |
178 | + ','.join(is_rfq and columns_for_po_line_import or columns_for_po_line_import[1:])) |
179 | line_with_error.append( |
180 | wiz_common_import.get_line_values( |
181 | cr, uid, ids, row, cell_nb=False, |
182 | @@ -176,7 +186,16 @@ |
183 | total_line_num -= 1 |
184 | continue |
185 | |
186 | - # Cell 0: Product Code |
187 | + |
188 | + # Cell 0 : Line Number (RfQ) |
189 | + if is_rfq: |
190 | + ln_value = check_line.line_number_value( |
191 | + row=row, cell_nb=header_index[_('Line Number')], to_write=to_write, context=context) |
192 | + to_write.update( |
193 | + line_number=ln_value['line_number'], |
194 | + error_list=ln_value['error_list']) |
195 | + |
196 | + # Cell 1: Product Code |
197 | p_value = check_line.product_value( |
198 | cr, uid, obj_data=obj_data, cell_nb=header_index[_('Product Code')], |
199 | product_obj=product_obj, row=row, to_write=to_write, context=context) |
200 | @@ -211,7 +230,7 @@ |
201 | to_write.update(product_qty=round_qty['value']['product_qty']) |
202 | warn_list = to_write['warning_list'] |
203 | warn_list.append(round_qty['warning']['message']) |
204 | - #message += _("Line %s in the Excel file: %s\n") % (line_num, round_qty['warning']['message']) |
205 | + #message += _("Line %s in the Excel file: %s\n") % (line_num, round_qty['warning']['message']) |
206 | |
207 | # Cell 4: Price |
208 | price_value = check_line.compute_price_value( |
209 | @@ -245,11 +264,14 @@ |
210 | to_write.update( |
211 | comment=c_value['comment'], |
212 | warning_list=c_value['warning_list']) |
213 | + |
214 | + |
215 | to_write.update( |
216 | to_correct_ok=any(to_write['error_list']), # the lines with to_correct_ok=True will be red |
217 | show_msg_ok=any(to_write['warning_list']), # the lines with show_msg_ok=True won't change color, it is just info |
218 | order_id=wiz.po_id.id, |
219 | text_error='\n'.join(to_write['error_list'] + to_write['warning_list'])) |
220 | + |
221 | # we check consistency on the model of on_change functions to call for updating values |
222 | purchase_line_obj.check_line_consistency( |
223 | cr, uid, wiz.po_id.id, to_write=to_write, context=context) |
224 | @@ -264,9 +286,50 @@ |
225 | cr.rollback() |
226 | continue |
227 | |
228 | - # write order line on PO |
229 | - purchase_line_obj.create(cr, uid, to_write, context=context) |
230 | - vals['order_line'].append((0, 0, to_write)) |
231 | + |
232 | + if is_rfq: |
233 | + rfq_line_ids = purchase_line_obj.search(cr, uid, [('order_id', '=', wiz.po_id.id), ('line_number', '=', to_write['line_number'])]) |
234 | + to_write['rfq_ok'] = True |
235 | + |
236 | + # CASE 1: the line is not registered in the system, so CREATE it : |
237 | + if not rfq_line_ids: |
238 | + created_lines += 1 |
239 | + if wiz.po_id.tender_id: |
240 | + msg = _('Warning! You are adding new lines which did not exist in the original tender!') |
241 | + if msg not in message: |
242 | + message += msg |
243 | + to_write.update({ |
244 | + 'line_number': False, |
245 | + 'red_color': True, |
246 | + }) |
247 | + purchase_line_obj.create(cr, uid, to_write, context=context) |
248 | + |
249 | + # CASE 2: the line is already in the system, so UPDATE it : |
250 | + for po_line in purchase_line_obj.browse(cr, uid, rfq_line_ids, context=context): |
251 | + # some checks : |
252 | + if to_write['line_number'] in line_number_set: |
253 | + raise osv.except_osv(_('Error'), _("the same line number appears several times")) |
254 | + else: |
255 | + line_number_set.add(to_write['line_number']) |
256 | + if p_value['product_code'] != po_line.product_id.default_code: |
257 | + raise osv.except_osv(_('Error'), _("Product code from system and from import must be the same.")) |
258 | + if not price_value['price_unit_defined']: |
259 | + raise osv.except_osv(_('Error'), _("Price must be defined in the RfQ import file.")) |
260 | + |
261 | + # in case of update we do not want to update qty and uom values : |
262 | + if to_write.has_key('product_qty'): |
263 | + to_write.pop('product_qty') |
264 | + if to_write.has_key('product_uom'): |
265 | + to_write.pop('product_uom') |
266 | + |
267 | + # update POL : |
268 | + purchase_line_obj.write(cr, uid, rfq_line_ids, to_write, context=context) |
269 | + |
270 | + else: # its not RfQ |
271 | + purchase_line_obj.create(cr, uid, to_write, context=context) |
272 | + |
273 | + vals['order_line'].append((0, 0, to_write)) |
274 | + |
275 | if to_write['error_list']: |
276 | lines_to_correct += 1 |
277 | complete_lines += 1 |
278 | @@ -327,13 +390,13 @@ |
279 | final_message = _(''' |
280 | %s |
281 | Importation completed in %s! |
282 | -# of imported lines : %s on %s lines |
283 | +# of imported lines : %s on %s lines (%s updated and %s created) |
284 | # of ignored lines: %s |
285 | # of lines to correct: %s |
286 | %s |
287 | |
288 | %s |
289 | -''') % (categ_log, total_time, complete_lines, line_num, ignore_lines, lines_to_correct, error_log, message) |
290 | +''') % (categ_log, total_time, complete_lines, line_num, complete_lines-created_lines,created_lines, ignore_lines, lines_to_correct, error_log, message) |
291 | wizard_vals['message'] = final_message |
292 | if line_with_error: |
293 | file_to_export = wiz_common_import.export_file_with_error( |
294 | @@ -371,8 +434,10 @@ |
295 | header_index = wiz_common_import.get_header_index( |
296 | cr, uid, ids, first_row, error_list=[], line_num=0, context=context) |
297 | context.update({'po_id': po_id, 'header_index': header_index}) |
298 | + rfq = purchase_obj.read(cr, uid, po_id, ['state', 'rfq_ok'], context=context) |
299 | + is_rfq = rfq['rfq_ok'] and rfq['state'] == 'rfq_sent' |
300 | res, res1 = wiz_common_import.check_header_values( |
301 | - cr, uid, ids, context, header_index, columns_for_po_line_import, |
302 | + cr, uid, ids, context, header_index, is_rfq and columns_for_po_line_import or columns_for_po_line_import[1:], |
303 | origin='PO') |
304 | if not res: |
305 | return self.write(cr, uid, ids, res1, context) |
306 | |
307 | === modified file 'bin/addons/msf_profile/i18n/fr_MF.po' |
308 | --- bin/addons/msf_profile/i18n/fr_MF.po 2016-10-21 15:36:56 +0000 |
309 | +++ bin/addons/msf_profile/i18n/fr_MF.po 2016-10-26 10:53:26 +0000 |
310 | @@ -74611,6 +74611,7 @@ |
311 | " Number of columns is not equal to %s" |
312 | msgstr "\n" |
313 | " Le nombre de colonnes n'est pas égal à %s" |
314 | +<<<<<<< TREE |
315 | |
316 | #. module: specific_rules |
317 | #: report:addons/specific_rules/report/report_stock_inventory_all_locations_xls.mako:143 |
318 | @@ -74683,3 +74684,11 @@ |
319 | msgid "You can't search on this object without using at least one exact search term (precede your search with the character '=')." |
320 | msgstr "Vous ne pouvez pas exécuter de recherche sur cet objet sans utiliser au moins une recherche exacte (ajoutez le caractère = devant votre filtre)." |
321 | |
322 | +======= |
323 | + |
324 | +#. module: msf_doc_import |
325 | +#: code:addons/msf_doc_import/wizard/wizard_import_po_line.py:300 |
326 | +#, python-format |
327 | +msgid "Warning! You are adding new lines which did not exist in the original tender!" |
328 | +msgstr "Attention ! Vous avez ajouté une nouvelle ligne qui n'existe pas dans l'appel d'offre original !" |
329 | +>>>>>>> MERGE-SOURCE |
330 | |
331 | === modified file 'bin/addons/msf_supply_doc_export/report/report_request_for_quotation_xls.mako' |
332 | --- bin/addons/msf_supply_doc_export/report/report_request_for_quotation_xls.mako 2014-04-29 14:10:16 +0000 |
333 | +++ bin/addons/msf_supply_doc_export/report/report_request_for_quotation_xls.mako 2016-10-26 10:53:26 +0000 |
334 | @@ -66,6 +66,7 @@ |
335 | <Column ss:AutoFitWidth="1" ss:Width="250" /> |
336 | |
337 | <Row> |
338 | + <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Line Number')}</Data></Cell> |
339 | <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Product Code')}</Data></Cell> |
340 | <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Product Description')}</Data></Cell> |
341 | <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Quantity')}</Data></Cell> |
342 | @@ -77,6 +78,7 @@ |
343 | </Row> |
344 | % for line in o.order_line: |
345 | <Row> |
346 | + <Cell ss:StyleID="line" ><Data ss:Type="Number">${(line.line_number or '')|x}</Data></Cell> |
347 | <Cell ss:StyleID="line" ><Data ss:Type="String">${(line.product_id.default_code or '')|x}</Data></Cell> |
348 | <Cell ss:StyleID="line" ><Data ss:Type="String">${(line.product_id.name or '')|x}</Data></Cell> |
349 | <Cell ss:StyleID="line" ><Data ss:Type="Number">${(line.product_qty or '')|x}</Data></Cell> |
350 | |
351 | === modified file 'bin/addons/purchase_override/purchase.py' |
352 | --- bin/addons/purchase_override/purchase.py 2016-10-16 10:55:55 +0000 |
353 | +++ bin/addons/purchase_override/purchase.py 2016-10-26 10:53:26 +0000 |
354 | @@ -3708,6 +3708,7 @@ |
355 | string='SoQ updated', |
356 | readonly=True, |
357 | ), |
358 | + 'red_color': fields.boolean(string='Red color'), |
359 | } |
360 | |
361 | _defaults = { |
362 | |
363 | === modified file 'bin/addons/purchase_override/purchase_view.xml' |
364 | --- bin/addons/purchase_override/purchase_view.xml 2016-08-03 12:08:12 +0000 |
365 | +++ bin/addons/purchase_override/purchase_view.xml 2016-10-26 10:53:26 +0000 |
366 | @@ -146,6 +146,7 @@ |
367 | </xpath> |
368 | |
369 | <xpath expr="/form/notebook//tree//field[@name='price_subtotal']" position="after"> |
370 | + <field name="red_color" invisible="1" /> |
371 | <field name="rfq_ok" invisible="1" /> |
372 | <field name="tender_line_id" invisible="1" /> |
373 | <field name="fake_state" invisible="1" /> |