mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] procurement_auto_create_group: Migration to 16.0
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
"name": "Procurement Auto Create Group",
|
||||
"version": "15.0.1.0.0",
|
||||
"version": "16.0.1.0.0",
|
||||
"development_status": "Production/Stable",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Allows to configure the system to propose automatically new "
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
* Héctor Villarreal Ortega <hector.villarreal@forgeflow.com>
|
||||
* Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
|
||||
* Bernat Puig <bernat.puig@forgeflow.com>
|
||||
* Laurent Mignon <laurent.mignon@acsone.eu>
|
||||
|
||||
@@ -5,108 +5,110 @@ from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestProcurementAutoCreateGroup(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestProcurementAutoCreateGroup, self).setUp()
|
||||
self.group_obj = self.env["procurement.group"]
|
||||
self.rule_obj = self.env["stock.rule"]
|
||||
self.route_obj = self.env["stock.location.route"]
|
||||
self.move_obj = self.env["stock.move"]
|
||||
self.picking_obj = self.env["stock.picking"]
|
||||
self.product_obj = self.env["product.product"]
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
|
||||
cls.group_obj = cls.env["procurement.group"]
|
||||
cls.rule_obj = cls.env["stock.rule"]
|
||||
cls.route_obj = cls.env["stock.route"]
|
||||
cls.move_obj = cls.env["stock.move"]
|
||||
cls.picking_obj = cls.env["stock.picking"]
|
||||
cls.product_obj = cls.env["product.product"]
|
||||
|
||||
self.warehouse = self.env.ref("stock.warehouse0")
|
||||
self.location = self.env.ref("stock.stock_location_stock")
|
||||
self.company_id = self.env.ref("base.main_company")
|
||||
self.supplier_location = self.env.ref("stock.stock_location_suppliers")
|
||||
self.loc_components = self.env.ref("stock.stock_location_components")
|
||||
picking_type_id = self.env.ref("stock.picking_type_internal").id
|
||||
cls.warehouse = cls.env.ref("stock.warehouse0")
|
||||
cls.location = cls.env.ref("stock.stock_location_stock")
|
||||
cls.company_id = cls.env.ref("base.main_company")
|
||||
cls.supplier_location = cls.env.ref("stock.stock_location_suppliers")
|
||||
cls.loc_components = cls.env.ref("stock.stock_location_components")
|
||||
picking_type_id = cls.env.ref("stock.picking_type_internal").id
|
||||
|
||||
self.partner = self.env["res.partner"].create({"name": "Partner"})
|
||||
cls.partner = cls.env["res.partner"].create({"name": "Partner"})
|
||||
|
||||
# Create rules and routes:
|
||||
pull_push_route_auto = self.route_obj.create({"name": "Auto Create Group"})
|
||||
self.rule_1 = self.rule_obj.create(
|
||||
pull_push_route_auto = cls.route_obj.create({"name": "Auto Create Group"})
|
||||
cls.rule_1 = cls.rule_obj.create(
|
||||
{
|
||||
"name": "rule with autocreate",
|
||||
"route_id": pull_push_route_auto.id,
|
||||
"auto_create_group": True,
|
||||
"action": "pull_push",
|
||||
"warehouse_id": self.warehouse.id,
|
||||
"warehouse_id": cls.warehouse.id,
|
||||
"picking_type_id": picking_type_id,
|
||||
"location_id": self.location.id,
|
||||
"location_src_id": self.loc_components.id,
|
||||
"partner_address_id": self.partner.id,
|
||||
"location_dest_id": cls.location.id,
|
||||
"location_src_id": cls.loc_components.id,
|
||||
"partner_address_id": cls.partner.id,
|
||||
}
|
||||
)
|
||||
pull_push_route_no_auto = self.route_obj.create(
|
||||
pull_push_route_no_auto = cls.route_obj.create(
|
||||
{"name": "Not Auto Create Group"}
|
||||
)
|
||||
self.rule_obj.create(
|
||||
cls.rule_obj.create(
|
||||
{
|
||||
"name": "rule with no autocreate",
|
||||
"route_id": pull_push_route_no_auto.id,
|
||||
"auto_create_group": False,
|
||||
"action": "pull_push",
|
||||
"warehouse_id": self.warehouse.id,
|
||||
"warehouse_id": cls.warehouse.id,
|
||||
"picking_type_id": picking_type_id,
|
||||
"location_id": self.location.id,
|
||||
"location_src_id": self.loc_components.id,
|
||||
"location_dest_id": cls.location.id,
|
||||
"location_src_id": cls.loc_components.id,
|
||||
}
|
||||
)
|
||||
push_route_auto = self.route_obj.create({"name": "Auto Create Group"})
|
||||
self.rule_1 = self.rule_obj.create(
|
||||
push_route_auto = cls.route_obj.create({"name": "Auto Create Group"})
|
||||
cls.rule_1 = cls.rule_obj.create(
|
||||
{
|
||||
"name": "route_auto",
|
||||
"location_src_id": self.location.id,
|
||||
"location_id": self.loc_components.id,
|
||||
"location_src_id": cls.location.id,
|
||||
"location_dest_id": cls.loc_components.id,
|
||||
"route_id": push_route_auto.id,
|
||||
"auto_create_group": True,
|
||||
"auto": "manual",
|
||||
"picking_type_id": picking_type_id,
|
||||
"warehouse_id": self.warehouse.id,
|
||||
"company_id": self.company_id.id,
|
||||
"warehouse_id": cls.warehouse.id,
|
||||
"company_id": cls.company_id.id,
|
||||
"action": "push",
|
||||
}
|
||||
)
|
||||
push_route_no_auto = self.route_obj.create({"name": "Not Auto Create Group"})
|
||||
self.rule_obj.create(
|
||||
push_route_no_auto = cls.route_obj.create({"name": "Not Auto Create Group"})
|
||||
cls.rule_obj.create(
|
||||
{
|
||||
"name": "route_no_auto",
|
||||
"location_src_id": self.location.id,
|
||||
"location_id": self.loc_components.id,
|
||||
"location_src_id": cls.location.id,
|
||||
"location_dest_id": cls.loc_components.id,
|
||||
"route_id": push_route_no_auto.id,
|
||||
"auto_create_group": False,
|
||||
"auto": "manual",
|
||||
"picking_type_id": picking_type_id,
|
||||
"warehouse_id": self.warehouse.id,
|
||||
"company_id": self.company_id.id,
|
||||
"warehouse_id": cls.warehouse.id,
|
||||
"company_id": cls.company_id.id,
|
||||
"action": "push",
|
||||
}
|
||||
)
|
||||
|
||||
# Prepare products:
|
||||
self.prod_auto_pull_push = self.product_obj.create(
|
||||
cls.prod_auto_pull_push = cls.product_obj.create(
|
||||
{
|
||||
"name": "Test Product 1",
|
||||
"type": "product",
|
||||
"route_ids": [(6, 0, [pull_push_route_auto.id])],
|
||||
}
|
||||
)
|
||||
self.prod_no_auto_pull_push = self.product_obj.create(
|
||||
cls.prod_no_auto_pull_push = cls.product_obj.create(
|
||||
{
|
||||
"name": "Test Product 2",
|
||||
"type": "product",
|
||||
"route_ids": [(6, 0, [pull_push_route_no_auto.id])],
|
||||
}
|
||||
)
|
||||
self.prod_auto_push = self.product_obj.create(
|
||||
cls.prod_auto_push = cls.product_obj.create(
|
||||
{
|
||||
"name": "Test Product 3",
|
||||
"type": "product",
|
||||
"route_ids": [(6, 0, [push_route_auto.id])],
|
||||
}
|
||||
)
|
||||
self.prod_no_auto_push = self.product_obj.create(
|
||||
cls.prod_no_auto_push = cls.product_obj.create(
|
||||
{
|
||||
"name": "Test Product 4",
|
||||
"type": "product",
|
||||
@@ -114,31 +116,33 @@ class TestProcurementAutoCreateGroup(TransactionCase):
|
||||
}
|
||||
)
|
||||
|
||||
def _procure(self, product):
|
||||
@classmethod
|
||||
def _procure(cls, product):
|
||||
values = {}
|
||||
self.group_obj.run(
|
||||
cls.group_obj.run(
|
||||
[
|
||||
self.env["procurement.group"].Procurement(
|
||||
cls.env["procurement.group"].Procurement(
|
||||
product,
|
||||
5.0,
|
||||
product.uom_id,
|
||||
self.location,
|
||||
cls.location,
|
||||
"TEST",
|
||||
"odoo tests",
|
||||
self.env.company,
|
||||
cls.env.company,
|
||||
values,
|
||||
)
|
||||
]
|
||||
)
|
||||
return True
|
||||
|
||||
def _push_trigger(self, product):
|
||||
picking = self.picking_obj.create(
|
||||
@classmethod
|
||||
def _push_trigger(cls, product):
|
||||
picking = cls.picking_obj.create(
|
||||
{
|
||||
"picking_type_id": self.ref("stock.picking_type_in"),
|
||||
"location_id": self.supplier_location.id,
|
||||
"location_dest_id": self.location.id,
|
||||
"move_lines": [
|
||||
"picking_type_id": cls.env.ref("stock.picking_type_in").id,
|
||||
"location_id": cls.supplier_location.id,
|
||||
"location_dest_id": cls.location.id,
|
||||
"move_ids": [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
@@ -149,14 +153,15 @@ class TestProcurementAutoCreateGroup(TransactionCase):
|
||||
"date": "2099-06-01 18:00:00",
|
||||
"product_uom": product.uom_id.id,
|
||||
"product_uom_qty": 1.0,
|
||||
"location_id": self.supplier_location.id,
|
||||
"location_dest_id": self.location.id,
|
||||
"location_id": cls.supplier_location.id,
|
||||
"location_dest_id": cls.location.id,
|
||||
},
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
picking.move_lines.write({"quantity_done": 1.0})
|
||||
picking.action_confirm()
|
||||
picking.move_ids.write({"quantity_done": 1.0})
|
||||
picking.button_validate()
|
||||
|
||||
def test_01_pull_push_no_auto_create_group(self):
|
||||
|
||||
Reference in New Issue
Block a user