~unifield-team/unifield-wm/improve-stock

« back to all changes in this revision

Viewing changes to msf_profile/msf_profile.py

  • Committer: Quentin THEURET
  • Date: 2016-02-12 10:24:09 UTC
  • Revision ID: qt@tempo-consulting.fr-20160212102409-w5zyu2v10v4pll35
[IMP] Use Product Stock availability on product_reserve method

Show diffs side-by-side

added added

removed removed

Lines of Context:
298
298
        for view in view_to_gen:
299
299
            view_obj.generate_button_access_rules(cr, uid, view)
300
300
 
 
301
    def pas_patch(self, cr, uid, *a, **b):
 
302
        return
 
303
        location_obj = self.pool.get('stock.location')
 
304
        product_obj = self.pool.get('product.product')
 
305
        prodlot_obj = self.pool.get('stock.production.lot')
 
306
        pas_obj = self.pool.get('product.stock.availability')
 
307
 
 
308
        location_ids = location_obj.search(cr, uid, [('usage', '!=', 'view')])
 
309
        lot_ids = prodlot_obj.search(cr, uid, [])
 
310
        prod_lot_ids = []
 
311
        already_ids = set()
 
312
        for lot in prodlot_obj.search(cr, uid, lot_ids):
 
313
            already_ids.add(lot.product_id.id)
 
314
            prod_lot_ids.append((lot.id, lot.product_id.id))
 
315
        product_ids = product_obj.search(cr, uid, [('id', 'not in', list(already_ids))])
 
316
 
 
317
        for loc_id in location_ids:
 
318
            for lot in prod_lot_ids:
 
319
                c = {'location': loc_id, 'prodlot_id': lot[0]}
 
320
                pas_obj.create(cr, uid, {
 
321
                    'location_id': loc_id,
 
322
                    'prodlot_id': lot[0],
 
323
                    'product_id': lot[1],
 
324
                    'quantity': product_obj.browse(cr, uid, lot[1], context=c).qty_available,
 
325
                })
 
326
            for prod_id in product_ids:
 
327
                c = {'location': loc_id}
 
328
                pas_obj.create(cr, uid, {
 
329
                    'location_id': loc_id,
 
330
                    'prodlot_id': False,
 
331
                    'product_id': prod_id,
 
332
                    'quantity': product_obj.browse(cr, uid, prod_id, context=c).qty_available,
 
333
                })
 
334
 
301
335
 
302
336
patch_scripts()
303
337