diff --git a/account_move_adyen_import/static/description/index.html b/account_move_adyen_import/static/description/index.html index e1dee74c..6f4271f1 100644 --- a/account_move_adyen_import/static/description/index.html +++ b/account_move_adyen_import/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z 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. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* 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 } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { diff --git a/account_stock_situation/models/company.py b/account_stock_situation/models/company.py index 30c86c2c..3b83e9c5 100644 --- a/account_stock_situation/models/company.py +++ b/account_stock_situation/models/company.py @@ -76,21 +76,53 @@ def _get_stock_valuation_another(self): # de nombres de produits que d'entrepots dans l'excel product_qties = self.env["stock.quant"].read_group( [("location_id", "child_of", location_ids)], - ["product_id", "quantity"], - ["product_id"], + ["product_id", "warehouse_id", "quantity"], + ["product_id", "warehouse_id"], + lazy=False, ) - product_ids = [x["product_id"][0] for x in product_qties] + + product_ids = list({x["product_id"][0] for x in product_qties}) + products = self.env["product.product"].browse(product_ids) prices = { x: x.variant_seller_ids and x.variant_seller_ids[0] or 0 for x in products } vals = defaultdict(list) - for prd_q in product_qties: - product = products.filtered(lambda s: s.id == prd_q["product_id"][0]) + + product_dict = {} + for product in product_qties: + if not product["product_id"][0] in product_dict: + product_dict[product["product_id"][0]] = [ + product["warehouse_id"][0], + product["quantity"], + ] + else: + product_dict[product["product_id"][0]] += [ + product["warehouse_id"][0], + product["quantity"], + ] + + for product_id, warehouse_quantities in product_dict.items(): + product = products.filtered(lambda s: s.id == product_id) + vals["lien"].append( + f"{base_url}/web#id={product_id}&cids={self.id}&action=" + f"{self.env.ref('product.product_normal_action_sell').id}&model=" + "product.product&view_type=form" + ) vals["code"].append(product.default_code) vals["designation"].append(product.name) - # TODO mettre une colonne qté par entrepot (x colonnes) - vals["qté"].append(round(prd_q["quantity"])) + for i in range(0, len(warehouse_quantities), 2): + warehouse_id = warehouse_quantities[i] + quantity = warehouse_quantities[i + 1] + warehouse_id = self.env["stock.warehouse"].browse(warehouse_id) + vals[f"qté_{warehouse_id.name}"].append(round(quantity)) + if len(warehouse_quantities) / 2 < len(self.valued_warehouse_ids): + warehouse_without_qty = self.valued_warehouse_ids.filtered( + lambda r: r.id != warehouse_quantities[0] + ) + for warehouse in warehouse_without_qty: + vals[f"qté_{warehouse.name}"].append(0) + # TODO quand la valeur est < cost_vs_purchase_threshold % de ce seuil # mettre une colonne 'check' à la valeur 1 vals["valeur"].append( @@ -99,15 +131,9 @@ def _get_stock_valuation_another(self): product.standard_price, prices[product] and prices[product].price or 0 * coef / 100, ) - * prd_q["quantity"] + * product["quantity"] ) ) - # TODO mettre l'url en first column - vals["lien"].append( - f"{base_url}/web#id={prd_q['product_id'][0]}&cids={self.id}&action=" - f"{self.env.ref('product.product_normal_action_sell').id}&model=" - "product.product&view_type=form" - ) df = pl.from_dict(vals) mfile = io.BytesIO() df.write_excel(workbook=mfile) diff --git a/account_stock_situation/static/description/index.html b/account_stock_situation/static/description/index.html index fb34b1c6..b5426d63 100644 --- a/account_stock_situation/static/description/index.html +++ b/account_stock_situation/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z 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. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* 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 } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle {