summaryrefslogtreecommitdiff
path: root/addons/mrp
diff options
context:
space:
mode:
authorsvs-odoo <svs@odoo.com>2019-05-03 08:02:16 +0000
committersvs-odoo <svs@odoo.com>2019-05-29 13:59:01 +0000
commitda33eb36b80d1b2a0004c28cf20d6b0263bcb643 (patch)
treee3a93c2ab2bac21dc43401013af28f491429d1a8 /addons/mrp
parentbe2795513644f09f6b443f462bb67cc5a0762e8d (diff)
[IMP] stock: editable quants
Made some changes in stock.quant model to allow user to modify product quantity easier. To allow the edition of quant without opening more permissions on the model, we switch to sudo in create mode and write if the conditions are met (special key in context + access rights on the current user + write on a specific field). Also, we have two list views for the quant: - The old list view who still readonly. - A new list view where user can create new quant or edit quantity of existing ones We display the second one if user is a stock manager. For existing quants, user can modify counted quantity (which will modify product quantity). User can also create new quant, in this case: - The quant is really a new one (ex.: new product/location association) so will simply create a new quant. - A corresponding quant already exist, so will modify the existing quant instead of create a new one. When an user creates a new quant, the model will check each time a non-quantity field (product, location, SN/LN, package or owner) is modified to see if corresponding quant exists. In this case, it'll get the quant ID and will update reserved and on hand quantities. If user didn't change the inventory quantity, it'll be updated too. On product form view, the 'Update quantity' button was removed as user can now simply modify quant with 'On Hand' stat button. Task #1935921 Co-authored-by: sle-odoo <sle@odoo.com>
Diffstat (limited to 'addons/mrp')
-rw-r--r--addons/mrp/tests/test_order.py12
-rw-r--r--addons/mrp/tests/test_procurement.py12
-rw-r--r--addons/mrp/tests/test_workorder_operation.py6
3 files changed, 15 insertions, 15 deletions
diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py
index ccf4843f075..233d0bf4354 100644
--- a/addons/mrp/tests/test_order.py
+++ b/addons/mrp/tests/test_order.py
@@ -128,22 +128,22 @@ class TestMrpOrder(TestMrpCommon):
self.assertEqual(production_2.reservation_state, 'confirmed', 'Production order should be availability for waiting state')
# Update Inventory
- inventory_wizard = self.env['stock.change.product.qty'].create({
+ self.env['stock.quant'].with_context(inventory_mode=True).create({
'product_id': self.product_2.id,
- 'new_quantity': 2.0,
+ 'inventory_quantity': 2.0,
+ 'location_id': self.ref('stock.stock_location_14')
})
- inventory_wizard.change_product_qty()
production_2.action_assign()
# check sub product availability state is partially available
self.assertEqual(production_2.reservation_state, 'confirmed', 'Production order should be availability for partially available state')
# Update Inventory
- inventory_wizard = self.env['stock.change.product.qty'].create({
+ self.env['stock.quant'].with_context(inventory_mode=True).create({
'product_id': self.product_2.id,
- 'new_quantity': 5.0,
+ 'inventory_quantity': 5.0,
+ 'location_id': self.ref('stock.stock_location_14')
})
- inventory_wizard.change_product_qty()
production_2.action_assign()
# check sub product availability state is assigned
diff --git a/addons/mrp/tests/test_procurement.py b/addons/mrp/tests/test_procurement.py
index e3a3b24352d..1b4f711b856 100644
--- a/addons/mrp/tests/test_procurement.py
+++ b/addons/mrp/tests/test_procurement.py
@@ -54,11 +54,11 @@ class TestProcurement(TestMrpCommon):
# Product2 48 Unit
# ---------------------
# Update Inventory
- inventory_wizard = self.env['stock.change.product.qty'].create({
+ self.env['stock.quant'].with_context(inventory_mode=True).create({
'product_id': self.product_2.id,
- 'new_quantity': 48,
+ 'inventory_quantity': 48,
+ 'location_id': self.warehouse.lot_stock_id.id,
})
- inventory_wizard.change_product_qty()
produce_product_4.action_assign()
self.assertEqual(produce_product_4.product_qty, 8, "Wrong quantity of finish product.")
self.assertEqual(produce_product_4.product_uom_id, self.uom_dozen, "Wrong quantity of finish product.")
@@ -83,11 +83,11 @@ class TestProcurement(TestMrpCommon):
# ------------------
# Update Inventory
- inventory_wizard = self.env['stock.change.product.qty'].create({
+ self.env['stock.quant'].with_context(inventory_mode=True).create({
'product_id': self.product_2.id,
- 'new_quantity': 12,
+ 'inventory_quantity': 12,
+ 'location_id': self.warehouse.lot_stock_id.id,
})
- inventory_wizard.change_product_qty()
production_product_6.action_assign()
# ------------------------------------
diff --git a/addons/mrp/tests/test_workorder_operation.py b/addons/mrp/tests/test_workorder_operation.py
index 38d52c799c2..530abcab062 100644
--- a/addons/mrp/tests/test_workorder_operation.py
+++ b/addons/mrp/tests/test_workorder_operation.py
@@ -307,11 +307,11 @@ class TestWorkOrderProcess(TestMrpCommon):
man_order = man_order_form.save()
# reset quantities
self.product_1.type = "product"
- self.env['stock.change.product.qty'].create({
+ self.env['stock.quant'].with_context(inventory_mode=True).create({
'product_id': self.product_1.id,
- 'new_quantity': 0.0,
+ 'inventory_quantity': 0.0,
'location_id': self.warehouse_1.lot_stock_id.id,
- }).change_product_qty()
+ })
(self.product_2 | self.product_4).write({
'tracking': 'none',