Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def lot_search_v2(pool, transaction, search_data):
- Location = pool.get('stock.location')
- Product = pool.get('product.product')
- Lot = pool.get('stock.lot')
- Date = pool.get('ir.date')
- today = Date.today()
- result = {}
- data = []
- found = False
- result['type'] = 'lot'
- warehouse = Location.get_default_warehouse()
- location_id = warehouse.storage_location.id
- domain = [('number', '=', str(search_data))]
- lots = Lot.search(domain)
- lot_ids = [lot.id for lot in lots]
- product_ids = [lot.product.id for lot in lots]
- with transaction.set_context(forecast=False, stock_date_end=today):
- pbl = Product.products_by_location(
- [location_id], grouping=('product', 'lot'),
- grouping_filter=(product_ids, lot_ids), with_childs=True)
- for key, quantity in pbl.items():
- location_id, product_id, lot_id = key
- product = Product(product_id)
- lot = Lot(lot_id)
- data.append({
- 'product': product.rec_name,
- 'product_id': product_id,
- 'location': Location(location_id).rec_name,
- 'location_id': location_id,
- 'quantity': quantity,
- 'uom': product.default_uom.symbol,
- 'uom_id': product.default_uom.id,
- 'lot': lot.number,
- 'lot_id': lot_id,
- 'id_preciball_po': lot.id_preciball_po,
- })
- result['data'] = data
- result['found'] = found
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement