Skip to content

Commit

Permalink
FIX aac_stk_situation: in _get_stock_valuation()
Browse files Browse the repository at this point in the history
  • Loading branch information
bealdav committed Aug 19, 2024
1 parent 66a2cfc commit aa0da11
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
7 changes: 3 additions & 4 deletions account_move_adyen_import/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
: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.
Expand Down Expand Up @@ -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 }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down
12 changes: 5 additions & 7 deletions account_stock_situation/models/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand All @@ -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]
Expand All @@ -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)
Expand All @@ -132,4 +130,4 @@ def _get_stock_valuation(self):
"datas": base64.b64encode(mfile.getvalue()),
}
)
return sum(vals["valeur"]), attach
return sum(vals["value"]), attach
7 changes: 3 additions & 4 deletions account_stock_situation/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
: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.
Expand Down Expand Up @@ -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 }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down

0 comments on commit aa0da11

Please sign in to comment.