@@ -193,21 +193,25 @@ def product_import_generic(self):
193193 colonnes = []
194194 reference = ""
195195 for row in reader .iter_rows (min_row = 1 , max_row = 2 , max_col = 6 , values_only = True ):
196- if row [0 ] == "Infotmation " :
196+ if row [0 ] == "Information " :
197197 if row [1 ] == "Champ de reference" :
198198 reference = row [2 ]
199- product_ids = self .env ["product.product" ].search ([])
199+ product_ids = self .env ["product.product" ].search_read (
200+ [], ["default_code" , "barcode" ]
201+ )
200202 speedy_product_list = {}
201203 if reference == "default_code" :
202204 for p in product_ids :
203- speedy_product_list [p . default_code ] = p . id
205+ speedy_product_list [p [ " default_code" ]] = p [ "id" ]
204206 if reference == "barcode" :
205207 for p in product_ids :
206- speedy_product_list [p .barcode ] = p .id
207- product_template_ids = self .env ["product.template" ].search ([])
208+ speedy_product_list [p ["barcode" ]] = p ["id" ]
209+ product_template_ids = self .env ["product.template" ].search_read (
210+ [], ["default_code" ]
211+ )
208212 speedy_product_template_list = {}
209213 for p in product_template_ids :
210- speedy_product_template_list [p . default_code ] = p . id
214+ speedy_product_template_list [p [ " default_code" ]] = p [ "id" ]
211215 list_product_create = {}
212216 for row in reader .iter_rows (min_row = 4 , values_only = True ):
213217 vals = {}
@@ -260,7 +264,7 @@ def product_import_generic(self):
260264 vals = import_obj ._prepare_product_vals (vals , location_id , speedy )
261265 res = (
262266 self .env ["product.product" ]
263- .browse (speedy_product_list [vals ["default_code" ]])
267+ .browse (speedy_product_list [vals [reference ]])
264268 .write (vals )
265269 )
266270 if res :
@@ -269,6 +273,7 @@ def product_import_generic(self):
269273 )
270274 else :
271275 logger .warning (f"line { line } have done nothing" )
276+ continue
272277 elif (
273278 not template
274279 and vals .get (reference ) not in speedy_product_list
@@ -292,8 +297,22 @@ def product_import_generic(self):
292297 vals ["standard_price" ]
293298 )
294299 p .write (vals )
300+ continue
301+ elif template and vals .get ("default_code" ) in speedy_product_template_list :
302+ record = self .env ["product.template" ].browse (speedy_product_template_list [vals ["default_code" ]])
303+ if record and not vals ["location_id" ]:
304+ vals ["location_id" ] = record .location_id
305+ vals = import_obj ._prepare_product_vals (vals , vals ["location_id" ], speedy )
306+ res = record .write (vals )
307+ if res :
308+ continue
309+ else :
310+ logger .warning ("ERREUR lors de la mise a jour du product" )
311+ continue
312+
295313 elif not template or template and not variant_att :
296314 res = import_obj ._create_product (vals , speedy )
315+ continue
297316 elif template :
298317 location_id = vals .get ("location_id" ) or speedy .get (
299318 "default_location_id"
@@ -313,6 +332,7 @@ def product_import_generic(self):
313332 logger .info (f"{ p_tmpl .id } has been create" )
314333 else :
315334 logger .warning ("nothing" )
335+ continue
316336 else :
317337 logger .warning (f"NO PRODUCT IMPORTED line { line } Name { row [1 ]} " )
318338 else :
0 commit comments