From 0d689b1e957b04c8a876f3c7e55515ea8357d19a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 13 May 2022 17:39:32 +0200 Subject: [PATCH] stock_valuation_xlsx: improve multi-company support Other small minor improvements/fixes --- stock_valuation_xlsx/__manifest__.py | 2 +- stock_valuation_xlsx/wizard/stock_valuation_xlsx.py | 10 +++++++--- stock_valuation_xlsx/wizard/stock_variation_xlsx.py | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/stock_valuation_xlsx/__manifest__.py b/stock_valuation_xlsx/__manifest__.py index cc83444..721c46b 100644 --- a/stock_valuation_xlsx/__manifest__.py +++ b/stock_valuation_xlsx/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Stock Valuation XLSX', - 'version': '12.0.1.0.0', + 'version': '12.0.1.0.1', 'category': 'Tools', 'license': 'AGPL-3', 'summary': 'Generate XLSX reports for past or present stock levels', diff --git a/stock_valuation_xlsx/wizard/stock_valuation_xlsx.py b/stock_valuation_xlsx/wizard/stock_valuation_xlsx.py index 3b6892a..d0ed12c 100644 --- a/stock_valuation_xlsx/wizard/stock_valuation_xlsx.py +++ b/stock_valuation_xlsx/wizard/stock_valuation_xlsx.py @@ -157,7 +157,7 @@ class StockValuationXlsx(models.TransientModel): self, company_id, in_stock_product_ids, standard_price_past_date=False): self.ensure_one() logger.debug('Start compute_product_data') - ppo = self.env['product.product'] + ppo = self.env['product.product'].with_context(force_company=company_id) ppho = self.env['product.price.history'] fields_list = self._prepare_product_fields() if not standard_price_past_date: @@ -396,9 +396,13 @@ class StockValuationXlsx(models.TransientModel): elif self.source == 'inventory': past_date = self.inventory_id.date data, in_stock_products = self.compute_data_from_inventory(product_ids, prec_qty) - standard_price_past_date = past_date - if not (self.source == 'stock' and self.stock_date_type == 'present') and self.standard_price_date == 'present': + if self.source == 'stock' and self.stock_date_type == 'present': standard_price_past_date = False + else: # field standard_price_date is shown on screen + if self.standard_price_date == 'present': + standard_price_past_date = False + else: + standard_price_past_date = past_date depreciation_rules = [] if apply_depreciation: depreciation_rules = self._prepare_expiry_depreciation_rules(company_id, past_date) diff --git a/stock_valuation_xlsx/wizard/stock_variation_xlsx.py b/stock_valuation_xlsx/wizard/stock_variation_xlsx.py index 0215f04..ae40ccc 100644 --- a/stock_valuation_xlsx/wizard/stock_variation_xlsx.py +++ b/stock_valuation_xlsx/wizard/stock_variation_xlsx.py @@ -122,7 +122,7 @@ class StockVariationXlsx(models.TransientModel): standard_price_start_date=False, standard_price_end_date=False): self.ensure_one() logger.debug('Start compute_product_data') - ppo = self.env['product.product'] + ppo = self.env['product.product'].with_context(force_company=company_id) ppho = self.env['product.price.history'] fields_list = self._prepare_product_fields() if not standard_price_start_date or not standard_price_end_date: @@ -278,7 +278,7 @@ class StockVariationXlsx(models.TransientModel): standard_price_start_date = standard_price_end_date = False if self.standard_price_start_date_type == 'start': standard_price_start_date = self.start_date - if self.standard_price_end_date_type == 'end': + if self.standard_price_end_date_type == 'end' and self.end_date_type == 'past': standard_price_end_date = self.end_date product_id2data = self.compute_product_data(