[FIX] stock: correct tests to create pickings without using new()
This commit is contained in:
@@ -26,23 +26,24 @@ class TestPacking(TransactionCase):
|
||||
})
|
||||
|
||||
# Create an incoming picking for this product of 300 PCE from suppliers to stock
|
||||
default_get_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get()))
|
||||
default_get_vals.update({
|
||||
vals = {
|
||||
'name': 'Incoming picking',
|
||||
'partner_id': self.ref('base.res_partner_2'),
|
||||
'picking_type_id': self.ref('stock.picking_type_in'),
|
||||
'location_id': self.ref('stock.stock_location_suppliers'),
|
||||
'location_dest_id': self.ref('stock.stock_location_stock'),
|
||||
'move_lines': [(0, 0, {
|
||||
'name': '/',
|
||||
'product_id': product1.id,
|
||||
'product_uom': product1.uom_id.id,
|
||||
'product_uom_qty': 300.00,
|
||||
'location_id': self.ref('stock.stock_location_suppliers'),
|
||||
'location_dest_id': self.ref('stock.stock_location_stock'),
|
||||
})],
|
||||
})
|
||||
pick1 = self.env['stock.picking'].new(default_get_vals)
|
||||
}
|
||||
pick1 = self.env['stock.picking'].create(vals)
|
||||
pick1.onchange_picking_type()
|
||||
pick1.move_lines.onchange_product_id()
|
||||
vals = pick1._convert_to_write(pick1._cache)
|
||||
pick1 = self.env['stock.picking'].create(vals)
|
||||
|
||||
# Confirm and assign picking
|
||||
pick1.action_confirm()
|
||||
@@ -106,23 +107,24 @@ class TestPacking(TransactionCase):
|
||||
self.assertTrue(len(pick1.move_lines) == 1)
|
||||
|
||||
# Make a delivery order of 300 pieces to the customer
|
||||
default_get_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get()))
|
||||
default_get_vals.update({
|
||||
vals = {
|
||||
'name': 'outgoing picking',
|
||||
'partner_id': self.ref('base.res_partner_4'),
|
||||
'picking_type_id': self.ref('stock.picking_type_out'),
|
||||
'location_id': self.ref('stock.stock_location_stock'),
|
||||
'location_dest_id': self.ref('stock.stock_location_customers'),
|
||||
'move_lines': [(0, 0, {
|
||||
'name': '/',
|
||||
'product_id': product1.id,
|
||||
'product_uom': product1.uom_id.id,
|
||||
'product_uom_qty': 300.00,
|
||||
'location_id': self.ref('stock.stock_location_stock'),
|
||||
'location_dest_id': self.ref('stock.stock_location_customers'),
|
||||
})],
|
||||
})
|
||||
delivery_order1 = self.env['stock.picking'].new(default_get_vals)
|
||||
}
|
||||
delivery_order1 = self.env['stock.picking'].create(vals)
|
||||
delivery_order1.onchange_picking_type()
|
||||
delivery_order1.move_lines.onchange_product_id()
|
||||
vals = delivery_order1._convert_to_write(delivery_order1._cache)
|
||||
delivery_order1 = self.env['stock.picking'].create(vals)
|
||||
|
||||
# Assign and confirm
|
||||
delivery_order1.action_confirm()
|
||||
|
||||
@@ -24,23 +24,24 @@ class TestPackingNeg(TransactionCase):
|
||||
})
|
||||
|
||||
# Create an incoming picking for this product of 300 PCE from suppliers to stock
|
||||
default_get_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get()))
|
||||
default_get_vals.update({
|
||||
vals = {
|
||||
'name': 'Incoming picking (negative product)',
|
||||
'partner_id': self.ref('base.res_partner_2'),
|
||||
'picking_type_id': self.ref('stock.picking_type_in'),
|
||||
'location_id': self.ref('stock.stock_location_suppliers'),
|
||||
'location_dest_id': self.ref('stock.stock_location_stock'),
|
||||
'move_lines': [(0, 0, {
|
||||
'name': 'NEG',
|
||||
'product_id': product_neg.id,
|
||||
'product_uom': product_neg.uom_id.id,
|
||||
'product_uom_qty': 300.00,
|
||||
'location_id': self.ref('stock.stock_location_suppliers'),
|
||||
'location_dest_id': self.ref('stock.stock_location_stock'),
|
||||
})],
|
||||
})
|
||||
pick_neg = self.env['stock.picking'].new(default_get_vals)
|
||||
}
|
||||
pick_neg = self.env['stock.picking'].create(vals)
|
||||
pick_neg.onchange_picking_type()
|
||||
pick_neg.move_lines.onchange_product_id()
|
||||
vals = pick_neg._convert_to_write(pick_neg._cache)
|
||||
pick_neg = self.env['stock.picking'].create(vals)
|
||||
|
||||
# Confirm and assign picking
|
||||
pick_neg.action_confirm()
|
||||
@@ -80,23 +81,24 @@ class TestPackingNeg(TransactionCase):
|
||||
pick_neg.action_done()
|
||||
|
||||
# Make a delivery order of 300 pieces to the customer
|
||||
default_get_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get()))
|
||||
default_get_vals.update({
|
||||
vals = {
|
||||
'name': 'outgoing picking (negative product)',
|
||||
'partner_id': self.ref('base.res_partner_4'),
|
||||
'picking_type_id': self.ref('stock.picking_type_out'),
|
||||
'location_id': self.ref('stock.stock_location_stock'),
|
||||
'location_dest_id': self.ref('stock.stock_location_customers'),
|
||||
'move_lines': [(0, 0, {
|
||||
'name': 'NEG',
|
||||
'product_id': product_neg.id,
|
||||
'product_uom': product_neg.uom_id.id,
|
||||
'product_uom_qty': 300.00,
|
||||
'location_id': self.ref('stock.stock_location_stock'),
|
||||
'location_dest_id': self.ref('stock.stock_location_customers'),
|
||||
})],
|
||||
})
|
||||
delivery_order_neg = self.env['stock.picking'].new(default_get_vals)
|
||||
}
|
||||
delivery_order_neg = self.env['stock.picking'].create(vals)
|
||||
delivery_order_neg.onchange_picking_type()
|
||||
delivery_order_neg.move_lines.onchange_product_id()
|
||||
vals = delivery_order_neg._convert_to_write(delivery_order_neg._cache)
|
||||
delivery_order_neg = self.env['stock.picking'].create(vals)
|
||||
|
||||
# Assign and confirm
|
||||
delivery_order_neg.action_confirm()
|
||||
@@ -136,23 +138,24 @@ class TestPackingNeg(TransactionCase):
|
||||
self.assertEqual(pallet_3_stock_qty, 50, "Should have 50 pieces in stock on pallet 3")
|
||||
|
||||
# Create a picking for reconciling the negative quant
|
||||
default_get_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get()))
|
||||
default_get_vals.update({
|
||||
vals = {
|
||||
'name': 'reconciling_delivery',
|
||||
'partner_id': self.ref('base.res_partner_4'),
|
||||
'picking_type_id': self.ref('stock.picking_type_in'),
|
||||
'location_id': self.ref('stock.stock_location_suppliers'),
|
||||
'location_dest_id': self.ref('stock.stock_location_stock'),
|
||||
'move_lines': [(0, 0, {
|
||||
'name': 'NEG',
|
||||
'product_id': product_neg.id,
|
||||
'product_uom': product_neg.uom_id.id,
|
||||
'product_uom_qty': 20.0,
|
||||
'location_id': self.ref('stock.stock_location_suppliers'),
|
||||
'location_dest_id': self.ref('stock.stock_location_stock'),
|
||||
})],
|
||||
})
|
||||
delivery_reconcile = self.env['stock.picking'].new(default_get_vals)
|
||||
}
|
||||
delivery_reconcile = self.env['stock.picking'].create(vals)
|
||||
delivery_reconcile.onchange_picking_type()
|
||||
delivery_reconcile.move_lines.onchange_product_id()
|
||||
vals = delivery_reconcile._convert_to_write(delivery_reconcile._cache)
|
||||
delivery_reconcile = self.env['stock.picking'].create(vals)
|
||||
|
||||
# Receive 20 products with lot neg in stock with a new incoming shipment that should be on pallet 2
|
||||
delivery_reconcile.action_confirm()
|
||||
|
||||
@@ -27,26 +27,24 @@ class TestProcRule(TransactionCase):
|
||||
'route_ids': [(4, product_route.id)]})
|
||||
|
||||
# Create Delivery Order of 10 `product.product_product_3` from Output -> Customer
|
||||
default_get_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get()))
|
||||
default_get_vals.update({
|
||||
product = self.env.ref('product.product_product_3')
|
||||
vals = {
|
||||
'name': 'Delivery order for procurement',
|
||||
'partner_id': self.ref('base.res_partner_2'),
|
||||
'picking_type_id': self.ref('stock.picking_type_out'),
|
||||
'location_id': self.ref('stock.stock_location_output'),
|
||||
'location_dest_id': self.ref('stock.stock_location_customers'),
|
||||
'move_lines': [(0, 0, {
|
||||
'product_id': self.ref('product.product_product_3'),
|
||||
'name': '/',
|
||||
'product_id': product.id,
|
||||
'product_uom': product.uom_id.id,
|
||||
'product_uom_qty': 10.00,
|
||||
'procure_method': 'make_to_order',
|
||||
})],
|
||||
})
|
||||
pick_output = self.env['stock.picking'].new(default_get_vals)
|
||||
}
|
||||
pick_output = self.env['stock.picking'].create(vals)
|
||||
pick_output.onchange_picking_type()
|
||||
pick_output.move_lines.onchange_product_id()
|
||||
pick_output.update({
|
||||
'location_id': self.ref('stock.stock_location_output'),
|
||||
'location_dest_id': self.ref('stock.stock_location_customers'),
|
||||
})
|
||||
vals = pick_output._convert_to_write(pick_output._cache)
|
||||
pick_output = self.env['stock.picking'].create(vals)
|
||||
|
||||
# Confirm delivery order.
|
||||
pick_output.action_confirm()
|
||||
|
||||
@@ -17,25 +17,25 @@ class TestWiseOperator(TransactionCase):
|
||||
'uom_po_id': self.ref('uom.product_uom_unit'),
|
||||
})
|
||||
|
||||
picking_default_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get()))
|
||||
|
||||
# Create an incoming picking for this product of 10 PCE from suppliers to stock
|
||||
vals = dict(picking_default_vals, **{
|
||||
vals = {
|
||||
'name': 'Incoming picking (wise unit)',
|
||||
'partner_id': self.ref('base.res_partner_2'),
|
||||
'picking_type_id': self.ref('stock.picking_type_in'),
|
||||
'location_id': self.ref('stock.stock_location_suppliers'),
|
||||
'location_dest_id': self.ref('stock.stock_location_stock'),
|
||||
'move_lines': [(0, 0, {
|
||||
'name': '/',
|
||||
'product_id': product_wise.id,
|
||||
'product_uom': product_wise.uom_id.id,
|
||||
'product_uom_qty': 10.00,
|
||||
'location_id': self.ref('stock.stock_location_suppliers'),
|
||||
'location_dest_id': self.ref('stock.stock_location_stock'),
|
||||
})],
|
||||
})
|
||||
pick1_wise = self.env['stock.picking'].new(vals)
|
||||
}
|
||||
pick1_wise = self.env['stock.picking'].create(vals)
|
||||
pick1_wise.onchange_picking_type()
|
||||
pick1_wise.move_lines.onchange_product_id()
|
||||
vals = pick1_wise._convert_to_write(pick1_wise._cache)
|
||||
pick1_wise = self.env['stock.picking'].create(vals)
|
||||
|
||||
# Confirm and assign picking and prepare partial
|
||||
pick1_wise.action_confirm()
|
||||
@@ -65,22 +65,24 @@ class TestWiseOperator(TransactionCase):
|
||||
self.assertEqual(len(records.ids), 3, "The number of quants created is not correct")
|
||||
|
||||
# Make a delivery order of 5 pieces to the customer
|
||||
vals = dict(picking_default_vals, **{
|
||||
vals = {
|
||||
'name': 'outgoing picking 1 (wise unit)',
|
||||
'partner_id': self.ref('base.res_partner_4'),
|
||||
'picking_type_id': self.ref('stock.picking_type_out'),
|
||||
'location_id': self.ref('stock.stock_location_stock'),
|
||||
'location_dest_id': self.ref('stock.stock_location_customers'),
|
||||
'move_lines': [(0, 0, {
|
||||
'name': '/',
|
||||
'product_id': product_wise.id,
|
||||
'product_uom': product_wise.uom_id.id,
|
||||
'product_uom_qty': 5.0,
|
||||
'location_id': self.ref('stock.stock_location_stock'),
|
||||
'location_dest_id': self.ref('stock.stock_location_customers'),
|
||||
})],
|
||||
})
|
||||
delivery_order_wise1 = self.env['stock.picking'].new(vals)
|
||||
}
|
||||
delivery_order_wise1 = self.env['stock.picking'].create(vals)
|
||||
delivery_order_wise1.onchange_picking_type()
|
||||
delivery_order_wise1.move_lines.onchange_product_id()
|
||||
vals = delivery_order_wise1._convert_to_write(delivery_order_wise1._cache)
|
||||
delivery_order_wise1 = self.env['stock.picking'].create(vals)
|
||||
|
||||
# Assign and confirm
|
||||
delivery_order_wise1.action_confirm()
|
||||
@@ -88,22 +90,24 @@ class TestWiseOperator(TransactionCase):
|
||||
self.assertEqual(delivery_order_wise1.state, 'assigned')
|
||||
|
||||
# Make a delivery order of 5 pieces to the customer
|
||||
vals = dict(picking_default_vals, **{
|
||||
vals = {
|
||||
'name': 'outgoing picking 2 (wise unit)',
|
||||
'partner_id': self.ref('base.res_partner_4'),
|
||||
'picking_type_id': self.ref('stock.picking_type_out'),
|
||||
'location_id': self.ref('stock.stock_location_stock'),
|
||||
'location_dest_id': self.ref('stock.stock_location_customers'),
|
||||
'move_lines': [(0, 0, {
|
||||
'name': '/',
|
||||
'product_id': product_wise.id,
|
||||
'product_uom': product_wise.uom_id.id,
|
||||
'product_uom_qty': 5.0,
|
||||
'location_id': self.ref('stock.stock_location_stock'),
|
||||
'location_dest_id': self.ref('stock.stock_location_customers'),
|
||||
})],
|
||||
})
|
||||
delivery_order_wise2 = self.env['stock.picking'].new(vals)
|
||||
}
|
||||
delivery_order_wise2 = self.env['stock.picking'].create(vals)
|
||||
delivery_order_wise2.onchange_picking_type()
|
||||
delivery_order_wise2.move_lines.onchange_product_id()
|
||||
vals = delivery_order_wise2._convert_to_write(delivery_order_wise2._cache)
|
||||
delivery_order_wise2 = self.env['stock.picking'].create(vals)
|
||||
|
||||
# Assign and confirm
|
||||
delivery_order_wise2.action_confirm()
|
||||
|
||||
Reference in New Issue
Block a user