Skip to content

Commit

Permalink
[MIG] stock_mts_mto_mrp_rule: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
arantxa-s73 committed Jan 22, 2025
1 parent d2781fa commit 8705fdf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion stock_mts_mto_mrp_rule/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Stock MTS+MTO MRP Rule",
"summary": "Stock MTS+MTO MRP Rule",
"version": "14.0.1.0.1",
"version": "17.0.1.0.0",
"category": "Warehouse",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"author": "Cetmix, Odoo Community Association (OCA)",
Expand Down
12 changes: 5 additions & 7 deletions stock_mts_mto_mrp_rule/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ class StockMove(models.Model):
_inherit = "stock.move"

def _prepare_move_split_vals(self, qty):
vals = super(StockMove, self)._prepare_move_split_vals(qty)
vals = super()._prepare_move_split_vals(qty)
if self._context.get("changed_purchase_method"):
vals.update(procure_method="make_to_order")
return vals

def _split(self, qty, restrict_partner_id=False):
new_move_vals = super(StockMove, self)._split(
qty, restrict_partner_id=restrict_partner_id
)
new_move_vals = super()._split(qty, restrict_partner_id=restrict_partner_id)
if self._context.get("changed_purchase_method"):
self.write({"procure_method": "make_to_stock"})
return new_move_vals
Expand All @@ -27,14 +25,14 @@ def _adjust_procure_method(self):
product_id = move.product_id
domain = [
("location_src_id", "=", move.location_id.id),
("location_id", "=", move.location_dest_id.id),
("location_dest_id", "=", move.location_dest_id.id),
("action", "!=", "push"),
]
rules = self.env["procurement.group"]._search_rule(
False, product_id, move.warehouse_id, domain
False, move.product_packaging_id, product_id, move.warehouse_id, domain
)
if not rules or rules and rules.action != "split_procurement":
super(StockMove, move)._adjust_procure_method()
return super(StockMove, move)._adjust_procure_method()
else:
needed_qty = rules.get_mto_qty_to_order(
product_id, move.product_qty, move.product_uom, {}
Expand Down
10 changes: 5 additions & 5 deletions stock_mts_mto_mrp_rule/tests/common.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from odoo.tests import SavepointCase
from odoo.tests.common import TransactionCase


class TestCommon(SavepointCase):
class TestCommon(TransactionCase):
@classmethod
def setUpClass(cls):
super(TestCommon, cls).setUpClass()
super().setUpClass()

Product = cls.env["product.product"]
ProcurementGroup = cls.env["procurement.group"]
StockLocationRoute = cls.env["stock.location.route"]
StockLocationRoute = cls.env["stock.route"]
StockRule = cls.env["stock.rule"]
StockQuant = cls.env["stock.quant"]

Expand Down Expand Up @@ -41,7 +41,7 @@ def setUpClass(cls):
cls.dummy_rule = StockRule.create(
{
"name": "dummy rule",
"location_id": location_stock_id,
"location_dest_id": location_stock_id,
"location_src_id": cls.env.ref("stock.stock_location_suppliers").id,
"action": "pull",
"warehouse_id": cls.warehouse.id,
Expand Down

0 comments on commit 8705fdf

Please sign in to comment.