From c60bc3432ff6138230c668b21941aaef674f2ae7 Mon Sep 17 00:00:00 2001 From: wilson gomez Date: Mon, 7 Feb 2022 17:48:18 -0500 Subject: [PATCH] minor fix --- stock.py | 29 +++++++++++++++++----------- view/warehouse_kardex_start_form.xml | 3 +-- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/stock.py b/stock.py index 8a4310a..b5baf53 100644 --- a/stock.py +++ b/stock.py @@ -656,7 +656,7 @@ class WarehouseKardexStockStart(ModelView): 'Warehouse Kardex Stock Start' __name__ = 'stock_co.warehouse_kardex_stock.start' company = fields.Many2One('company.company', 'Company', required=True) - location = fields.Many2One('stock.location', "Location", + locations = fields.Many2Many('stock.location', None, None, "Location", domain=[ ('type', 'in', ['warehouse']), ('active', '=', True) @@ -688,10 +688,11 @@ class WarehouseKardexStock(Wizard): def do_print_(self, action): data = { 'company': self.start.company.id, - 'location': self.start.location.id, + # 'location': self.start.location.id, 'from_date': self.start.from_date, 'to_date': self.start.to_date, 'categories': [l.id for l in self.start.categories], + 'locations': [l.id for l in self.start.locations], } return action, data @@ -707,11 +708,11 @@ class WarehouseKardexReport(Report): Company = pool.get('company.company') Product = pool.get('product.product') Location = pool.get('stock.location') - warehouse = Location(data['location']) + warehouses = Location.browse(data['locations']) # StockMove = pool.get('stock.move') - id_location = warehouse.storage_location.id - input_location = warehouse.input_location.id - output_location = warehouse.output_location.id + id_locations = [w.storage_location.id for w in warehouses if w.storage_location] + # input_location = warehouse.input_location.id + # output_location = warehouse.output_location.id dom_products = [ ('active', '=', True), ('template.active', '=', True), @@ -729,11 +730,11 @@ class WarehouseKardexReport(Report): stock_context_start = { 'stock_date_end': (data['from_date'] - timedelta(1)), - 'locations': [id_location], + 'locations': id_locations, } stock_context_end = { 'stock_date_end': data['to_date'], - 'locations': [id_location], + 'locations': id_locations, } products = {} @@ -755,9 +756,11 @@ class WarehouseKardexReport(Report): # 'output': f'and from_location = {id_location} and to_location != {output_location}', # 'output_dif': f'and from_location = {output_location} and to_location = {id_location}' # } + tup_locations = str(tuple(id_locations)).replace(',', '') if len( + id_locations) == 1 else str(tuple(id_locations)) type = { - 'input': f'and to_location = {id_location}', - 'output': f'and from_location = {id_location}', + 'input': f'and to_location in {tup_locations}', + 'output': f'and from_location in {tup_locations}', } # where product in {tuple(products)} @@ -791,8 +794,12 @@ class WarehouseKardexReport(Report): # report_context['products_in'] = moves['input'] # report_context['products_start'] = products_start # report_context['products_end'] = products_end + wh_name = '' + for l in warehouses: + wh_name += (l.name + ' ,') + report_context['products'] = products.values() - report_context['warehouse'] = warehouse.name + report_context['warehouse'] = wh_name report_context['company'] = Company(data['company']) return report_context diff --git a/view/warehouse_kardex_start_form.xml b/view/warehouse_kardex_start_form.xml index 15ff5ec..47a5380 100644 --- a/view/warehouse_kardex_start_form.xml +++ b/view/warehouse_kardex_start_form.xml @@ -4,11 +4,10 @@ this repository contains the full copyright notices and license terms. -->