mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[16.0][MIG] account_move_line_mrp_info
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
"name": "Account Move Line Mrp Info",
|
||||
"version": "14.0.1.1.0",
|
||||
"version": "16.0.1.0.0",
|
||||
"author": "ForgeFlow," "Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/manufacture",
|
||||
"category": "Manufacture",
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from odoo.tests import Form
|
||||
|
||||
from odoo.addons.mrp.tests.common import TestMrpCommon
|
||||
|
||||
|
||||
class TestMrpOrder(TestMrpCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
def _check_multiwarehouse_group(*args, **kwargs):
|
||||
pass
|
||||
|
||||
with patch(
|
||||
"odoo.addons.stock.models.stock_warehouse.Warehouse._check_multiwarehouse_group",
|
||||
new=_check_multiwarehouse_group,
|
||||
):
|
||||
super(TestMrpCommon, cls).setUpClass()
|
||||
|
||||
def setUp(self):
|
||||
super(TestMrpOrder, self).setUp()
|
||||
self.stock_location = self.env.ref("stock.stock_location_stock")
|
||||
self.Quant = self.env["stock.quant"].with_context(inventory_mode=True)
|
||||
self.env.ref("base.group_user").write(
|
||||
{"implied_ids": [(4, self.env.ref("stock.group_production_lot").id)]}
|
||||
)
|
||||
@@ -22,8 +36,7 @@ class TestMrpOrder(TestMrpCommon):
|
||||
{
|
||||
"name": "Test Account",
|
||||
"code": "TestAccount1",
|
||||
"user_type_id": self.env.ref("account.data_account_type_payable").id,
|
||||
"reconcile": True,
|
||||
"account_type": "liability_payable",
|
||||
}
|
||||
)
|
||||
location = self.env["stock.location"].search([("usage", "=", "production")])
|
||||
@@ -42,8 +55,20 @@ class TestMrpOrder(TestMrpCommon):
|
||||
p2.standard_price = 5
|
||||
p_final.categ_id = pc.id
|
||||
|
||||
self.env["stock.quant"]._update_available_quantity(p1, self.stock_location, 100)
|
||||
self.env["stock.quant"]._update_available_quantity(p2, self.stock_location, 5)
|
||||
self.Quant.create(
|
||||
{
|
||||
"product_id": p1.id,
|
||||
"location_id": self.stock_location.id,
|
||||
"inventory_quantity": 100,
|
||||
}
|
||||
).action_apply_inventory()
|
||||
self.Quant.create(
|
||||
{
|
||||
"product_id": p2.id,
|
||||
"location_id": self.stock_location.id,
|
||||
"inventory_quantity": 5,
|
||||
}
|
||||
).action_apply_inventory()
|
||||
mo.action_assign()
|
||||
|
||||
mo_form = Form(mo)
|
||||
@@ -51,7 +76,15 @@ class TestMrpOrder(TestMrpCommon):
|
||||
mo = mo_form.save()
|
||||
mo.button_mark_done()
|
||||
|
||||
journal_items_after_production = self.env["account.move.line"].search([]).ids
|
||||
journal_items_after_production = (
|
||||
self.env["account.move.line"]
|
||||
.search(
|
||||
[
|
||||
("mrp_production_id", "=", mo.id),
|
||||
]
|
||||
)
|
||||
.ids
|
||||
)
|
||||
|
||||
result = mo.view_journal_items()
|
||||
domain = result["domain"]
|
||||
@@ -79,9 +112,21 @@ class TestMrpOrder(TestMrpCommon):
|
||||
|
||||
|
||||
class TestUnbuild(TestMrpCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
def _check_multiwarehouse_group(*args, **kwargs):
|
||||
pass
|
||||
|
||||
with patch(
|
||||
"odoo.addons.stock.models.stock_warehouse.Warehouse._check_multiwarehouse_group",
|
||||
new=_check_multiwarehouse_group,
|
||||
):
|
||||
super(TestMrpCommon, cls).setUpClass()
|
||||
|
||||
def setUp(self):
|
||||
super(TestUnbuild, self).setUp()
|
||||
self.stock_location = self.env.ref("stock.stock_location_stock")
|
||||
self.Quant = self.env["stock.quant"].with_context(inventory_mode=True)
|
||||
self.env.ref("base.group_user").write(
|
||||
{"implied_ids": [(4, self.env.ref("stock.group_production_lot").id)]}
|
||||
)
|
||||
@@ -96,8 +141,7 @@ class TestUnbuild(TestMrpCommon):
|
||||
{
|
||||
"name": "Test Account",
|
||||
"code": "TestAccount2",
|
||||
"user_type_id": self.env.ref("account.data_account_type_payable").id,
|
||||
"reconcile": True,
|
||||
"account_type": "liability_payable",
|
||||
}
|
||||
)
|
||||
location = self.env["stock.location"].search([("usage", "=", "production")])
|
||||
@@ -116,15 +160,35 @@ class TestUnbuild(TestMrpCommon):
|
||||
p2.standard_price = 5
|
||||
p_final.categ_id = pc.id
|
||||
|
||||
self.env["stock.quant"]._update_available_quantity(p1, self.stock_location, 100)
|
||||
self.env["stock.quant"]._update_available_quantity(p2, self.stock_location, 5)
|
||||
self.Quant.create(
|
||||
{
|
||||
"product_id": p1.id,
|
||||
"location_id": self.stock_location.id,
|
||||
"inventory_quantity": 100,
|
||||
}
|
||||
).action_apply_inventory()
|
||||
self.Quant.create(
|
||||
{
|
||||
"product_id": p2.id,
|
||||
"location_id": self.stock_location.id,
|
||||
"inventory_quantity": 5,
|
||||
}
|
||||
).action_apply_inventory()
|
||||
mo.action_assign()
|
||||
|
||||
mo_form = Form(mo)
|
||||
mo_form.qty_producing = 5.0
|
||||
mo = mo_form.save()
|
||||
mo.button_mark_done()
|
||||
journal_items_before_unbuild = self.env["account.move.line"].search([]).ids
|
||||
journal_items_before_unbuild = (
|
||||
self.env["account.move.line"]
|
||||
.search(
|
||||
[
|
||||
("mrp_production_id", "=", mo.id),
|
||||
]
|
||||
)
|
||||
.ids
|
||||
)
|
||||
|
||||
x = Form(self.env["mrp.unbuild"])
|
||||
x.product_id = p_final
|
||||
@@ -132,7 +196,17 @@ class TestUnbuild(TestMrpCommon):
|
||||
x.product_qty = 5
|
||||
unbuild = x.save()
|
||||
unbuild.action_unbuild()
|
||||
journal_items_after_unbuild = self.env["account.move.line"].search([]).ids
|
||||
journal_items_after_unbuild = (
|
||||
self.env["account.move.line"]
|
||||
.search(
|
||||
[
|
||||
"|",
|
||||
("mrp_production_id", "=", mo.id),
|
||||
("unbuild_id", "=", unbuild.id),
|
||||
]
|
||||
)
|
||||
.ids
|
||||
)
|
||||
|
||||
result = unbuild.view_journal_items()
|
||||
domain = result["domain"]
|
||||
|
||||
Reference in New Issue
Block a user