From aa0da11dae5a3f7290730e63c9fdd5547cdbaf9d Mon Sep 17 00:00:00 2001 From: David Beal Date: Mon, 19 Aug 2024 16:12:59 +0200 Subject: [PATCH] FIX aac_stk_situation: in _get_stock_valuation() --- .../static/description/index.html | 7 +++---- account_stock_situation/models/company.py | 12 +++++------- .../static/description/index.html | 7 +++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/account_move_adyen_import/static/description/index.html b/account_move_adyen_import/static/description/index.html index 6f4271f1d..e1dee74c4 100644 --- a/account_move_adyen_import/static/description/index.html +++ b/account_move_adyen_import/static/description/index.html @@ -8,11 +8,10 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ +:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. -Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +274,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: gray; } /* line numbers */ +pre.code .ln { color: grey; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +300,7 @@ span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle { diff --git a/account_stock_situation/models/company.py b/account_stock_situation/models/company.py index af018c3ae..e19db5089 100644 --- a/account_stock_situation/models/company.py +++ b/account_stock_situation/models/company.py @@ -71,13 +71,11 @@ def _get_stock_valuation(self): if tools.config.get("running_env") == "dev": base_url = "http://anothercorp.localhost/" location_ids = [x.lot_stock_id.id for x in self.valued_warehouse_ids] - stock_quant_ids = self.env["stock.quant"].search( [("location_id", "child_of", location_ids)], ) products = self.env["product.product"].browse(stock_quant_ids.product_id.ids) vals = defaultdict(list) - product_dict = {} for stock_quant in stock_quant_ids: if stock_quant.product_id.id not in product_dict: @@ -86,14 +84,16 @@ def _get_stock_valuation(self): stock_quant.quantity, ] else: - if stock_quant.warehouse_id in product_dict[stock_quant.product_id.id]: + if ( + stock_quant.warehouse_id + in product_dict.get(stock_quant.product_id.id)[0] + ): product_dict[stock_quant.product_id.id][1] += stock_quant.quantity else: product_dict[stock_quant.product_id.id] += [ stock_quant.warehouse_id, stock_quant.quantity, ] - for product_id, warehouse_quantities in product_dict.items(): product = products.filtered(lambda s: s.id == product_id) vals["link"].append( @@ -103,7 +103,6 @@ def _get_stock_valuation(self): ) vals["code"].append(product.default_code) vals["designation"].append(product.name) - for i in range(0, len(warehouse_quantities), 2): warehouse_id = warehouse_quantities[i] quantity = warehouse_quantities[i + 1] @@ -120,7 +119,6 @@ def _get_stock_valuation(self): vals[f"qty_{warehouse.code}"].append(0) vals["value"].append(round(product.standard_price)) - df = pl.from_dict(vals) mfile = io.BytesIO() df.write_excel(workbook=mfile) @@ -132,4 +130,4 @@ def _get_stock_valuation(self): "datas": base64.b64encode(mfile.getvalue()), } ) - return sum(vals["valeur"]), attach + return sum(vals["value"]), attach diff --git a/account_stock_situation/static/description/index.html b/account_stock_situation/static/description/index.html index 1b44c16e4..2bb7a2bf5 100644 --- a/account_stock_situation/static/description/index.html +++ b/account_stock_situation/static/description/index.html @@ -8,11 +8,10 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ +:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. -Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +274,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: gray; } /* line numbers */ +pre.code .ln { color: grey; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +300,7 @@ span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle {