Skip to content

Commit

Permalink
[18.0][MIG] stock_available: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisBrose committed Dec 10, 2024
1 parent a23d367 commit 1733291
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion stock_available/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Stock available to promise",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Numérigraphe, Sodexis, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-availability",
"development_status": "Production/Stable",
Expand Down
2 changes: 1 addition & 1 deletion stock_available/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _compute_available_quantities(self):
)

def _get_search_immediately_usable_qty_domain(self):
return [("type", "=", "product")]
return [("type", "=", "consu"), ("is_storable", "=", True)]

@api.model
def _search_immediately_usable_qty(self, operator, value):
Expand Down
14 changes: 9 additions & 5 deletions stock_available/tests/test_stock_available.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,23 @@ def test01_stock_levels(self):
{
"name": "product A",
"standard_price": 1,
"type": "product",
"type": "consu",
"uom_id": uom_unit.id,
"default_code": "A",
"product_tmpl_id": templateAB.id,
"is_storable": True,
}
)

productB = productObj.create(
{
"name": "product B",
"standard_price": 1,
"type": "product",
"type": "consu",
"uom_id": uom_unit.id,
"default_code": "B",
"product_tmpl_id": templateAB.id,
"is_storable": True,
}
)

Expand Down Expand Up @@ -137,7 +139,7 @@ def test_available_stock_multiple_location(self):
{
"name": "product A",
"standard_price": 1,
"type": "product",
"type": "consu",
"uom_id": uom_unit.id,
"default_code": "A",
}
Expand All @@ -159,8 +161,10 @@ def test_available_stock_multiple_location(self):
)
stockMoveIn._action_confirm()
self.assertEqual(
productA.with_context(location=shelf1.id).immediately_usable_qty, 2.0
productA.with_context(location=shelf1.id).immediately_usable_qty,
2.0,
)
self.assertEqual(
productA.with_context(location=shelf2.id).immediately_usable_qty, 0.0
productA.with_context(location=shelf2.id).immediately_usable_qty,
0.0,
)
10 changes: 5 additions & 5 deletions stock_available/views/product_product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record model="ir.ui.view" id="product_normal_form_view">
<field name="name">Quantity available to promise (variant tree)</field>
<field name="name">Quantity available to promise (variant form)</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="stock.product_form_view_procurement_button" />
<field name="arch" type="xml">
Expand All @@ -15,7 +15,7 @@
<button
type="object"
name="action_open_quants"
invisible="type not in ('product', 'consu')"
invisible="type != 'consu'"
class="oe_stat_button"
icon="fa-building-o"
>
Expand All @@ -35,7 +35,7 @@
<button
type="object"
name="action_open_quants"
invisible="type not in ('product', 'consu')"
invisible="type != 'consu'"
class="oe_stat_button"
icon="fa-building-o"
>
Expand All @@ -55,8 +55,8 @@
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_stock_available_product_tree">
<field name="name">Quantity available to promise (variant tree)</field>
<record model="ir.ui.view" id="view_stock_available_product_list">
<field name="name">Quantity available to promise (variant list)</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="stock.view_stock_product_tree" />
<field name="arch" type="xml">
Expand Down
14 changes: 8 additions & 6 deletions stock_available/views/product_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<button
type="object"
name="action_open_quants"
invisible="type not in ('product', 'consu')"
invisible="type != 'consu'"
class="oe_stat_button"
icon="fa-building-o"
>
Expand All @@ -38,7 +38,7 @@
<button
type="object"
name="action_open_quants"
invisible="type not in ('product', 'consu')"
invisible="type != 'consu'"
class="oe_stat_button"
icon="fa-building-o"
>
Expand All @@ -58,8 +58,8 @@
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_stock_available_product_template_tree">
<field name="name">Quantity available to promise (tree)</field>
<record model="ir.ui.view" id="view_stock_available_product_template_list">
<field name="name">Quantity available to promise (list)</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.view_stock_product_template_tree" />
<field name="arch" type="xml">
Expand All @@ -76,9 +76,11 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.product_template_kanban_stock_view" />
<field name="arch" type="xml">
<xpath expr="//div[@name='product_lst_price']" position="after">
<xpath expr="//span/field[@name='list_price']" position="after">
<field name="type" invisible="1" />
<field name="is_storable" invisible="1" />
<div
t-if="record.type.raw_value == 'product'"
t-if="record.type.raw_value == 'consu' and record.is_storable.raw_value"
>Available to Promise: <field name="immediately_usable_qty" /> <field
name="uom_id"
/></div>
Expand Down

0 comments on commit 1733291

Please sign in to comment.