Skip to content

Commit

Permalink
[MIG] stock_available_unreserved: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nedas Žilinskas committed May 8, 2024
1 parent 46ed844 commit 951b394
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion stock_available_unreserved/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Stock Available Unreserved",
"summary": "Quantity of stock available for immediate use",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"development_status": "Production/Stable",
"maintainers": ["LoisRForgeFlow"],
Expand Down
2 changes: 1 addition & 1 deletion stock_available_unreserved/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _compute_qty_available_not_reserved(self):
def _search_quantity_unreserved(self, operator, value):
if operator not in OPERATORS:
raise UserError(_("Invalid domain operator %s") % operator)

Check warning on line 69 in stock_available_unreserved/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_available_unreserved/models/product_product.py#L69

Added line #L69 was not covered by tests
if not isinstance(value, (float, int)):
if not isinstance(value, float | int):
raise UserError(_("Invalid domain right operand %s") % value)

Check warning on line 71 in stock_available_unreserved/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_available_unreserved/models/product_product.py#L71

Added line #L71 was not covered by tests

ids = []
Expand Down
7 changes: 5 additions & 2 deletions stock_available_unreserved/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import api, fields, models
from odoo import _, api, fields, models


class ProductTemplate(models.Model):
Expand Down Expand Up @@ -32,7 +32,10 @@ def action_open_quants_unreserved(self):
quant_ids = quants.filtered(
lambda x: x.product_id.qty_available_not_res > 0
).ids
result = self.env.ref("stock.group_stock_multi_locations").read()[0]
result = self.env["ir.actions.actions"]._for_xml_id(
"stock.dashboard_open_quants"
)
result["display_name"] = _("Stock On Hand (Unreserved)")
result["domain"] = [("id", "in", quant_ids)]
result["context"] = {
"search_default_locationgroup": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def setUpClass(cls):
"product_id": cls.productA.id,
"product_uom": cls.productA.uom_id.id,
"product_uom_qty": 2,
"quantity_done": 2,
"quantity": 2,
"location_id": cls.supplier_location.id,
"location_dest_id": cls.stock_location.id,
},
Expand All @@ -110,7 +110,7 @@ def setUpClass(cls):
"product_id": cls.productB.id,
"product_uom": cls.productB.uom_id.id,
"product_uom_qty": 3,
"quantity_done": 3,
"quantity": 3,
"location_id": cls.supplier_location.id,
"location_dest_id": cls.stock_location.id,
},
Expand All @@ -123,7 +123,6 @@ def setUpClass(cls):
"picking_type_id": cls.env.ref("stock.picking_type_out").id,
"location_id": cls.stock_location.id,
"location_dest_id": cls.customer_location.id,
"immediate_transfer": False,
"move_ids": [
(
0,
Expand All @@ -142,7 +141,7 @@ def setUpClass(cls):
)

def compare_qty_available_not_res(self, product, value):
product.invalidate_cache()
product.invalidate_recordset()
self.assertEqual(product.qty_available_not_res, value)

def test_01_stock_levels(self):
Expand Down
4 changes: 2 additions & 2 deletions stock_available_unreserved/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<button
type="object"
name="action_open_quants_unreserved"
attrs="{'invisible':[('type', '!=', 'product')]}"
invisible="type != 'product'"
class="oe_stat_button"
icon="fa-building-o"
>
Expand All @@ -82,7 +82,7 @@
name="%(product_open_quants_unreserved)d"
icon="fa-building-o"
type="action"
attrs="{'invisible':[('type', '!=', 'product')]}"
invisible="type != 'product'"
>
<field
name="qty_available_not_res"
Expand Down

0 comments on commit 951b394

Please sign in to comment.