Skip to content

Commit

Permalink
[17.0][MIG] stock_mts_mto_rule: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
milinsoft committed Feb 5, 2024
1 parent 2ccb8dc commit f3a11ac
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 18 deletions.
3 changes: 2 additions & 1 deletion stock_mts_mto_rule/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Stock MTS+MTO Rule
==================

..
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
Expand Down Expand Up @@ -104,6 +104,7 @@ Contributors
- Florian da Costa <[email protected]>
- Jared Kipe <[email protected]>
- Alan Ramos <[email protected]>
- Aleksander Milinkevich <[email protected]>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion stock_mts_mto_rule/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Stock MTS+MTO Rule",
"summary": "Add a MTS+MTO route",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"development_status": "Mature",
"category": "Warehouse",
"website": "https://github.com/OCA/stock-logistics-warehouse",
Expand Down
10 changes: 5 additions & 5 deletions stock_mts_mto_rule/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class StockWarehouse(models.Model):
mts_mto_rule_id = fields.Many2one("stock.rule", "MTO+MTS rule", check_company=True)

def _get_all_routes(self):
routes = super(StockWarehouse, self)._get_all_routes()
routes = super()._get_all_routes()
routes |= self.mapped("mts_mto_rule_id.route_id")
return routes

def _update_name_and_code(self, new_name=False, new_code=False):
res = super(StockWarehouse, self)._update_name_and_code(new_name, new_code)
res = super()._update_name_and_code(new_name, new_code)
if not new_name:
return res
for warehouse in self.filtered("mts_mto_rule_id"):
Expand All @@ -36,15 +36,15 @@ def _update_name_and_code(self, new_name=False, new_code=False):
def _get_route_name(self, route_type):
if route_type == "mts_mto":
return _("MTS+MTO")
return super(StockWarehouse, self)._get_route_name(route_type)
return super()._get_route_name(route_type)

def _get_global_route_rules_values(self):
rule = self.get_rules_dict()[self.id][self.delivery_steps]
rule = [r for r in rule if r.from_loc == self.lot_stock_id][0]
location_id = rule.from_loc
location_dest_id = rule.dest_loc
picking_type_id = rule.picking_type
res = super(StockWarehouse, self)._get_global_route_rules_values()
res = super()._get_global_route_rules_values()
res.update(
{
"mts_mto_rule_id": {
Expand Down Expand Up @@ -75,7 +75,7 @@ def _get_global_route_rules_values(self):
return res

def _create_or_update_global_routes_rules(self):
res = super(StockWarehouse, self)._create_or_update_global_routes_rules()
res = super()._create_or_update_global_routes_rules()

if (
self.mto_mts_management
Expand Down
1 change: 1 addition & 0 deletions stock_mts_mto_rule/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Florian da Costa \<<[email protected]>\>
- Jared Kipe \<<[email protected]>\>
- Alan Ramos \<<[email protected]>\>
- Aleksander Milinkevich \<<[email protected]>\>
1 change: 1 addition & 0 deletions stock_mts_mto_rule/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<li>Florian da Costa &lt;<a class="reference external" href="mailto:florian.dacosta&#64;akretion.com">florian.dacosta&#64;akretion.com</a>&gt;</li>
<li>Jared Kipe &lt;<a class="reference external" href="mailto:jared&#64;hibou.io">jared&#64;hibou.io</a>&gt;</li>
<li>Alan Ramos &lt;<a class="reference external" href="mailto:alan.ramos&#64;jarsa.com.mx">alan.ramos&#64;jarsa.com.mx</a>&gt;</li>
<li>Aleksander Milinkevich &lt;<a class="reference external" href="mailto:aleksander&#64;versada.eu">aleksander&#64;versada.eu</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
14 changes: 7 additions & 7 deletions stock_mts_mto_rule/tests/test_mto_mts_route.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import exceptions
from odoo import Command, exceptions
from odoo.tests.common import TransactionCase


Expand All @@ -18,7 +18,7 @@ def _create_quant(self, qty):
def test_standard_mto_route(self):
mto_route = self.env.ref("stock.route_warehouse0_mto")
mto_route.active = True
self.product.route_ids = [(6, 0, [mto_route.id])]
self.product.route_ids = [Command.set(mto_route.ids)]
self.env["procurement.group"].run(
[
self.group.Procurement(
Expand Down Expand Up @@ -56,7 +56,7 @@ def test_standard_mts_route(self):

def test_mts_mto_route_split(self):
mto_mts_route = self.env.ref("stock_mts_mto_rule.route_mto_mts")
self.product.route_ids = [(6, 0, [mto_mts_route.id])]
self.product.route_ids = [Command.set(mto_mts_route.ids)]
self._create_quant(1.0)
self.env["procurement.group"].run(
[
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_mts_mto_route_split(self):

def test_mts_mto_route_mto_only(self):
mto_mts_route = self.env.ref("stock_mts_mto_rule.route_mto_mts")
self.product.route_ids = [(6, 0, [mto_mts_route.id])]
self.product.route_ids = [Command.set(mto_mts_route.ids)]
self.env["procurement.group"].run(
[
self.group.Procurement(
Expand All @@ -123,7 +123,7 @@ def test_mts_mto_route_mto_only(self):

def test_mts_mto_route_mts_only(self):
mto_mts_route = self.env.ref("stock_mts_mto_rule.route_mto_mts")
self.product.route_ids = [(6, 0, [mto_mts_route.id])]
self.product.route_ids = [Command.set(mto_mts_route.ids)]
self._create_quant(3.0)
self.env["procurement.group"].run(
[
Expand Down Expand Up @@ -214,7 +214,7 @@ def test_rename_warehouse(self):
self.assertEqual(new_rule_name, self.warehouse.mts_mto_rule_id.name)

def setUp(self):
super(TestMtoMtsRoute, self).setUp()
super().setUp()
self.move_obj = self.env["stock.move"]
self.warehouse = self.env.ref("stock.warehouse0")
self.uom = self.env["uom.uom"].browse(1)
Expand Down Expand Up @@ -244,4 +244,4 @@ def setUp(self):
"route_id": self.dummy_route.id,
}
self.dummy_rule = self.env["stock.rule"].create(rule_vals)
self.warehouse.write({"route_ids": [(4, self.dummy_route.id)]})
self.warehouse.write({"route_ids": [Command.link(self.dummy_route.id)]})
8 changes: 4 additions & 4 deletions stock_mts_mto_rule/view/pull_rule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<field
name="mts_rule_id"
groups="stock.group_adv_location"
attrs="{'invisible': [('action', '!=', 'split_procurement')]}"
invisible="action != 'split_procurement'"
/>
<field
name="mto_rule_id"
groups="stock.group_adv_location"
attrs="{'invisible': [('action', '!=', 'split_procurement')]}"
invisible="action != 'split_procurement'"
/>
</field>
</field>
Expand All @@ -28,12 +28,12 @@
<field
name="mts_rule_id"
groups="stock.group_adv_location"
attrs="{'invisible': [('action', '!=', 'split_procurement')]}"
invisible="action != 'split_procurement'"
/>
<field
name="mto_rule_id"
groups="stock.group_adv_location"
attrs="{'invisible': [('action', '!=', 'split_procurement')]}"
invisible="action != 'split_procurement'"
/>
</field>
</field>
Expand Down

0 comments on commit f3a11ac

Please sign in to comment.