Skip to content

Commit

Permalink
[MIG] stock_request_mrp: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelZilli authored and nicomacr committed Sep 14, 2022
1 parent 12480b2 commit 719a412
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion stock_request_mrp/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Stock Request MRP",
"summary": "Manufacturing request for stock",
"version": "13.0.1.0.0",
"version": "15.0.1.0.0",
"license": "LGPL-3",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"author": "ForgeFlow, Odoo Community Association (OCA)",
Expand Down
6 changes: 4 additions & 2 deletions stock_request_mrp/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ def action_view_stock_request(self):
action["res_id"] = requests.id
return action

def _get_finished_move_value(
def _get_move_finished_values(
self,
product_id,
product_uom_qty,
product_uom,
operation_id=False,
byproduct_id=False,
cost_share=0,
):
res = super()._get_finished_move_value(
res = super()._get_move_finished_values(
product_id,
product_uom_qty,
product_uom,
operation_id=operation_id,
byproduct_id=byproduct_id,
cost_share=cost_share,
)
if self.stock_request_ids:
res["allocation_ids"] = [
Expand Down
25 changes: 8 additions & 17 deletions stock_request_mrp/tests/test_stock_request_mrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).

from odoo import fields
from odoo.tests import Form, common
from odoo.tests import common


class TestStockRequestMrp(common.TransactionCase):
Expand All @@ -11,7 +11,6 @@ def setUp(self):

# common models
self.stock_request = self.env["stock.request"]
self.produce_wiz = self.env["mrp.product.produce"]

# refs
self.stock_request_user_group = self.env.ref(
Expand Down Expand Up @@ -68,7 +67,7 @@ def _update_qty_in_location(self, location, product, quantity):
def _create_user(self, name, group_ids, company_ids):
return (
self.env["res.users"]
.with_context({"no_reset_password": True})
.with_context(no_reset_password=True)
.create(
{
"name": name,
Expand Down Expand Up @@ -110,15 +109,6 @@ def _create_mrp_bom(self, product_id, raw_materials):

return bom

def _produce(self, mo, qty=0.0):
wiz = Form(
self.produce_wiz.with_context({"active_id": mo.id, "active_ids": [mo.id]})
)
wiz.qty_producing = qty or mo.product_qty
produce_wizard = wiz.save()
produce_wizard.do_produce()
return True

def test_create_request_01(self):
"""Single Stock request with buy rule"""
expected_date = fields.Datetime.now()
Expand Down Expand Up @@ -164,12 +154,13 @@ def test_create_request_01(self):
self.assertEqual(
manufacturing_order.company_id, order.stock_request_ids[0].company_id
)
manufacturing_order.action_confirm()
manufacturing_order.write(
{"qty_producing": manufacturing_order.product_uom_qty}
)
manufacturing_order._set_qty_producing()

self._produce(manufacturing_order, 5.0)
self.assertEqual(order.stock_request_ids.qty_in_progress, 5.0)
self.assertEqual(order.stock_request_ids.qty_done, 0.0)

manufacturing_order.button_mark_done()
manufacturing_order.with_context(skip_immediate=True).button_mark_done()
self.assertEqual(order.stock_request_ids.qty_in_progress, 0.0)
self.assertEqual(order.stock_request_ids.qty_done, 5.0)

Expand Down

0 comments on commit 719a412

Please sign in to comment.