Skip to content

Commit

Permalink
[MIG] stock_account_valuation_report: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanRijnhart committed Feb 5, 2025
1 parent dbd26ca commit a552655
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 132 deletions.
1 change: 1 addition & 0 deletions stock_account_valuation_report/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Contributors

- Jordi Ballester Alomar <[email protected]>
- Aaron Henriquez <[email protected]>
- Stefan Rijnhart <[email protected]>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion stock_account_valuation_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Stock Account Valuation Report",
"version": "16.0.1.1.0",
"version": "18.0.1.0.0",
"summary": "Improves logic of the Inventory Valuation Report",
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-reporting",
Expand Down
58 changes: 13 additions & 45 deletions stock_account_valuation_report/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,11 @@ class ProductProduct(models.Model):
compute="_compute_inventory_value",
search="_search_qty_discrepancy",
)
valuation = fields.Selection(
related="product_tmpl_id.valuation", search="_search_valuation"
)

@api.model
def _search_valuation(self, operator, value):
domain = [
"|",
("categ_id.property_valuation", operator, value),
("property_valuation", operator, value),
]
products = self.env["product.product"].search(domain)
if value:
return [("id", "in", products.ids)]
else:
return [("id", "not in", products.ids)]

@api.model
def _search_qty_discrepancy(self, operator, value):
products = self.with_context(active_test=False).search(

Check warning on line 36 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L36

Added line #L36 was not covered by tests
[
("type", "=", "product"),
]
[("is_storable", "=", True)],
)
dp = self.env["decimal.precision"].precision_get("Product Price")
products_with_discrepancy = products.filtered(

Check warning on line 40 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L39-L40

Added lines #L39 - L40 were not covered by tests
Expand All @@ -66,9 +48,7 @@ def _search_qty_discrepancy(self, operator, value):
@api.model
def _search_valuation_discrepancy(self, operator, value):
products = self.with_context(active_test=False).search(

Check warning on line 50 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L50

Added line #L50 was not covered by tests
[
("type", "=", "product"),
]
[("is_storable", "=", True)],
)
dp = self.env.ref("product.decimal_discount").precision_get("Discount")
products_with_discrepancy = products.filtered(

Check warning on line 54 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L53-L54

Added lines #L53 - L54 were not covered by tests
Expand All @@ -80,7 +60,7 @@ def _search_valuation_discrepancy(self, operator, value):
return [("id", "in", products_with_discrepancy.ids)]

Check warning on line 60 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L60

Added line #L60 was not covered by tests

def _compute_inventory_value(self):
self.env["account.move.line"].check_access_rights("read")
self.env["account.move.line"].check_access("read")
to_date = self.env.context.get("at_date", False)
accounting_values = {}
layer_values = {}
Expand Down Expand Up @@ -180,13 +160,13 @@ def _compute_inventory_value(self):

def action_view_amls(self):
self.ensure_one()
tree_view_ref = self.env.ref("account.view_move_line_tree")
list_view_ref = self.env.ref("account.view_move_line_tree")
form_view_ref = self.env.ref("account.view_move_line_form")
action = {

Check warning on line 165 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L162-L165

Added lines #L162 - L165 were not covered by tests
"name": _("Accounting Valuation at date"),
"type": "ir.actions.act_window",
"view_type": "form",
"view_mode": "tree,form",
"view_mode": "list,form",
"context": self.env.context,
"res_model": "account.move.line",
"domain": [
Expand All @@ -196,28 +176,16 @@ def action_view_amls(self):
self.stock_fifo_real_time_aml_ids.ids,
)
],
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
"views": [(list_view_ref.id, "list"), (form_view_ref.id, "form")],
}
return action

Check warning on line 181 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L181

Added line #L181 was not covered by tests

def action_view_valuation_layers(self):
self.ensure_one()
tree_view_ref = self.env.ref("stock_account.stock_valuation_layer_tree")
form_view_ref = self.env.ref("stock_account.stock_valuation_layer_form")
action = {
"name": _("Inventory Valuation"),
"type": "ir.actions.act_window",
"view_type": "form",
"view_mode": "tree,form",
"context": self.env.context,
"res_model": "stock.valuation.layer",
"domain": [
(
"id",
"in",
self.stock_valuation_layer_ids.ids,
)
],
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
}
action = self.env["ir.actions.actions"]._for_xml_id(
"stock_account.stock_valuation_layer_report_action"
)
action["domain"] = [
("id", "in", self.stock_valuation_layer_ids.ids),
]
action["context"] = {}
return action
1 change: 1 addition & 0 deletions stock_account_valuation_report/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Jordi Ballester Alomar \<<[email protected]>\>
- Aaron Henriquez \<<[email protected]>\>
- Stefan Rijnhart \<<[email protected]>\>
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li>Aaron Henriquez &lt;<a class="reference external" href="mailto:ahenriquez&#64;forgeflow.com">ahenriquez&#64;forgeflow.com</a>&gt;</li>
<li>Stefan Rijnhart &lt;<a class="reference external" href="mailto:stefan&#64;opener.amsterdam">stefan&#64;opener.amsterdam</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Loading

0 comments on commit a552655

Please sign in to comment.