stock_valuation_xlsx: improve multi-company support

Other small minor improvements/fixes
This commit is contained in:
Alexis de Lattre
2022-05-13 17:35:50 +02:00
parent fdf204b3aa
commit 00df54ee37
3 changed files with 10 additions and 6 deletions

View File

@@ -6,7 +6,7 @@
{ {
'name': 'Stock Valuation XLSX', 'name': 'Stock Valuation XLSX',
'version': '10.0.1.0.0', 'version': '10.0.1.0.1',
'category': 'Tools', 'category': 'Tools',
'license': 'AGPL-3', 'license': 'AGPL-3',
'summary': 'Generate XLSX reports for past or present stock levels', 'summary': 'Generate XLSX reports for past or present stock levels',

View File

@@ -153,7 +153,7 @@ class StockValuationXlsx(models.TransientModel):
self, company_id, in_stock_product_ids, standard_price_past_date=False): self, company_id, in_stock_product_ids, standard_price_past_date=False):
self.ensure_one() self.ensure_one()
logger.debug('Start compute_product_data') 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'] ppho = self.env['product.price.history']
fields_list = self._prepare_product_fields() fields_list = self._prepare_product_fields()
if not standard_price_past_date: if not standard_price_past_date:
@@ -392,9 +392,13 @@ class StockValuationXlsx(models.TransientModel):
elif self.source == 'inventory': elif self.source == 'inventory':
past_date = self.inventory_id.date past_date = self.inventory_id.date
data, in_stock_products = self.compute_data_from_inventory(product_ids, prec_qty) data, in_stock_products = self.compute_data_from_inventory(product_ids, prec_qty)
standard_price_past_date = past_date if self.source == 'stock' and self.stock_date_type == 'present':
if not (self.source == 'stock' and self.stock_date_type == 'present') and self.standard_price_date == 'present':
standard_price_past_date = False 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 = [] depreciation_rules = []
if apply_depreciation: if apply_depreciation:
depreciation_rules = self._prepare_expiry_depreciation_rules(company_id, past_date) depreciation_rules = self._prepare_expiry_depreciation_rules(company_id, past_date)

View File

@@ -121,7 +121,7 @@ class StockVariationXlsx(models.TransientModel):
self, company_id, filter_product_ids, standard_price_start_date=False, standard_price_end_date=False): self, company_id, filter_product_ids, standard_price_start_date=False, standard_price_end_date=False):
self.ensure_one() self.ensure_one()
logger.debug('Start compute_product_data') 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'] ppho = self.env['product.price.history']
fields_list = self._prepare_product_fields() fields_list = self._prepare_product_fields()
if not standard_price_start_date or not standard_price_end_date: if not standard_price_start_date or not standard_price_end_date:
@@ -277,7 +277,7 @@ class StockVariationXlsx(models.TransientModel):
standard_price_start_date = standard_price_end_date = False standard_price_start_date = standard_price_end_date = False
if self.standard_price_start_date_type == 'start': if self.standard_price_start_date_type == 'start':
standard_price_start_date = self.start_date 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 standard_price_end_date = self.end_date
product_id2data = self.compute_product_data( product_id2data = self.compute_product_data(