diff --git a/addons/mrp/data/mrp_demo.xml b/addons/mrp/data/mrp_demo.xml
index 6a55de49738..83e38b7336f 100644
--- a/addons/mrp/data/mrp_demo.xml
+++ b/addons/mrp/data/mrp_demo.xml
@@ -629,7 +629,8 @@
-
+
+
diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py
index 30a6fb49c44..fda419b396b 100644
--- a/addons/mrp/tests/test_order.py
+++ b/addons/mrp/tests/test_order.py
@@ -57,7 +57,7 @@ class TestMrpOrder(TestMrpCommon):
'location_id': self.warehouse_1.lot_stock_id.id
})]
})
- inventory.action_done()
+ inventory.action_validate()
test_date_planned = datetime.now() - timedelta(days=1)
test_quantity = 2.0
@@ -241,7 +241,7 @@ class TestMrpOrder(TestMrpCommon):
})]
})
inventory.action_start()
- inventory.action_done()
+ inventory.action_validate()
# re-assign consume material
man_order.action_assign()
@@ -399,7 +399,7 @@ class TestMrpOrder(TestMrpCommon):
'location_id': source_location_id
})]
})
- inventory.action_done()
+ inventory.action_validate()
# create a mo for this bom
mo_custom_laptop = self.env['mrp.production'].create({
diff --git a/addons/mrp/tests/test_stock.py b/addons/mrp/tests/test_stock.py
index 8b3c557d3e2..650d1752e1e 100644
--- a/addons/mrp/tests/test_stock.py
+++ b/addons/mrp/tests/test_stock.py
@@ -70,7 +70,8 @@ class TestWarehouse(common.TestMrpCommon):
(0, 0, {'product_id': self.product_2.id, 'product_uom_id': self.product_2.uom_id.id, 'product_qty': 12, 'prod_lot_id': lot_product_2.id, 'location_id': self.ref('stock.stock_location_14')})
]})
(stock_inv_product_4 | stock_inv_product_2).action_start()
- (stock_inv_product_4 | stock_inv_product_2).action_done()
+ stock_inv_product_2.action_validate()
+ stock_inv_product_4.action_validate()
#Create Manufacturing order.
production_3 = self.env['mrp.production'].create({
@@ -97,6 +98,6 @@ class TestWarehouse(common.TestMrpCommon):
#Check scrap move is created for this production order.
#TODO: should check with scrap objects link in between
-
+
# scrap_move = production_3.move_raw_ids.filtered(lambda x: x.product_id == self.product_2 and x.scrapped)
# self.assertTrue(scrap_move, "There are no any scrap move created for production order.")
diff --git a/addons/mrp/tests/test_workorder_operation.py b/addons/mrp/tests/test_workorder_operation.py
index d137356b11a..1c01a35ca06 100644
--- a/addons/mrp/tests/test_workorder_operation.py
+++ b/addons/mrp/tests/test_workorder_operation.py
@@ -70,7 +70,7 @@ class TestWorkOrderProcess(common.TransactionCase):
'location_id': self.source_location_id
})]
})
- inventory.action_done()
+ inventory.action_validate()
# Create work order
production_table.button_plan()
@@ -170,7 +170,7 @@ class TestWorkOrderProcess(common.TransactionCase):
'location_id': self.source_location_id
})]
})
- inventory.action_done()
+ inventory.action_validate()
# Create work order
production_table.button_plan()
@@ -222,7 +222,7 @@ class TestWorkOrderProcess(common.TransactionCase):
self.assertEqual(move_table_bolt.quantity_done, 4)
# Change the quantity of the production order to 1
- wiz = self.env['change.production.qty'].create({'mo_id': production_table.id ,
+ wiz = self.env['change.production.qty'].create({'mo_id': production_table.id ,
'product_qty': 1.0})
wiz.change_prod_qty()
# ---------------------------------------------------------------
@@ -313,7 +313,7 @@ class TestWorkOrderProcess(common.TransactionCase):
})]
})
# inventory.action_start()
- inventory.action_done()
+ inventory.action_validate()
# Check consumed move status
mo_custom_laptop.action_assign()
@@ -377,12 +377,12 @@ class TestWorkOrderProcess(common.TransactionCase):
# finsh_moves_state = any(move.state != 'done' for move in mo_custom_laptop.move_finished_ids)
# self.assertFalse(raw_moves_state, "Wrong state in consumed moves of production order.")
# self.assertFalse(finsh_moves_state, "Wrong state in consumed moves of production order.")
-#
+#
# # Finished move quants of production order
-#
+#
# finshed_quant_lot_001 = mo_custom_laptop.move_finished_ids.filtered(lambda x: x.product_id.id == custom_laptop.id and x.product_uom_qty==6).mapped('quant_ids')
# finshed_quant_lot_002 = mo_custom_laptop.move_finished_ids.filtered(lambda x: x.product_id.id == custom_laptop.id and x.product_uom_qty==4).mapped('quant_ids')
-#
+#
# # Check total quantity consumed of charger, keybord
# # --------------------------------------------------
# charger_quants = mo_custom_laptop.move_raw_ids.filtered(lambda x: x.product_id.id == product_charger.id and x.state == 'done').mapped('quant_ids')
@@ -487,7 +487,7 @@ class TestWorkOrderProcess(common.TransactionCase):
})]
})
# inventory.action_start()
- inventory.action_done()
+ inventory.action_validate()
# Start Production ...
# --------------------
diff --git a/addons/sale_mrp/tests/test_sale_mrp_flow.py b/addons/sale_mrp/tests/test_sale_mrp_flow.py
index 14a94657f83..fed0cbcf45b 100644
--- a/addons/sale_mrp/tests/test_sale_mrp_flow.py
+++ b/addons/sale_mrp/tests/test_sale_mrp_flow.py
@@ -253,7 +253,7 @@ class TestSaleMrpFlow(common.TransactionCase):
'product_uom_id': self.uom_kg.id,
'product_qty': 20,
'location_id': self.stock_location.id})
- inventory.action_done()
+ inventory.action_validate()
# --------------------------------------------------
# Assign product c to manufacturing order of product D.
@@ -307,7 +307,7 @@ class TestSaleMrpFlow(common.TransactionCase):
'product_uom_id': self.uom_kg.id,
'product_qty': 27.5025,
'location_id': self.stock_location.id})
- inventory.action_done()
+ inventory.action_validate()
# Assign product to manufacturing order of product A.
# ---------------------------------------------------
diff --git a/addons/stock/data/stock_demo.xml b/addons/stock/data/stock_demo.xml
index 982d24fc9ad..c6d62993bb1 100644
--- a/addons/stock/data/stock_demo.xml
+++ b/addons/stock/data/stock_demo.xml
@@ -35,7 +35,7 @@
customer
-
+
@@ -131,7 +131,7 @@
-
+
@@ -176,4 +176,3 @@
-
diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py
index 8f1269cab46..3658e4fcb4d 100644
--- a/addons/stock/models/stock_inventory.py
+++ b/addons/stock/models/stock_inventory.py
@@ -177,9 +177,9 @@ class Inventory(models.Model):
'res_id': wiz.id,
}
else:
- self.action_done()
+ self._action_done()
- def action_done(self):
+ def _action_done(self):
negative = next((line for line in self.mapped('line_ids') if line.product_qty < 0 and line.product_qty != line.theoretical_qty), False)
if negative:
raise UserError(_('You cannot set a negative product quantity in an inventory line:\n\t%s - qty: %s') % (negative.product_id.name, negative.product_qty))
diff --git a/addons/stock/tests/test_inventory.py b/addons/stock/tests/test_inventory.py
index 1d0ad411e7a..6f4c3a5ab6c 100644
--- a/addons/stock/tests/test_inventory.py
+++ b/addons/stock/tests/test_inventory.py
@@ -44,7 +44,7 @@ class TestInventory(TransactionCase):
self.assertEqual(len(inventory.line_ids), 1)
self.assertEqual(inventory.line_ids.theoretical_qty, 100)
inventory.line_ids.product_qty = 0 # Put the quantity back to 0
- inventory.action_done()
+ inventory.action_validate()
# check
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0)
@@ -72,7 +72,7 @@ class TestInventory(TransactionCase):
inventory.line_ids.prod_lot_id = lot1
inventory.line_ids.product_qty = 1
- inventory.action_done()
+ inventory.action_validate()
# check
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location, lot_id=lot1), 1.0)
@@ -103,7 +103,7 @@ class TestInventory(TransactionCase):
inventory.line_ids.product_qty = 2
with self.assertRaises(ValidationError):
- inventory.action_done()
+ inventory.action_validate()
def test_inventory_4(self):
""" Check that even if a product is tracked by serial number, it's possible to add
@@ -164,7 +164,7 @@ class TestInventory(TransactionCase):
self.assertEqual(inventory.line_ids.theoretical_qty, 0)
inventory.line_ids.partner_id = owner1
inventory.line_ids.product_qty = 5
- inventory.action_done()
+ inventory.action_validate()
quant = self.env['stock.quant']._gather(self.product1, self.stock_location)
self.assertEqual(len(quant), 1)
@@ -186,7 +186,7 @@ class TestInventory(TransactionCase):
})
inventory.action_start()
inventory.line_ids.product_qty = 10
- inventory.action_done()
+ inventory.action_validate()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 10.0)
# Make a chain of two moves, validate the first and check that 10 products are reserved
@@ -229,7 +229,7 @@ class TestInventory(TransactionCase):
})
inventory.action_start()
inventory.line_ids.product_qty = 8
- inventory.action_done()
+ inventory.action_validate()
self.assertEqual(self.env['stock.quant']._gather(self.product1, self.pack_location).quantity, 8.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.pack_location), 0)
self.assertEqual(move_pack_cust.state, 'partially_available')
@@ -250,7 +250,7 @@ class TestInventory(TransactionCase):
})
inventory.action_start()
inventory.line_ids.product_qty = 10
- inventory.action_done()
+ inventory.action_validate()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.pack_location), 2)
diff --git a/addons/stock/tests/test_move2.py b/addons/stock/tests/test_move2.py
index 8cbee8a78b3..888531e8255 100644
--- a/addons/stock/tests/test_move2.py
+++ b/addons/stock/tests/test_move2.py
@@ -1055,7 +1055,7 @@ class TestSinglePicking(TestStockCommon):
})
inventory.action_start()
inventory.line_ids.product_qty = 2
- inventory.action_done()
+ inventory.action_validate()
delivery_order.action_assign()
self.assertEqual(delivery_order.state, 'assigned')
self.assertEqual(move1.state, 'assigned')
@@ -1113,7 +1113,7 @@ class TestSinglePicking(TestStockCommon):
inventory.action_start()
inventory.line_ids.prod_lot_id = lot1
inventory.line_ids.product_qty = 2
- inventory.action_done()
+ inventory.action_validate()
delivery_order.action_assign()
self.assertEqual(delivery_order.state, 'assigned')
self.assertEqual(move1.state, 'assigned')
@@ -1179,7 +1179,7 @@ class TestSinglePicking(TestStockCommon):
'product_id': self.productA.id,
'product_qty': 1,
})
- inventory.action_done()
+ inventory.action_validate()
delivery_order.action_assign()
self.assertEqual(delivery_order.state, 'assigned')
self.assertEqual(move1.state, 'assigned')
@@ -1246,7 +1246,7 @@ class TestSinglePicking(TestStockCommon):
'product_id': self.productA.id,
'product_qty': 1,
})
- inventory.action_done()
+ inventory.action_validate()
delivery_order.action_assign()
self.assertEqual(delivery_order.state, 'assigned')
self.assertEqual(move1.state, 'assigned')
@@ -1820,7 +1820,7 @@ class TestRoutes(TestStockCommon):
'categ_id': self.env.ref('product.product_category_all').id,
})
self.uom_unit = self.env.ref('uom.product_uom_unit')
-
+
def _enable_pick_ship(self):
self.wh = self.env['stock.warehouse'].search([('company_id', '=', self.env.user.id)], limit=1)
@@ -1834,7 +1834,7 @@ class TestRoutes(TestStockCommon):
`origin` fields are erased.
"""
self._enable_pick_ship()
-
+
# create a procurement group and set in on the pick procurement rule
procurement_group0 = self.env['procurement.group'].create({})
pick_rule = self.pick_ship_route.pull_ids.filtered(lambda rule: 'Stock -> Output' in rule.name)
@@ -1888,9 +1888,9 @@ class TestRoutes(TestStockCommon):
move2._action_confirm()
self.assertEqual(picking_pick.partner_id.id, False)
self.assertEqual(picking_pick.origin, False)
-
+
def test_replenish_pick_ship_1(self):
- """ Creates 2 warehouses and make a replenish using one warehouse
+ """ Creates 2 warehouses and make a replenish using one warehouse
to ressuply the other one, Then check if the quantity and the product are matching
"""
self.product_uom_qty = 42
@@ -1916,21 +1916,21 @@ class TestRoutes(TestStockCommon):
'quantity': self.product_uom_qty,
'warehouse_id': self.wh.id,
})
-
+
replenish_wizard.launch_replenishment()
last_picking_id = self.env['stock.picking'].search([('origin', '=', 'Manual Replenishment')])[-1]
self.assertTrue(last_picking_id, 'Picking not found')
move_line = last_picking_id.move_lines.search([('product_id','=', self.product1.id)])
self.assertTrue(move_line,'The product is not in the picking')
self.assertEqual(move_line[0].product_uom_qty, self.product_uom_qty, 'Quantities does not match')
- self.assertEqual(move_line[1].product_uom_qty, self.product_uom_qty, 'Quantities does not match')
+ self.assertEqual(move_line[1].product_uom_qty, self.product_uom_qty, 'Quantities does not match')
def test_push_rule_on_move_1(self):
""" Create a route with a push rule, force it on a move, check that it is applied.
- """
+ """
self._enable_pick_ship()
stock_location = self.env.ref('stock.stock_location_stock')
-
+
push_location = self.env['stock.location'].create({
'location_id': stock_location.location_id.id,
'name': 'push location',
diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py
index 19214a4fdcf..ef6c72cbf27 100644
--- a/addons/stock/tests/test_stock_flow.py
+++ b/addons/stock/tests/test_stock_flow.py
@@ -1076,7 +1076,7 @@ class TestStockFlow(TestStockCommon):
'product_uom_id': self.uom_dozen.id,
'product_qty': 10,
'location_id': self.stock_location})
- inventory.action_done()
+ inventory.action_validate()
# Check quantity available of product UnitA.
quants = self.StockQuantObj.search([('product_id', '=', self.UnitA.id), ('location_id', '=', self.stock_location)])
total_qty = [quant.quantity for quant in quants]
@@ -1092,7 +1092,7 @@ class TestStockFlow(TestStockCommon):
self.assertEqual(inventory_line.product_qty, 120, "Wrong product quantity in inventory line.")
# Modify the inventory line and set the quantity to 144 product on this new inventory.
inventory_line.write({'product_qty': 144})
- inventory.action_done()
+ inventory.action_validate()
move = self.MoveObj.search([('product_id', '=', self.UnitA.id), ('inventory_id', '=', inventory.id)], limit=1)
self.assertEqual(move.product_uom_qty, 24, "Wrong move quantity of product UnitA.")
# Check quantity available of product UnitA.
@@ -1118,7 +1118,7 @@ class TestStockFlow(TestStockCommon):
'product_uom_id': self.uom_tone.id,
'product_qty': 5,
'location_id': self.stock_location})
- inventory.action_done()
+ inventory.action_validate()
quants = self.StockQuantObj.search([('product_id', '=', productKG.id), ('location_id', '=', self.stock_location)])
total_qty = [quant.quantity for quant in quants]
self.assertEqual(sum(total_qty), 5000, 'Expecting 5000 kg , got %.4f kg on location stock!' % (sum(total_qty)))
@@ -1133,7 +1133,7 @@ class TestStockFlow(TestStockCommon):
self.assertEqual(inventory_line.product_qty, 5000, "Wrong product quantity in inventory line.")
# Modify the inventory line and set the quantity to 4000 product on this new inventory.
inventory_line.write({'product_qty': 4000})
- inventory.action_done()
+ inventory.action_validate()
# Check inventory move quantity of product KG.
move = self.MoveObj.search([('product_id', '=', productKG.id), ('inventory_id', '=', inventory.id)], limit=1)
self.assertEqual(move.product_uom_qty, 1000, "Wrong move quantity of product KG.")
@@ -1168,7 +1168,7 @@ class TestStockFlow(TestStockCommon):
line_vals += [{'location_id': self.stock_location, 'product_id': lotproduct.id, 'product_qty': 30, 'product_uom_id': lotproduct.uom_id.id, 'prod_lot_id': lot1.id}]
line_vals += [{'location_id': self.stock_location, 'product_id': lotproduct.id, 'product_qty': 25, 'product_uom_id': lotproduct.uom_id.id, 'prod_lot_id': False}]
inventory.write({'line_ids': [(0, 0, x) for x in line_vals]})
- inventory.action_done()
+ inventory.action_validate()
self.assertEqual(packproduct.qty_available, 30, "Wrong qty available for packproduct")
self.assertEqual(lotproduct.qty_available, 55, "Wrong qty available for lotproduct")
quants = self.StockQuantObj.search([('product_id', '=', packproduct.id), ('location_id', '=', self.stock_location), ('package_id', '=', pack1.id)])
@@ -1185,7 +1185,7 @@ class TestStockFlow(TestStockCommon):
line_vals += [{'location_id': self.stock_location, 'product_id': lotproduct.id, 'product_qty': 0, 'product_uom_id': lotproduct.uom_id.id, 'prod_lot_id': False}]
line_vals += [{'location_id': self.stock_location, 'product_id': lotproduct.id, 'product_qty': 10, 'product_uom_id': lotproduct.uom_id.id, 'prod_lot_id': lot1.id}]
inventory2.write({'line_ids': [(0, 0, x) for x in line_vals]})
- inventory2.action_done()
+ inventory2.action_validate()
self.assertEqual(packproduct.qty_available, 40, "Wrong qty available for packproduct")
self.assertEqual(lotproduct.qty_available, 10, "Wrong qty available for lotproduct")
quants = self.StockQuantObj.search([('product_id', '=', lotproduct.id), ('location_id', '=', self.stock_location), ('lot_id', '=', lot1.id)])
@@ -1208,7 +1208,7 @@ class TestStockFlow(TestStockCommon):
# check all products have given category id
products_category = inventory3.line_ids.mapped('product_id.categ_id')
self.assertEqual(len(products_category), 1, "Inventory line should have only one category")
- inventory3.action_done()
+ inventory3.action_validate()
# check category with exhausted in stock location
inventory4 = self.InvObj.create({
'name': 'Test Exhausted Product',
@@ -1220,7 +1220,7 @@ class TestStockFlow(TestStockCommon):
inventory4.action_start()
inventory4._get_inventory_lines_values()
inventory4_lines_count = len(inventory4.line_ids)
- inventory4.action_done()
+ inventory4.action_validate()
# Add one product in this product category
product = self.ProductObj.create({'name': 'Product A', 'type': 'product', 'categ_id': category_id})
# Check that this exhausted product is in the product category inventory adjustment
@@ -1234,7 +1234,7 @@ class TestStockFlow(TestStockCommon):
inventory5.action_start()
inventory5._get_inventory_lines_values()
inventory5_lines_count = len(inventory5.line_ids)
- inventory5.action_done()
+ inventory5.action_validate()
self.assertEqual(inventory5_lines_count, inventory4_lines_count + 1, "The new product is not taken into account in the inventory valuation.")
self.assertTrue(product.id in inventory5.line_ids.mapped('product_id').ids, "The new product is not take into account in the inventory valuation.")
@@ -1572,7 +1572,7 @@ class TestStockFlow(TestStockCommon):
'location_id': self.stock_location
})]
})
- inventory.action_done()
+ inventory.action_validate()
# create a "all at once" delivery order for two products
picking_out = self.PickingObj.create({
@@ -1605,7 +1605,7 @@ class TestStockFlow(TestStockCommon):
'location_id': self.stock_location
})]
})
- inventory.action_done()
+ inventory.action_validate()
# recheck availability of the delivery order, it should be assigned
picking_out.action_assign()
self.assertEquals(len(picking_out.move_lines), 1.0)
@@ -1664,7 +1664,7 @@ class TestStockFlow(TestStockCommon):
'location_id': self.stock_location
})]
})
- inventory.action_done()
+ inventory.action_validate()
# create a "partial" delivery order for two products
picking_out = self.PickingObj.create({
@@ -1698,7 +1698,7 @@ class TestStockFlow(TestStockCommon):
'location_id': self.stock_location
})]
})
- inventory.action_done()
+ inventory.action_validate()
# recheck availability of the delivery order, it should be assigned
picking_out.action_assign()
diff --git a/addons/stock/tests/test_warehouse.py b/addons/stock/tests/test_warehouse.py
index 0704dc3dd3a..c54dced5b6a 100644
--- a/addons/stock/tests/test_warehouse.py
+++ b/addons/stock/tests/test_warehouse.py
@@ -28,7 +28,7 @@ class TestWarehouse(TestStockCommon):
# Update the line, set to 35
inventory.line_ids.write({'product_qty': 35.0})
- inventory.action_done()
+ inventory.action_validate()
# Check related move and quants
self.assertIn(inventory.name, inventory.move_ids.name)
@@ -209,7 +209,7 @@ class TestWarehouse(TestStockCommon):
self.assertEqual(len(inventory.line_ids), 1, "Wrong inventory lines generated.")
self.assertEqual(inventory.line_ids.theoretical_qty, -1, "Theoretical quantity should be -1.")
inventory.line_ids.product_qty = 0 # Put the quantity back to 0
- inventory.action_done()
+ inventory.action_validate()
# The inventory adjustment should have created one
self.assertEqual(len(inventory.move_ids), 1)
@@ -246,4 +246,4 @@ class TestResupply(TestStockCommon):
'product_min_qty': 10,
'product_max_qty': 100,
'product_uom': self.uom_unit.id,
- })
\ No newline at end of file
+ })
diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py
index 0d65f56d807..7301555d993 100644
--- a/addons/stock/wizard/stock_change_product_qty.py
+++ b/addons/stock/wizard/stock_change_product_qty.py
@@ -91,5 +91,5 @@ class ProductChangeQuantity(models.TransientModel):
'location_id': wizard.location_id.id,
'line_ids': [(0, 0, line_data)],
})
- inventory.action_done()
+ inventory.action_validate()
return {'type': 'ir.actions.act_window_close'}