diff --git a/stock.py b/stock.py index 876eabc..7a20cc9 100644 --- a/stock.py +++ b/stock.py @@ -553,6 +553,7 @@ class WarehouseStockDetailedStart(ModelView): ], depends=['location_storage']) location_storage = fields.One2Many('stock.location', None, 'Locations Storage') to_date = fields.Date('To Date', required=True) + lot = fields.Boolean('Grouping Lot') @staticmethod def default_company(): @@ -589,6 +590,7 @@ class WarehouseStockDetailed(Wizard): 'company': self.start.company.id, 'locations': location_ids, 'to_date': self.start.to_date, + 'lot': self.start.lot, } return action, data @@ -604,6 +606,7 @@ class WarehouseStockDetailedReport(Report): Company = pool.get('company.company') Product = pool.get('product.product') Location = pool.get('stock.location') + LotbyLocation = pool.get('stock.lots_by_locations') if data['locations']: ids_location = data['locations'] locations = Location.browse(ids_location) @@ -644,11 +647,16 @@ class WarehouseStockDetailedReport(Report): stock_context['locations'] = [l.id] with Transaction().set_context(stock_context): prdts = Product.search(dom_products, order=[('code', 'ASC')]) + if data['lot']: + prd_ids = [p.id for p in prdts] + print(prd_ids, 'ids') + prdts = LotbyLocation.search([('product' , 'in', prd_ids)]) for p in prdts: add_({ 'parent_name': l.parent.name if l.parent else '', 'name': l.name, - 'product': p, + 'product': p.product if data['lot'] else p, + 'lot': p if data['lot'] else None, }) products = values diff --git a/view/warehouse_stock_detailed_view_form.xml b/view/warehouse_stock_detailed_view_form.xml index a088453..09e9809 100644 --- a/view/warehouse_stock_detailed_view_form.xml +++ b/view/warehouse_stock_detailed_view_form.xml @@ -6,5 +6,7 @@ this repository contains the full copyright notices and license terms. -->