[IMP] stock: picking flow reworked

This commit changes the process flow of stock pickings. A new picking will
always be created in immediate transfer mode and 'ready' state. From
their, it can be validated directly or 'reset to draft'. This second action
switch the immediate mode to planned mode and reset the state as draft.
From their the classical workflow is processed
confirm -> (assigned ->) validated

Task: 3256447
Part-of: odoo/odoo#117513
This commit is contained in:
William Henrotin
2023-05-17 13:37:47 +02:00
parent 647a5d7449
commit 5e5d92ef79
51 changed files with 699 additions and 287 deletions
-10
View File
@@ -534,16 +534,6 @@ class StockMove(models.Model):
else:
return 0.0
def _show_details_in_draft(self):
self.ensure_one()
production = self.raw_material_production_id or self.production_id
if production and (self.state != 'draft' or production.state != 'draft'):
return True
elif production:
return False
else:
return super()._show_details_in_draft()
def _update_quantity_done(self, mo):
self.ensure_one()
new_qty = float_round((mo.qty_producing - mo.qty_produced) * self.unit_factor, precision_rounding=self.product_uom.rounding)
+1
View File
@@ -455,6 +455,7 @@ class TestProcurement(TestMrpCommon):
'location_dest_id': self.ref('stock.stock_location_customers'),
})],
})
pick_output.action_reset_draft()
pick_output.action_confirm() # should trigger orderpoint to create and confirm 1st MO
pick_output.action_assign()
+2 -1
View File
@@ -304,7 +304,6 @@ class TestKitPicking(common.TestMrpCommon):
'location_dest_id': self.warehouse_1.wh_input_stock_loc_id.id,
'partner_id': self.test_partner.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'immediate_transfer': True
})
move_receipt_1 = self.env['stock.move'].create({
'name': self.kit_parent.name,
@@ -366,6 +365,8 @@ class TestKitPicking(common.TestMrpCommon):
'picking_type_id': in_type.id,
'location_id': customer_location.id,
'location_dest_id': stock_location.id,
'state': 'draft',
'immediate_transfer': False,
'move_ids': [(0, 0, {
'name': product.name,
'product_id': product.id,
+1 -5
View File
@@ -505,16 +505,12 @@ class TestTraceability(TestMrpCommon):
moveA = self.env['stock.move'].create({
'name': 'Picking A move',
'product_id': endproductA.id,
'product_uom_qty': 1,
'quantity_done': 1,
'product_uom': endproductA.uom_id.id,
'picking_id': pickingA_out.id,
'location_id': stock_location.id,
'location_dest_id': customer_location.id})
# Confirm and assign pickingA
pickingA_out.action_confirm()
pickingA_out.action_assign()
# Set move_line lot_id to the mrp.production lot_producing_id
moveA.move_line_ids[0].write({
'qty_done': 1.0,
+1 -4
View File
@@ -708,11 +708,8 @@ class TestUnbuild(TestMrpCommon):
internal_form.location_dest_id = subloc01
with internal_form.move_ids_without_package.new() as move:
move.product_id = p_final
move.product_uom_qty = 1.0
move.quantity_done = 1.0
internal_transfer = internal_form.save()
internal_transfer.action_confirm()
internal_transfer.action_assign()
internal_transfer.move_line_ids.qty_done = 1.0
internal_transfer.button_validate()
unbuild_order_form = Form(self.env['mrp.unbuild'])
@@ -146,7 +146,10 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon):
'location_dest_id': self.customer_location,
'partner_id': self.env['ir.model.data']._xmlid_to_res_id('base.res_partner_4'),
'picking_type_id': self.warehouse.out_type_id.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': self.finished_product.name,
'product_id': self.finished_product.id,
@@ -226,6 +229,8 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon):
'location_dest_id': self.customer_location,
'partner_id': self.env['ir.model.data']._xmlid_to_res_id('base.res_partner_4'),
'picking_type_id': self.warehouse.out_type_id.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': self.finished_product.name,
@@ -334,6 +334,8 @@ class TestMrpValuationStandard(TestMrpValuationCommon):
'location_id': self.customer_location.id,
'location_dest_id': self.stock_location.id,
'picking_type_id': self.picking_type_in.id,
'state': 'draft',
'immediate_transfer': False,
'move_line_ids': [(0, 0, {
'product_id': self.product1.id,
'qty_done': 1,
@@ -80,7 +80,7 @@ class MrpProduction(models.Model):
if consumption_issues:
return self._action_generate_consumption_wizard(consumption_issues)
self._update_finished_move()
self.sudo()._update_finished_move() # Portal user may need sudo rights to update pickings
self.subcontracting_has_been_recorded = True
quantity_issues = self._get_quantity_produced_issues()
@@ -153,9 +153,6 @@ class StockMove(models.Model):
bom = move._get_subcontract_bom()
if not bom:
continue
if float_is_zero(move.product_qty, precision_rounding=move.product_uom.rounding) and\
move.picking_id.immediate_transfer is True:
raise UserError(_("To subcontract, use a planned transfer."))
move.write({
'is_subcontract': True,
'location_id': move.picking_id.partner_id.with_company(move.company_id).property_stock_subcontractor.id
@@ -241,7 +238,10 @@ class StockMove(models.Model):
def _update_subcontract_order_qty(self, new_quantity):
for move in self:
quantity_to_remove = move.product_uom_qty - new_quantity
move_quantity = move.quantity_done if move.from_immediate_transfer else move.product_uom_qty
quantity_to_remove = move_quantity - new_quantity
if float_is_zero(quantity_to_remove, precision_rounding=move.product_uom.rounding):
continue
productions = move.move_orig_ids.production_id.filtered(lambda p: p.state not in ('done', 'cancel'))[::-1]
# Cancel productions until reach new_quantity
for production in productions:
@@ -138,7 +138,7 @@ class StockPicking(models.Model):
'bom_id': bom.id,
'location_src_id': subcontract_move.picking_id.partner_id.with_company(subcontract_move.company_id).property_stock_subcontractor.id,
'location_dest_id': subcontract_move.picking_id.partner_id.with_company(subcontract_move.company_id).property_stock_subcontractor.id,
'product_qty': subcontract_move.product_uom_qty,
'product_qty': subcontract_move.from_immediate_transfer and subcontract_move.quantity_done or subcontract_move.product_qty,
'picking_type_id': warehouse.subcontracting_type_id.id,
'date_start': subcontract_move.date - relativedelta(days=bom.produce_delay)
}
@@ -150,7 +150,8 @@ class StockPicking(models.Model):
# do not create extra production for move that have their quantity updated
if move.move_orig_ids.production_id:
continue
if float_compare(move.product_qty, 0, precision_rounding=move.product_uom.rounding) <= 0:
quantity = move.from_immediate_transfer and move.quantity_done or move.product_qty
if float_compare(quantity, 0, precision_rounding=move.product_uom.rounding) <= 0:
# If a subcontracted amount is decreased, don't create a MO that would be for a negative value.
continue
mo = self.env['mrp.production'].with_company(move.company_id).create(self._prepare_subcontract_mo_vals(move, bom))
@@ -38,9 +38,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
# Nothing should be tracked
self.assertTrue(all(m.product_uom_qty == m.reserved_availability for m in picking_receipt.move_ids))
@@ -121,9 +120,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
# Nothing should be tracked
self.assertEqual(picking_receipt.display_action_record_components, 'hide')
@@ -189,9 +187,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
# Nothing should be tracked
self.assertEqual(picking_receipt.display_action_record_components, 'hide')
@@ -255,9 +252,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
warehouse = picking_receipt.picking_type_id.warehouse_id
@@ -324,9 +320,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt1 = picking_form.save()
picking_receipt1.action_confirm()
# Create a receipt picking from the subcontractor2
picking_form = Form(self.env['stock.picking'])
@@ -334,9 +329,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = subcontractor_partner2
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt2 = picking_form.save()
picking_receipt2.action_confirm()
mo_pick1 = picking_receipt1.move_ids.mapped('move_orig_ids.production_id')
mo_pick2 = picking_receipt2.move_ids.mapped('move_orig_ids.production_id')
@@ -385,9 +379,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = subcontractor_partner2
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
picking_receipt.move_ids.quantity_done = 3.0
picking_receipt._action_done()
@@ -412,8 +405,9 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 5
move.quantity_done = 5
picking_receipt = picking_form.save()
picking_receipt.action_reset_draft()
picking_receipt.action_confirm()
picking_receipt.move_ids.quantity_done = 3
@@ -452,9 +446,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 5
move.quantity_done = 5
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
picking_delivery = self.env['stock.move'].search([
('product_id', 'in', (self.comp1 | self.comp2).ids)
@@ -485,9 +478,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = subcontractor_contact
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
# Check that a manufacturing order is created
mo = self.env['mrp.production'].search([('bom_id', '=', self.bom.id)])
self.assertEqual(len(mo), 1)
@@ -501,9 +493,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
self.assertEqual(picking_receipt.display_action_record_components, 'facultative')
action = picking_receipt.action_record_components()
mo = self.env['mrp.production'].browse(action['res_id'])
@@ -534,9 +525,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
self.assertEqual(picking_receipt.display_action_record_components, 'facultative')
action = picking_receipt.action_record_components()
@@ -642,8 +632,9 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = finished
move.product_uom_qty = 5
move.quantity_done = 5
picking = picking_form.save()
picking.action_reset_draft()
picking.action_confirm()
supply_picking = self.env['mrp.production'].search([('bom_id', '=', bom.id)]).picking_ids
@@ -745,8 +736,9 @@ class TestSubcontractingTracking(TransactionCase):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished_product
move.product_uom_qty = 1
move.quantity_done = 1
picking_receipt = picking_form.save()
picking_receipt.action_reset_draft()
picking_receipt.action_confirm()
# We should be able to call the 'record_components' button
@@ -823,8 +815,9 @@ class TestSubcontractingTracking(TransactionCase):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished_product
move.product_uom_qty = nb_finished_product
move.quantity_done = nb_finished_product
picking_receipt = picking_form.save()
picking_receipt.action_reset_draft()
picking_receipt.action_confirm()
# We shouldn't be able to call the 'record_components' button
@@ -870,8 +863,9 @@ class TestSubcontractingTracking(TransactionCase):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished_product
move.product_uom_qty = todo_nb
move.quantity_done = todo_nb
picking_receipt = picking_form.save()
picking_receipt.action_reset_draft()
picking_receipt.action_confirm()
# We should be able to call the 'record_components' button
@@ -973,8 +967,9 @@ class TestSubcontractingTracking(TransactionCase):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = finished_product
move.product_uom_qty = todo_nb
move.quantity_done = todo_nb
picking_receipt = picking_form.save()
picking_receipt.action_reset_draft()
picking_receipt.action_confirm()
mo = self.env['mrp.production'].search([('bom_id', '=', bom.id)])
@@ -1047,8 +1042,9 @@ class TestSubcontractingTracking(TransactionCase):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = finished_product
move.product_uom_qty = todo_nb
move.quantity_done = todo_nb
picking_receipt = picking_form.save()
picking_receipt.action_reset_draft()
picking_receipt.action_confirm()
mo = self.env['mrp.production'].search([('bom_id', '=', bom.id)])
@@ -1146,9 +1142,8 @@ class TestSubcontractingPortal(TransactionCase):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished_product
move.product_uom_qty = 2
move.quantity_done = 2
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
# Using the subcontractor (portal user)
lot1 = self.env['stock.lot'].with_user(self.portal_user).create({
@@ -1259,8 +1254,9 @@ class TestSubcontractingSerialMassReceipt(TransactionCase):
picking_form.partner_id = self.subcontractor
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = sum(quantities)
move.quantity_done = sum(quantities)
picking_receipt = picking_form.save()
picking_receipt.action_reset_draft()
picking_receipt.action_confirm()
# Process the delivery of the components
picking_deliver = self.env['mrp.production'].search([('bom_id', '=', self.bom.id)]).picking_ids
@@ -1297,9 +1293,8 @@ class TestSubcontractingSerialMassReceipt(TransactionCase):
picking_form.partner_id = self.subcontractor
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = quantity
move.quantity_done = quantity
picking_receipt = picking_form.save()
picking_receipt.action_confirm()
# Receive finished products
Form(self.env['stock.assign.serial'].with_context(
default_move_id=picking_receipt.move_ids[0].id,
@@ -54,8 +54,9 @@ class TestSubcontractingPortalUi(HttpCase):
picking_form.partner_id = self.partner_portal
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished_product
move.product_uom_qty = 2
move.quantity_done = 2
picking_receipt = picking_form.save()
picking_receipt.action_reset_draft()
picking_receipt.action_confirm()
self.start_tour("/my/productions", 'subcontracting_portal_tour', login="georges1")
@@ -146,8 +146,9 @@ class TestAccountSubcontractingFlows(TestMrpSubcontractingCommon):
picking_form.partner_id = self.subcontractor_partner1
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = todo_nb
move.quantity_done = todo_nb
picking_receipt = picking_form.save()
picking_receipt.action_reset_draft()
# Mimic the extra cost on the po line
picking_receipt.move_ids.price_unit = 50
picking_receipt.action_confirm()
@@ -219,8 +220,9 @@ class TestAccountSubcontractingFlows(TestMrpSubcontractingCommon):
receipt_form.partner_id = self.subcontractor_partner1
with receipt_form.move_ids_without_package.new() as move:
move.product_id = self.finished
move.product_uom_qty = 10
move.quantity_done = 10
receipt = receipt_form.save()
receipt.action_reset_draft()
# add an extra cost
receipt.move_ids.price_unit = 50
receipt.action_confirm()
@@ -22,6 +22,7 @@ class StockPicking(models.Model):
'move_type': 'direct',
'location_id': location_id,
'location_dest_id': location_dest_id,
'state': 'draft',
}
@@ -49,7 +49,9 @@ class TestStockLot(TestStockCommon):
picking_in = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'location_dest_id': self.stock_location
'location_dest_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
})
move_a = self.MoveObj.create({
@@ -145,6 +147,8 @@ class TestStockLot(TestStockCommon):
picking_in = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
move_b = self.MoveObj.create({
@@ -192,6 +196,8 @@ class TestStockLot(TestStockCommon):
picking_in = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
move_c = self.MoveObj.create({
@@ -336,9 +342,8 @@ class TestStockLot(TestStockCommon):
picking_form.picking_type_id = self.env.ref('stock.picking_type_in')
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.apple_product
move.product_uom_qty = 4
move.quantity_done = 4
receipt = picking_form.save()
receipt.action_confirm()
# Defines a date during the receipt.
move = receipt.move_ids_without_package[0]
@@ -346,7 +351,6 @@ class TestStockLot(TestStockCommon):
self.assertEqual(move.use_expiration_date, True)
line.lot_name = 'Apple Box #3'
line.expiration_date = expiration_date
line.qty_done = 4
receipt._action_done()
# Get back the lot created when the picking was done...
+2
View File
@@ -227,6 +227,8 @@ class PurchaseOrder(models.Model):
'location_dest_id': self._get_destination_location(),
'location_id': self.partner_id.property_stock_supplier.id,
'company_id': self.company_id.id,
'state': 'draft',
'immediate_transfer': False,
}
def _create_picking(self):
@@ -97,6 +97,7 @@ class TestAveragePrice(ValuationReconciliationTestCommon):
})
# Assign this outgoing shipment and process the delivery
outgoing_shipment.action_reset_draft()
outgoing_shipment.action_assign()
res = outgoing_shipment.button_validate()
Form(self.env['stock.immediate.transfer'].with_context(res['context'])).save().process()
@@ -273,8 +273,8 @@ class TestCreatePicking(common.TestProductCommon):
'procure_method': 'make_to_order',
'picking_id': customer_picking.id,
})
customer_move._action_confirm()
customer_picking.action_reset_draft()
customer_picking.action_confirm()
purchase_order = self.env['purchase.order'].search([('partner_id', '=', partner.id)])
self.assertTrue(purchase_order, 'No purchase order created.')
@@ -420,7 +420,8 @@ class TestCreatePicking(common.TestProductCommon):
'picking_id': delivery_order.id,
})
customer_move._action_confirm()
delivery_order.action_reset_draft()
delivery_order.action_confirm()
# find created po the product
purchase_order = self.env['purchase.order'].search([('partner_id', '=', partner.id)])
@@ -99,6 +99,7 @@ class TestFifoPrice(ValuationReconciliationTestCommon):
})
# I assign this outgoing shipment
outgoing_shipment.action_reset_draft()
outgoing_shipment.action_assign()
# Process the delivery of the outgoing shipment
@@ -124,6 +125,7 @@ class TestFifoPrice(ValuationReconciliationTestCommon):
})
# I assign this outgoing shipment
outgoing_shipment_uom.action_reset_draft()
outgoing_shipment_uom.action_assign()
# Process the delivery of the outgoing shipment
@@ -184,6 +186,7 @@ class TestFifoPrice(ValuationReconciliationTestCommon):
})
# I assign this outgoing shipment
outgoing_shipment_cur.action_reset_draft()
outgoing_shipment_cur.action_assign()
# Process the delivery of the outgoing shipment
@@ -206,6 +209,7 @@ class TestFifoPrice(ValuationReconciliationTestCommon):
})
# I assign this outgoing shipment
outgoing_shipment_ret.action_reset_draft()
outgoing_shipment_ret.action_assign()
res = outgoing_shipment_ret.button_validate()
Form(self.env[res['res_model']].with_context(res['context'])).save().process()
@@ -52,6 +52,7 @@ class TestMoveCancelPropagation(PurchaseTestCommon):
self.warehouse.write({'delivery_steps': 'ship_only', 'reception_steps': 'one_step'})
self.picking_out.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.move.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.picking_out.action_reset_draft()
self.picking_out.action_confirm()
# Find PO related to picking.
@@ -81,6 +82,7 @@ class TestMoveCancelPropagation(PurchaseTestCommon):
self.warehouse.write({'delivery_steps': 'ship_only', 'reception_steps': 'one_step'})
self.picking_out.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.move.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.picking_out.action_reset_draft()
self.picking_out.action_confirm()
# Find PO related to picking.
@@ -111,6 +113,7 @@ class TestMoveCancelPropagation(PurchaseTestCommon):
self.warehouse.write({'delivery_steps': 'pick_ship', 'reception_steps': 'two_steps'})
self.picking_out.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.move.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.picking_out.action_reset_draft()
self.picking_out.action_confirm()
# Find purchase order related to picking.
@@ -145,6 +148,7 @@ class TestMoveCancelPropagation(PurchaseTestCommon):
self.warehouse.write({'delivery_steps': 'pick_ship', 'reception_steps': 'two_steps'})
self.picking_out.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.move.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.picking_out.action_reset_draft()
self.picking_out.action_confirm()
# Find PO related to picking.
@@ -183,6 +187,7 @@ class TestMoveCancelPropagation(PurchaseTestCommon):
self.warehouse.write({'delivery_steps': 'pick_pack_ship', 'reception_steps': 'three_steps'})
self.picking_out.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.move.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.picking_out.action_reset_draft()
self.picking_out.action_confirm()
# Find PO related to picking.
@@ -219,6 +224,7 @@ class TestMoveCancelPropagation(PurchaseTestCommon):
self.warehouse.write({'delivery_steps': 'pick_pack_ship', 'reception_steps': 'three_steps'})
self.picking_out.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.move.write({'location_id': self.warehouse.out_type_id.default_location_src_id.id})
self.picking_out.action_reset_draft()
self.picking_out.action_confirm()
# Find PO related to picking.
@@ -66,10 +66,8 @@ class TestReorderingRule(TransactionCase):
picking_form.picking_type_id = self.env.ref('stock.picking_type_out')
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.product_01
move.product_uom_qty = 10.0
move.quantity_done = 10.0
customer_picking = picking_form.save()
# picking confirm
customer_picking.action_confirm()
# Run scheduler
self.env['procurement.group'].run_scheduler()
@@ -143,16 +141,15 @@ class TestReorderingRule(TransactionCase):
picking_form.picking_type_id = self.env.ref('stock.picking_type_out')
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.product_01
move.product_uom_qty = 10.0
move.quantity_done = 10.0
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.product_01
move.product_uom_qty = 10.0
move.quantity_done = 10.0
customer_picking = picking_form.save()
customer_picking.move_ids[0].location_id = subloc_1.id
customer_picking.move_ids[1].location_id = subloc_2.id
# picking confirm
customer_picking.action_confirm()
self.assertEqual(self.product_01.with_context(location=subloc_1.id).virtual_available, -10)
self.assertEqual(self.product_01.with_context(location=subloc_2.id).virtual_available, -10)
@@ -305,6 +302,7 @@ class TestReorderingRule(TransactionCase):
move.product_uom_qty = 10.0
customer_picking = picking_form.save()
customer_picking.move_ids.filtered(lambda m: m.product_id == product_buy_mto).procure_method = 'make_to_order'
customer_picking.action_reset_draft()
customer_picking.action_confirm()
self.env['stock.warehouse.orderpoint']._get_orderpoint_action()
self.env['stock.warehouse.orderpoint']._get_orderpoint_action()
@@ -348,6 +346,7 @@ class TestReorderingRule(TransactionCase):
move.product_uom_qty = 10.0
customer_picking = picking_form.save()
customer_picking.move_ids.filtered(lambda m: m.product_id == product_buy_mto).procure_method = 'make_to_order'
customer_picking.action_reset_draft()
customer_picking.action_confirm()
self.env['stock.warehouse.orderpoint'].flush_model()
@@ -403,6 +402,7 @@ class TestReorderingRule(TransactionCase):
move.product_uom_qty = 10.0
customer_picking = picking_form.save()
customer_picking.move_ids.filtered(lambda m: m.product_id == product_buy_mto).procure_method = 'make_to_order'
customer_picking.action_reset_draft()
customer_picking.action_confirm()
self.env['stock.warehouse.orderpoint']._get_orderpoint_action()
orderpoint_product = self.env['stock.warehouse.orderpoint'].search(
@@ -445,6 +445,7 @@ class TestReorderingRule(TransactionCase):
move.product_uom_qty = 10.0
customer_picking = picking_form.save()
customer_picking.move_ids.filtered(lambda m: m.product_id == product_buy_mto).procure_method = 'make_to_order'
customer_picking.action_reset_draft()
customer_picking.action_confirm()
self.env['stock.warehouse.orderpoint'].flush_model()
@@ -959,8 +960,11 @@ class TestReorderingRule(TransactionCase):
'product_uom_qty': 1,
'location_id': warehouse.lot_stock_id.id,
'location_dest_id': self.env.ref('stock.stock_location_customers').id,
})]
})],
'state': 'draft',
'immediate_transfer': False,
})
picking.with_user(user).action_reset_draft()
picking.with_user(user).action_assign()
# check that the PO line quantity has been updated
self.assertEqual(po_line.product_qty, 6, 'The PO line quantity should be 6')
@@ -1624,7 +1624,10 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
'location_id': stock_location.id,
'location_dest_id': customer_location.id,
})],
'state': 'draft',
'immediate_transfer': False,
})
delivery01.action_reset_draft()
delivery01.action_confirm()
delivery01.move_ids._set_quantities_to_reservation()
delivery01.button_validate()
@@ -1695,7 +1698,10 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
'location_id': stock_location.id,
'location_dest_id': customer_location.id,
})],
'state': 'draft',
'immediate_transfer': False,
})
delivery02.action_reset_draft()
delivery02.action_confirm()
delivery02.move_ids._set_quantities_to_reservation()
delivery02.button_validate()
@@ -1748,7 +1754,10 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
'location_id': stock_location.id,
'location_dest_id': customer_location.id,
})],
'state': 'draft',
'immediate_transfer': False,
})
delivery.action_reset_draft()
delivery.action_confirm()
delivery.move_ids._set_quantities_to_reservation()
delivery.button_validate()
@@ -274,6 +274,7 @@ class TestSaleStockMargin(TestStockValuationCommon):
'picking_type_id': incoming_picking_type.id,
'picking_id': picking.id,
})
picking.action_reset_draft()
picking.action_confirm()
res_dict = picking.button_validate()
wizard = Form(self.env[(res_dict.get('res_model'))].with_context(res_dict['context'])).save()
+40
View File
@@ -86,6 +86,8 @@
<field name="scheduled_date" eval="DateTime.today()"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_27').name,
'product_id': ref('product.product_product_27'),
@@ -105,6 +107,8 @@
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=15)"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_6').name,
'product_id': ref('product.product_product_6'),
@@ -124,6 +128,8 @@
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=5)"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_delivery_02').name,
'product_id': ref('product.product_delivery_02'),
@@ -143,6 +149,8 @@
<field name="scheduled_date" eval="DateTime.today()"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_5').name,
'product_id': ref('product.product_product_5'),
@@ -162,6 +170,8 @@
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=7)"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_3').name,
'product_id': ref('product.product_product_3'),
@@ -181,6 +191,8 @@
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=12)"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_3').name,
'product_id': ref('product.product_product_3'),
@@ -200,6 +212,8 @@
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=20)"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_6').name,
'product_id': ref('product.product_product_6'),
@@ -217,6 +231,8 @@
<field name="picking_type_id" ref="stock.picking_type_in"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
<field name="location_dest_id" ref="stock.stock_location_stock"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('stock.product_cable_management_box').name,
'product_id': ref('stock.product_cable_management_box'),
@@ -235,6 +251,8 @@
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=5)"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
<field name="location_dest_id" ref="stock.stock_location_stock"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_delivery_01').name,
'product_id': ref('product.product_delivery_01'),
@@ -252,6 +270,8 @@
<field name="partner_id" ref="base.res_partner_1"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
<field name="location_dest_id" ref="stock.stock_location_stock"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_22').name,
'product_id': ref('product.product_product_22'),
@@ -269,6 +289,8 @@
<field name="partner_id" ref="base.res_partner_1"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
<field name="location_dest_id" ref="stock.stock_location_stock"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_10').name,
'product_id': ref('product.product_product_10'),
@@ -286,6 +308,8 @@
<field name="partner_id" ref="base.res_partner_1"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
<field name="location_dest_id" ref="stock.stock_location_stock"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_delivery_02').name,
'product_id': ref('product.product_delivery_02'),
@@ -305,6 +329,8 @@
<field name="scheduled_date" eval="DateTime.today()"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
<field name="location_dest_id" ref="stock.stock_location_shop0"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="company_id" ref="stock.res_company_1"/>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_9').name,
@@ -324,6 +350,8 @@
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=5)"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
<field name="location_dest_id" ref="stock.stock_location_shop0"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="company_id" ref="stock.res_company_1"/>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_delivery_01').name,
@@ -342,6 +370,8 @@
<field name="picking_type_id" ref="stock.chi_picking_type_in"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
<field name="location_dest_id" ref="stock.stock_location_shop0"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="company_id" ref="stock.res_company_1"/>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_delivery_01').name,
@@ -362,6 +392,8 @@
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=2)"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
<field name="location_dest_id" ref="stock.stock_location_shop0"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="company_id" ref="stock.res_company_1"/>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_22').name,
@@ -383,6 +415,8 @@
<field name="scheduled_date" eval="DateTime.today()"/>
<field name="location_id" ref="stock.stock_location_shop0"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="company_id" ref="stock.res_company_1"/>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_27').name,
@@ -403,6 +437,8 @@
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=10)"/>
<field name="location_id" ref="stock.stock_location_shop0"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="company_id" ref="stock.res_company_1"/>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_6').name,
@@ -423,6 +459,8 @@
<field name="scheduled_date" eval="DateTime.today()"/>
<field name="location_id" ref="stock.stock_location_shop0"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="company_id" ref="stock.res_company_1"/>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_delivery_02').name,
@@ -443,6 +481,8 @@
<field name="scheduled_date" eval="DateTime.today()"/>
<field name="location_id" ref="stock.stock_location_shop0"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
<field name="state">draft</field>
<field name="immediate_transfer">False</field>
<field name="company_id" ref="stock.res_company_1"/>
<field name="move_ids" model="stock.move" eval="[(0, 0, {
'name': obj().env.ref('product.product_product_5').name,
+13 -15
View File
@@ -55,7 +55,7 @@ class StockMove(models.Model):
product_uom_qty = fields.Float(
'Demand',
digits='Product Unit of Measure',
default=1.0, required=True, states={'done': [('readonly', True)]},
default=0, required=True, states={'done': [('readonly', True)]},
help="This is the quantity of products from an inventory "
"point of view. For moves in the state 'done', this is the "
"quantity of products that were actually moved. For other "
@@ -248,7 +248,6 @@ class StockMove(models.Model):
else:
move.show_details_visible = (((consignment_enabled and move.picking_code != 'incoming') or
show_details_visible or move.has_tracking != 'none') and
move._show_details_in_draft() and
move.show_operations is False)
def _compute_show_reserved_availability(self):
@@ -392,7 +391,7 @@ class StockMove(models.Model):
def _process_increase(move, quantity):
moves = move
if move.picking_id.immediate_transfer:
if move.picking_id and move.picking_id.immediate_transfer:
moves = move._action_confirm(merge=False)
# Kits, already handle in action_explode, should be clean in master
if len(moves) > 1:
@@ -681,7 +680,10 @@ Please change the quantity done or the rounding precision of your unit of measur
(self - move_to_unreserve).filtered(lambda m: m.state == 'assigned').write({'state': 'partially_available'})
# When editing the initial demand, directly run again action assign on receipt moves.
receipt_moves_to_reassign |= move_to_unreserve.filtered(lambda m: m.location_id.usage == 'supplier')
receipt_moves_to_reassign |= (self - move_to_unreserve).filtered(lambda m: m.location_id.usage == 'supplier' and m.state in ('partially_available', 'assigned'))
receipt_moves_to_reassign |= (self - move_to_unreserve).filtered(lambda m:
m.location_id.usage == 'supplier'
and m.state in ('partially_available', 'assigned')
and not m.picking_id.immediate_transfer)
move_to_recompute_state |= self - move_to_unreserve - receipt_moves_to_reassign
# propagate product_packaging_id changes in the stock move chain
if 'product_packaging_id' in vals:
@@ -784,7 +786,7 @@ Please change the quantity done or the rounding precision of your unit of measur
show_source_location=self.picking_type_id.code != 'incoming',
show_destination_location=self.picking_type_id.code != 'outgoing',
show_package=not self.location_id.usage == 'supplier',
show_reserved_quantity=self.state != 'done' and not self.picking_id.immediate_transfer and self.picking_type_id.code != 'incoming'
show_reserved_quantity=self.state != 'done' and self.picking_type_id.code != 'incoming'
),
}
@@ -1194,7 +1196,6 @@ Please change the quantity done or the rounding precision of your unit of measur
('location_dest_id', '=', self.location_dest_id.id),
('picking_type_id', '=', self.picking_type_id.id),
('printed', '=', False),
('immediate_transfer', '=', False),
('state', 'in', ['draft', 'confirmed', 'waiting', 'partially_available', 'assigned'])]
if self.partner_id and (self.location_id.usage == 'transit' or self.location_dest_id.usage == 'transit'):
domain += [('partner_id', '=', self.partner_id.id)]
@@ -1328,6 +1329,8 @@ Please change the quantity done or the rounding precision of your unit of measur
'picking_type_id': self.mapped('picking_type_id').id,
'location_id': self.mapped('location_id').id,
'location_dest_id': self.mapped('location_dest_id').id,
'state': 'draft',
'immediate_transfer': False,
}
def _should_be_assigned(self):
@@ -1408,8 +1411,7 @@ Please change the quantity done or the rounding precision of your unit of measur
neg_r_moves._assign_picking()
# call `_action_assign` on every confirmed move which location_id bypasses the reservation + those expected to be auto-assigned
moves.filtered(lambda move: not move.picking_id.immediate_transfer
and move.state in ('confirmed', 'partially_available')
moves.filtered(lambda move: move.state in ('confirmed', 'partially_available')
and (move._should_bypass_reservation()
or move.picking_type_id.reservation_method == 'at_confirm'
or (move.reservation_date and move.reservation_date <= fields.Date.today())))\
@@ -1676,7 +1678,7 @@ Please change the quantity done or the rounding precision of your unit of measur
assigned_moves_ids.add(move.id)
moves_to_redirect.add(move.id)
else:
if float_is_zero(move.product_uom_qty, precision_rounding=move.product_uom.rounding):
if float_is_zero(move.product_uom_qty, precision_rounding=move.product_uom.rounding) and not force_qty:
assigned_moves_ids.add(move.id)
elif not move.move_orig_ids:
if move.procure_method == 'make_to_order':
@@ -1876,8 +1878,8 @@ Please change the quantity done or the rounding precision of your unit of measur
@api.ondelete(at_uninstall=False)
def _unlink_if_draft_or_cancel(self):
if any(move.state not in ('draft', 'cancel') for move in self):
raise UserError(_('You can only delete draft or cancelled moves.'))
if any(move.state not in ('draft', 'cancel') and (move.move_orig_ids or move.move_dest_ids) for move in self):
raise UserError(_('You can not delete moves linked to another operation'))
def unlink(self):
# With the non plannified picking, draft moves could have some move lines.
@@ -2112,10 +2114,6 @@ Please change the quantity done or the rounding precision of your unit of measur
else:
move.procure_method = 'make_to_order'
def _show_details_in_draft(self):
self.ensure_one()
return self.state != 'draft' or (self.picking_id.immediate_transfer and self.state == 'draft')
def _trigger_scheduler(self):
""" Check for auto-triggered orderpoints and trigger them. """
if not self or self.env['ir.config_parameter'].sudo().get_param('stock.no_auto_scheduler'):
+33 -30
View File
@@ -313,7 +313,7 @@ class Picking(models.Model):
('assigned', 'Ready'),
('done', 'Done'),
('cancel', 'Cancelled'),
], string='Status', compute='_compute_state',
], string='Status', compute='_compute_state', default='assigned',
copy=False, index=True, readonly=True, store=True, tracking=True,
help=" * Draft: The transfer is not confirmed yet. Reservation doesn't apply.\n"
" * Waiting another operation: This transfer is waiting for another operation before being ready.\n"
@@ -365,8 +365,7 @@ class Picking(models.Model):
picking_type_id = fields.Many2one(
'stock.picking.type', 'Operation Type',
required=True, readonly=True, index=True,
default=_default_picking_type_id,
states={'draft': [('readonly', False)]})
default=_default_picking_type_id)
picking_type_code = fields.Selection(
related='picking_type_id.code',
readonly=True)
@@ -400,9 +399,6 @@ class Picking(models.Model):
show_check_availability = fields.Boolean(
compute='_compute_show_check_availability',
help='Technical field used to compute whether the button "Check Availability" should be displayed.')
show_mark_as_todo = fields.Boolean(
compute='_compute_show_mark_as_todo',
help='Technical field used to compute whether the button "Mark as Todo" should be displayed.')
show_validate = fields.Boolean(
compute='_compute_show_validate',
help='Technical field used to decide whether the button "Validate" should be displayed.')
@@ -426,7 +422,7 @@ class Picking(models.Model):
show_reserved = fields.Boolean(related='picking_type_id.show_reserved')
show_lots_text = fields.Boolean(compute='_compute_show_lots_text')
has_tracking = fields.Boolean(compute='_compute_has_tracking')
immediate_transfer = fields.Boolean(default=False)
immediate_transfer = fields.Boolean(default=True)
package_level_ids = fields.One2many('stock.package_level', 'picking_id')
package_level_ids_details = fields.One2many('stock.package_level', 'picking_id')
products_availability = fields.Char(
@@ -443,14 +439,14 @@ class Picking(models.Model):
('name_uniq', 'unique(name, company_id)', 'Reference must be unique per company!'),
]
@api.depends('show_validate', 'immediate_transfer',
@api.depends('show_validate',
'move_ids.reserved_availability',
'move_ids.quantity_done')
def _compute_show_qty_button(self):
self.show_set_qty_button = False
self.show_clear_qty_button = False
for picking in self:
if not picking.show_validate or picking.immediate_transfer:
if not picking.show_validate:
continue
if any(float_is_zero(m.quantity_done, precision_rounding=m.product_uom.rounding) and not float_is_zero(m.reserved_availability, precision_rounding=m.product_uom.rounding) for m in picking.move_ids):
picking.show_set_qty_button = True
@@ -511,7 +507,7 @@ class Picking(models.Model):
picking.show_operations = True
continue
if picking.picking_type_id.show_operations:
if (picking.state == 'draft' and picking.immediate_transfer) or picking.state != 'draft':
if (picking.state == 'draft') or picking.state != 'draft':
picking.show_operations = True
else:
picking.show_operations = False
@@ -545,7 +541,7 @@ class Picking(models.Model):
]
})
@api.depends('move_type', 'immediate_transfer', 'move_ids.state', 'move_ids.picking_id')
@api.depends('move_type', 'move_ids.state', 'move_ids.picking_id')
def _compute_state(self):
''' State of a picking depends on the state of its related stock.move
- Draft: only used for "planned pickings"
@@ -574,7 +570,9 @@ class Picking(models.Model):
picking_move_lines[picking_id.id].add(move.id)
for picking in self:
picking_id = (picking.ids and picking.ids[0]) or picking.id
if not picking_moves_state_map[picking_id]:
if not picking_moves_state_map[picking_id] and picking.immediate_transfer:
continue
elif not picking_moves_state_map[picking_id]:
picking.state = 'draft'
elif picking_moves_state_map[picking_id]['any_draft']:
picking.state = 'draft'
@@ -633,13 +631,13 @@ class Picking(models.Model):
for picking in self:
picking.has_packages = bool(cnt_by_picking.get(picking.id, False))
@api.depends('immediate_transfer', 'state')
@api.depends('state')
def _compute_show_check_availability(self):
""" According to `picking.show_check_availability`, the "check availability" button will be
displayed in the form view of a picking.
"""
for picking in self:
if picking.immediate_transfer or picking.state not in ('confirmed', 'waiting', 'assigned'):
if picking.state not in ('confirmed', 'waiting', 'assigned'):
picking.show_check_availability = False
continue
picking.show_check_availability = any(
@@ -648,24 +646,15 @@ class Picking(models.Model):
for move in picking.move_ids
)
@api.depends('state', 'move_ids')
def _compute_show_mark_as_todo(self):
for picking in self:
if picking.immediate_transfer or picking.state != 'draft':
picking.show_mark_as_todo = False
else:
picking.show_mark_as_todo = True
@api.depends('state')
def _compute_show_validate(self):
for picking in self:
if not (picking.immediate_transfer) and picking.state == 'draft':
if picking.state == 'draft':
picking.show_validate = False
elif picking.state not in ('draft', 'waiting', 'confirmed', 'assigned'):
picking.show_validate = False
else:
picking.show_validate = True
@api.depends('state', 'move_ids', 'picking_type_id')
def _compute_show_allocation(self):
self.show_allocation = False
@@ -678,7 +667,7 @@ class Picking(models.Model):
def _compute_location_id(self):
for picking in self:
picking = picking.with_company(picking.company_id)
if picking.picking_type_id and picking.state == 'draft':
if picking.picking_type_id:
if picking.picking_type_id.default_location_src_id:
location_id = picking.picking_type_id.default_location_src_id.id
elif picking.partner_id:
@@ -776,6 +765,12 @@ class Picking(models.Model):
# order to get a determinist execution of `_set_scheduled_date`
scheduled_dates.append(vals.pop('scheduled_date', False))
# immediate transfer is a default value allow in specific cases (interface only)
if vals.get('state', 'assigned') != 'assigned':
vals['immediate_transfer'] = False
if self.env['ir.config_parameter'].sudo().get_param('stock.no_default_immediate_tranfer'):
vals['immediate_transfer'] = False
pickings = super().create(vals_list)
for picking, scheduled_date in zip(pickings, scheduled_dates):
@@ -842,6 +837,8 @@ class Picking(models.Model):
def action_confirm(self):
self._check_company()
if not self.env.context.get('skip_draft'):
self.filtered(lambda p: p.state in ['assigned', 'draft'] and p.immediate_transfer).action_reset_draft()
self.mapped('package_level_ids').filtered(lambda pl: pl.state == 'draft' and not pl.move_ids)._generate_moves()
# call `_action_confirm` on every draft move
self.move_ids.filtered(lambda move: move.state == 'draft')._action_confirm()
@@ -856,6 +853,7 @@ class Picking(models.Model):
also impact the state of the picking as it is computed based on move's states.
@return: True
"""
self.mapped('package_level_ids').filtered(lambda pl: pl.state == 'draft' and not pl.move_ids)._generate_moves()
self.filtered(lambda picking: picking.state == 'draft').action_confirm()
moves = self.move_ids.filtered(lambda move: move.state not in ('draft', 'cancel', 'done')).sorted(
key=lambda move: (-int(move.priority), not bool(move.date_deadline), move.date_deadline, move.date, move.id)
@@ -877,6 +875,13 @@ class Picking(models.Model):
self.filtered(lambda x: not x.move_ids).state = 'cancel'
return True
def action_reset_draft(self):
picking_to_reset = self.filtered(lambda p: p.state not in ('done', 'cancel'))
picking_to_reset.do_unreserve()
picking_to_reset.immediate_transfer = False
picking_to_reset.move_ids.quantity_done = 0
picking_to_reset.move_ids.state = 'draft'
def _action_done(self):
"""Call `_action_done` on the `stock.move` of the `stock.picking` in `self`.
This method makes sure every `stock.move.line` is linked to a `stock.move` by either
@@ -936,7 +941,7 @@ class Picking(models.Model):
else:
for move in self.move_ids:
if not move.package_level_id:
if move.state == 'assigned' and move.picking_id and not move.picking_id.immediate_transfer or move.state == 'done':
if move.state == 'assigned' and move.picking_id or move.state == 'done':
if any(not ml.package_level_id for ml in move.move_line_ids):
move_ids_without_package |= move
else:
@@ -1223,9 +1228,8 @@ class Picking(models.Model):
continue
if not picking.move_ids and not picking.package_level_ids:
continue
if picking.immediate_transfer or any(move.additional for move in picking.move_ids):
picking.action_confirm()
# Make sure the reservation is bypassed in immediate transfer mode.
if any(move.additional for move in picking.move_ids):
picking.with_context(skip_draft=picking.immediate_transfer).action_confirm()
if picking.immediate_transfer:
picking.move_ids.write({'state': 'assigned'})
@@ -1498,7 +1502,6 @@ class Picking(models.Model):
picking_move_lines = self.move_line_ids
if (
not self.picking_type_id.show_reserved
and not self.immediate_transfer
and not self.env.context.get('barcode_view')
):
picking_move_lines = self.move_line_nosuggest_ids
@@ -507,6 +507,8 @@ class StockGenerate(StockGenerateCommon):
'picking_type_id': self.warehouse.in_type_id.id,
'location_id': self.env.ref('stock.stock_location_suppliers').id,
'location_dest_id': stock_location.id,
'state': 'draft',
'immediate_transfer': False,
})
move = self.env['stock.move'].create({
'name': self.product_serial.name,
+92 -12
View File
@@ -2670,6 +2670,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.pack_location.id,
'picking_type_id': self.env.ref('stock.picking_type_internal').id,
'state': 'draft',
'immediate_transfer': False,
})
move_stock_pack = self.env['stock.move'].create({
'name': 'test_link_assign_7',
@@ -2684,6 +2686,8 @@ class StockMove(TransactionCase):
'location_id': self.pack_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move_pack_cust = self.env['stock.move'].create({
'name': 'test_link_assign_7',
@@ -2783,6 +2787,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.pack_location.id,
'picking_type_id': self.env.ref('stock.picking_type_internal').id,
'state': 'draft',
'immediate_transfer': False,
})
move_stock_pack = self.env['stock.move'].create({
'name': 'test_link_assign_7',
@@ -2797,6 +2803,8 @@ class StockMove(TransactionCase):
'location_id': self.pack_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move_pack_cust = self.env['stock.move'].create({
'name': 'test_link_assign_7',
@@ -2850,6 +2858,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.pack_location.id,
'picking_type_id': self.env.ref('stock.picking_type_internal').id,
'state': 'draft',
'immediate_transfer': False,
})
move_stock_pack = self.env['stock.move'].create({
'name': 'test_link_assign_9',
@@ -2864,6 +2874,8 @@ class StockMove(TransactionCase):
'location_id': self.pack_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move_pack_cust = self.env['stock.move'].create({
'name': 'test_link_assign_0',
@@ -3216,6 +3228,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.customer_location.id,
'partner_id': customer.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
p01_move = self.env['stock.move'].create({
@@ -4062,6 +4076,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.stock_location.id,
'partner_id': owner.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'state': 'draft',
'immediate_transfer': False,
})
# move from shelf1
move1 = self.env['stock.move'].create({
@@ -4213,6 +4229,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.stock_location.id,
'partner_id': partner.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': 'test_immediate_validate_1',
@@ -4245,6 +4263,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.customer_location.id,
'partner_id': partner.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': 'test_immediate_validate_2',
@@ -4292,6 +4312,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.pack_location.id,
'picking_type_id': self.env.ref('stock.picking_type_internal').id,
'state': 'draft',
'immediate_transfer': False,
})
product1_move = self.env['stock.move'].create({
'name': 'product1_move',
@@ -4349,6 +4371,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.customer_location.id,
'partner_id': partner.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
# move from shelf1
self.env['stock.move'].create({
@@ -4382,6 +4406,8 @@ class StockMove(TransactionCase):
'location_id': self.supplier_location.id,
'location_dest_id': self.stock_location.id,
'picking_type_id': picking_type_id.id,
'immediate_transfer': False,
'state': 'draft',
})
self.env['stock.move'].create({
'name': 'move1',
@@ -4437,6 +4463,8 @@ class StockMove(TransactionCase):
'location_id': self.supplier_location.id,
'location_dest_id': self.stock_location.id,
'picking_type_id': picking_type.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': 'product1_move',
@@ -4481,6 +4509,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.customer_location.id,
'partner_id': partner.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': 'test_immediate_validate_2',
@@ -4514,6 +4544,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.stock_location.id,
'partner_id': partner.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': 'test_immediate_validate_8_1',
@@ -4530,6 +4562,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.stock_location.id,
'partner_id': partner.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': 'test_immediate_validate_8_2',
@@ -4546,6 +4580,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.stock_location.id,
'partner_id': partner.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': 'test_immediate_validate_8_3',
@@ -4584,8 +4620,12 @@ class StockMove(TransactionCase):
picking_type_receipt.use_create_lots = False
picking_type_receipt.use_existing_lots = False
picking_form = Form(self.env['stock.picking'])
picking_form.picking_type_id = picking_type_receipt
internal_transfer = self.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': picking_type_receipt.id,
})
picking_form = Form(internal_transfer)
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.product_serial
move.product_uom_qty = 4
@@ -4617,8 +4657,12 @@ class StockMove(TransactionCase):
'company_id': self.env.company.id,
})
self.env['stock.quant']._update_available_quantity(self.product_lot, self.stock_location, 10, lot_id=lot)
picking_form = Form(self.env['stock.picking'])
picking_form.picking_type_id = picking_type_internal
internal_transfer = self.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': picking_type_internal.id,
})
picking_form = Form(internal_transfer)
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.product_lot
move.product_uom_qty = 4
@@ -4666,7 +4710,7 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
})
self.assertEqual(move1.state, 'draft')
self.assertEqual(move1.product_uom_qty, 1)
self.assertEqual(move1.product_uom_qty, 0)
move1.product_uom_qty = 100
move1.product_id = self.product_serial
move1._onchange_product_id()
@@ -4748,6 +4792,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.customer_location.id,
'partner_id': partner.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': 'A move to confirm and scrap its product',
@@ -4793,6 +4839,8 @@ class StockMove(TransactionCase):
'location_dest_id': self.customer_location.id,
'partner_id': partner.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': 'A move to confirm and scrap its product',
@@ -4896,6 +4944,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': scrap_location.id,
'picking_type_id': internal_operation.id,
'state': 'draft',
'immediate_transfer': False,
'move_ids': [(0, 0, {
'name': 'Scrap %s' % product.display_name,
'location_id': self.stock_location.id,
@@ -5241,7 +5291,6 @@ class StockMove(TransactionCase):
'location_id': self.supplier_location.id,
'location_dest_id': self.stock_location.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'immediate_transfer': True,
})
move1 = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -5266,6 +5315,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -5360,6 +5411,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -5402,6 +5455,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -5445,6 +5500,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -5492,6 +5549,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -5557,8 +5616,12 @@ class StockMove(TransactionCase):
}]).action_apply_inventory()
# Creates a delivery for a bunch of products.
delivery_form = Form(self.env['stock.picking'])
delivery_form.picking_type_id = self.env.ref('stock.picking_type_out')
delivery_form = self.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
})
delivery_form = Form(delivery_form)
with delivery_form.move_ids_without_package.new() as move:
move.product_id = self.product
move.product_uom_qty = 10
@@ -5681,6 +5744,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -5736,6 +5801,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -5780,6 +5847,8 @@ class StockMove(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -5893,7 +5962,10 @@ class StockMove(TransactionCase):
picking_out = self.env['stock.picking'].create({
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id})
'location_dest_id': self.customer_location.id,
'state': 'draft',
'immediate_transfer': False,
})
move = self.env['stock.move'].create({
'name': product.name,
'product_id': product.id,
@@ -5928,6 +6000,8 @@ class StockMove(TransactionCase):
'picking_type_id': internal_transfer.id,
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': self.product_consu.name,
@@ -6012,6 +6086,8 @@ class StockMove(TransactionCase):
'picking_type_id': internal_transfer.id,
'location_id': stock_location.id,
'location_dest_id': shelf_location.id,
'state': 'draft',
'immediate_transfer': False,
'move_line_nosuggest_ids': [Command.create({
'product_id': self.product.id,
'qty_done': 1.0
@@ -6047,7 +6123,7 @@ class StockMove(TransactionCase):
"""
Since updating the move's `lot_ids` field for product tracked by serial numbers will
also updates the move's `quantity_done`, this test checks the move's move lines will be
correclty updated and consequently its picking can be validated.
correctly updated and consequently its picking can be validated.
"""
sn = self.env['stock.lot'].create({
'name': 'test_lot_001',
@@ -6055,8 +6131,12 @@ class StockMove(TransactionCase):
'company_id': self.env.company.id,
})
picking_form = Form(self.env['stock.picking'])
picking_form.picking_type_id = self.env.ref('stock.picking_type_in')
internal_transfer = self.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
})
picking_form = Form(internal_transfer)
with picking_form.move_ids_without_package.new() as move:
move.product_id = self.product_serial
move.product_uom_qty = 1
+99 -35
View File
@@ -18,6 +18,8 @@ class TestPickShip(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
dest = self.MoveObj.create({
@@ -36,6 +38,8 @@ class TestPickShip(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.pack_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
@@ -56,6 +60,8 @@ class TestPickShip(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
ship = self.MoveObj.create({
@@ -72,6 +78,8 @@ class TestPickShip(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.pack_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
pack = self.MoveObj.create({
@@ -89,6 +97,8 @@ class TestPickShip(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.pack_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
@@ -386,6 +396,8 @@ class TestPickShip(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
dest = self.MoveObj.create({
'name': self.gB.name,
@@ -402,6 +414,8 @@ class TestPickShip(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.pack_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
@@ -817,6 +831,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -857,6 +873,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -895,6 +913,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -939,6 +959,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -986,6 +1008,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
# Avoid to merge move3 and move4 for the test case
self.env['ir.config_parameter'].create({
@@ -1073,6 +1097,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.MoveObj.create({
'name': self.productA.name,
@@ -1118,6 +1144,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.MoveObj.create({
'name': self.productA.name,
@@ -1162,6 +1190,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.supplier_location,
'location_dest_id': self.stock_location,
'picking_type_id': self.picking_type_in,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.MoveObj.create({
'name': self.productA.name,
@@ -1200,6 +1230,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -1244,6 +1276,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
product = self.kgB
self.MoveObj.create({
@@ -1277,6 +1311,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.MoveObj.create({
'name': self.productA.name,
@@ -1331,6 +1367,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.MoveObj.create({
'name': self.productA.name,
@@ -1389,6 +1427,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.MoveObj.create({
'name': self.productA.name,
@@ -1449,6 +1489,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.MoveObj.create({
'name': self.productA.name,
@@ -1504,6 +1546,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -1537,6 +1581,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -1577,6 +1623,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -1617,6 +1665,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -1661,6 +1711,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.supplier_location,
'location_dest_id': self.stock_location,
'picking_type_id': self.picking_type_in,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -1708,6 +1760,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.supplier_location,
'location_dest_id': self.stock_location,
'picking_type_id': self.picking_type_in,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -1753,6 +1807,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.supplier_location,
'location_dest_id': self.stock_location,
'picking_type_id': self.picking_type_in,
'state': 'draft',
'immediate_transfer': False,
})
move_1 = self.MoveObj.create({
'name': self.productA.name,
@@ -1795,6 +1851,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.supplier_location,
'location_dest_id': warehouse.wh_input_stock_loc_id.id,
'picking_type_id': warehouse.in_type_id.id,
'state': 'draft',
'immediate_transfer': False,
})
move_receipt_1 = self.MoveObj.create({
'name': self.productA.name,
@@ -1809,6 +1867,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.supplier_location,
'location_dest_id': warehouse.wh_input_stock_loc_id.id,
'picking_type_id': warehouse.in_type_id.id,
'state': 'draft',
'immediate_transfer': False,
})
move_receipt_2 = self.MoveObj.create({
'name': self.productA.name,
@@ -1855,6 +1915,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.supplier_location,
'location_dest_id': warehouse.wh_input_stock_loc_id.id,
'picking_type_id': warehouse.in_type_id.id,
'state': 'draft',
'immediate_transfer': False,
})
move_receipt_1 = self.MoveObj.create({
'name': self.productA.name,
@@ -1869,6 +1931,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': warehouse.wh_input_stock_loc_id.id,
'location_dest_id': warehouse.wh_qc_stock_loc_id.id,
'picking_type_id': warehouse.int_type_id.id,
'state': 'draft',
'immediate_transfer': False,
})
move1_receipt_2 = self.MoveObj.create({
'name': self.productB.name,
@@ -1913,6 +1977,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -1947,6 +2013,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
move_a = self.MoveObj.create({
'name': self.productA.name,
@@ -1982,10 +2050,10 @@ class TestSinglePicking(TestStockCommon):
picking.picking_type_id = ptout
with picking.move_ids_without_package.new() as move:
move.product_id = self.productA
move.product_uom_qty = 10
move.quantity_done = 10
picking = picking.save()
self.assertEqual(picking.immediate_transfer, False)
self.assertEqual(picking.state, 'draft')
self.assertEqual(picking.immediate_transfer, True)
self.assertEqual(picking.state, 'assigned')
picking = Form(picking)
picking.move_ids_without_package.remove(0)
@@ -2001,6 +2069,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.supplier_location,
'location_dest_id': self.stock_location,
'picking_type_id': self.picking_type_in,
'state': 'draft',
'immediate_transfer': False,
})
move_1 = self.MoveObj.create({
'name': self.productA.name,
@@ -2033,6 +2103,8 @@ class TestSinglePicking(TestStockCommon):
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'move_type': 'one',
'state': 'draft',
'immediate_transfer': False,
})
move_3 = self.MoveObj.create({
'name': self.productA.name,
@@ -2056,13 +2128,11 @@ class TestSinglePicking(TestStockCommon):
# The autocoform ran, the picking shoud be confirmed and reservable.
self.assertEqual(delivery_order.state, 'confirmed')
self.assertEqual(delivery_order.show_mark_as_todo, False)
self.assertEqual(delivery_order.show_check_availability, True)
delivery_order.action_assign()
self.assertEqual(delivery_order.state, 'assigned')
self.assertEqual(delivery_order.show_check_availability, False)
self.assertEqual(delivery_order.show_mark_as_todo, False)
stock_location = self.env['stock.location'].browse(self.stock_location)
self.assertEqual(self.env['stock.quant']._gather(self.productA, stock_location).reserved_quantity, 10.0)
@@ -2077,7 +2147,6 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'immediate_transfer': True,
'move_ids_without_package': [(0, 0, {
'name': self.productA.name,
'product_id': self.productA.id,
@@ -2097,7 +2166,6 @@ class TestSinglePicking(TestStockCommon):
self.assertEqual(delivery_order.state, 'assigned')
self.assertEqual(delivery_order.show_check_availability, False)
self.assertEqual(delivery_order.show_mark_as_todo, False)
def test_owner_1(self):
# Required for `owner_id` to be visible in the view
@@ -2108,6 +2176,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.supplier_location,
'location_dest_id': self.stock_location,
'picking_type_id': self.picking_type_in,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
'name': self.productA.name,
@@ -2180,7 +2250,7 @@ class TestSinglePicking(TestStockCommon):
# Checks receipt has still its destination location and checks its move
# line took the one from the putaway rule.
self.assertEqual(receipt.location_dest_id.id, stock_location.id)
self.assertEqual(receipt.move_line_ids.location_dest_id.id, shelf_location.id)
self.assertEqual(receipt.move_line_nosuggest_ids.location_dest_id.id, shelf_location.id)
def test_cancel_plan_transfer(self):
""" Test canceling plan transfer """
@@ -2189,6 +2259,8 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
'move_ids': [(0, 0, {
'name': self.productA.name,
'product_id': self.productA.id,
@@ -2214,7 +2286,6 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'immediate_transfer': True,
'move_line_ids': [(0, 0, {
'product_id': self.productA.id,
'qty_done': 10,
@@ -2236,7 +2307,6 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.supplier_location,
'location_dest_id': self.stock_location,
'picking_type_id': self.picking_type_in,
'immediate_transfer': True,
'move_line_ids': [(0, 0, {
'product_id': self.productA.id,
'product_uom_id': self.productA.uom_id.id,
@@ -2287,7 +2357,9 @@ class TestStockUOM(TestStockCommon):
picking_in = self.env['stock.picking'].create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'location_dest_id': self.stock_location
'location_dest_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
})
move = self.env['stock.move'].create({
'name': 'First move with 60 GT',
@@ -2355,6 +2427,8 @@ class TestStockUOM(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move = self.env['stock.move'].create({
@@ -3237,6 +3311,8 @@ class TestAutoAssign(TestStockCommon):
'location_id': self.pack_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
dest = self.MoveObj.create({
@@ -3255,6 +3331,8 @@ class TestAutoAssign(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.pack_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
@@ -3284,6 +3362,8 @@ class TestAutoAssign(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
customer_move = self.env['stock.move'].create({
'name': 'customer move',
@@ -3305,6 +3385,8 @@ class TestAutoAssign(TestStockCommon):
'location_id': self.customer_location,
'location_dest_id': self.stock_location,
'picking_type_id': self.picking_type_in,
'state': 'draft',
'immediate_transfer': False,
})
supplier_move = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -3342,6 +3424,8 @@ class TestAutoAssign(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.pack_location,
'picking_type_id': self.picking_type_out,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -3390,6 +3474,8 @@ class TestAutoAssign(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location,
'picking_type_id': picking_type_out1.id,
'state': 'draft',
'immediate_transfer': False,
})
# 'by_date' picking w/ 1 day before scheduled date auto-assign setting, set to 5 days in advance => shouldn't auto-assign
@@ -3450,6 +3536,8 @@ class TestAutoAssign(TestStockCommon):
'location_id': self.customer_location,
'location_dest_id': self.stock_location,
'picking_type_id': self.picking_type_in,
'state': 'draft',
'immediate_transfer': False,
})
supplier_move = self.env['stock.move'].create({
'name': 'test_transit_1',
@@ -3529,27 +3617,3 @@ class TestAutoAssign(TestStockCommon):
move.lot_ids = [(4, lot2.id)]
move.lot_ids = [(4, lot3.id)]
self.assertEqual(move.quantity_done, 3.0/12.0)
def test_update_description(self):
""" Create an empty picking. Adds a move on product1, select the picking type, add
again a move on product1. Confirm the picking. The two stock moves should be merged. """
product1 = self.env['product.product'].create({
'name': 'product',
'type':'product',
})
picking_form = Form(self.env['stock.picking'])
with picking_form.move_ids_without_package.new() as move:
move.product_id = product1
move.product_uom_qty = 10
move.location_id = self.env.ref('stock.stock_location_suppliers')
move.location_dest_id = self.env.ref('stock.stock_location_stock')
picking_form.picking_type_id = self.env.ref('stock.picking_type_in')
with picking_form.move_ids_without_package.new() as move:
move.product_id = product1
move.product_uom_qty = 15
picking = picking_form.save()
picking.action_confirm()
self.assertEqual(len(picking.move_ids), 1)
self.assertEqual(picking.move_ids.product_uom_qty, 25)
+4
View File
@@ -196,6 +196,8 @@ class TestMultiCompany(TransactionCase):
'picking_type_id': self.warehouse_a.in_type_id.id,
'location_id': self.env.ref('stock.stock_location_suppliers').id,
'location_dest_id': self.stock_location_a.id,
'state': 'draft',
'immediate_transfer': False,
})
self.assertEqual(picking.company_id, self.company_a)
move1 = self.env['stock.move'].create({
@@ -555,6 +557,8 @@ class TestMultiCompany(TransactionCase):
'picking_type_id': self.warehouse_a.out_type_id.id,
'location_id': self.stock_location_a.id,
'location_dest_id': customer_location.id,
'state': 'draft',
'immediate_transfer': False,
})
move_wha_to_cus = self.env['stock.move'].create({
'name': "WH_A to Customer",
+66 -28
View File
@@ -158,6 +158,7 @@ class TestPacking(TestPackingCommon):
'location_id': self.stock_location.id,
'location_dest_id': self.stock_location.id,
'state': 'draft',
'immediate_transfer': False,
})
picking.picking_type_id.show_entire_packs = True
package_level = self.env['stock.package_level'].create({
@@ -183,6 +184,7 @@ class TestPacking(TestPackingCommon):
'location_id': self.stock_location.id,
'location_dest_id': self.stock_location.id,
'state': 'draft',
'immediate_transfer': False,
})
picking.picking_type_id.show_entire_packs = True
package_level = self.env['stock.package_level'].create({
@@ -224,6 +226,7 @@ class TestPacking(TestPackingCommon):
'location_id': self.stock_location.id,
'location_dest_id': self.stock_location.id,
'state': 'draft',
'immediate_transfer': False,
})
package_level = self.env['stock.package_level'].create({
'package_id': pack.id,
@@ -275,6 +278,7 @@ class TestPacking(TestPackingCommon):
'location_id': self.customer_location.id,
'location_dest_id': self.stock_location.id,
'state': 'draft',
'immediate_transfer': False,
})
ship_move_a = self.env['stock.move'].create({
'name': 'move 1',
@@ -363,6 +367,7 @@ class TestPacking(TestPackingCommon):
**location_dict,
**{
'picking_type_id': self.warehouse.in_type_id.id,
'immediate_transfer': False,
'move_ids': [(6, 0, [move.id])],
}})
@@ -392,6 +397,7 @@ class TestPacking(TestPackingCommon):
'location_id': self.stock_location.id,
'location_dest_id': self.stock_location.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move.line'].create({
'location_id': self.stock_location.id,
@@ -464,11 +470,12 @@ class TestPacking(TestPackingCommon):
# Add 2 lines
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productA
move_line.product_uom_qty = 1
move_line.quantity_done = 1
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productB
move_line.product_uom_qty = 1
move_line.quantity_done = 1
receipt = receipt_form.save()
receipt.action_reset_draft()
receipt.action_confirm()
# Adds quantities then packs them and valids the receipt.
@@ -521,8 +528,12 @@ class TestPacking(TestPackingCommon):
# ...
# if self.env.context.get('force_detailed_view'):
# picking.show_operations = True
internal_form = Form(self.env['stock.picking'].with_context(force_detailed_view=True))
internal_form.picking_type_id = self.warehouse.int_type_id
picking = self.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': self.warehouse.int_type_id.id,
})
internal_form = Form(picking.with_context(force_detailed_view=True))
# The test specifically removes the ability to see the location fields
# grp_multi_loc = self.env.ref('stock.group_stock_multi_locations')
# self.env.user.write({'groups_id': [(3, grp_multi_loc.id)]})
@@ -611,11 +622,12 @@ class TestPacking(TestPackingCommon):
# Add 2 lines
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productA
move_line.product_uom_qty = 1
move_line.quantity_done = 1
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productB
move_line.product_uom_qty = 1
move_line.quantity_done = 1
receipt = receipt_form.save()
receipt.action_reset_draft()
receipt.action_confirm()
# Adds quantities then packs them and valids the receipt.
@@ -668,8 +680,12 @@ class TestPacking(TestPackingCommon):
# ...
# if self.env.context.get('force_detailed_view'):
# picking.show_operations = True
internal_form = Form(self.env['stock.picking'].with_context(force_detailed_view=True))
internal_form.picking_type_id = self.warehouse.int_type_id
picking = self.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': self.warehouse.int_type_id.id,
})
internal_form = Form(picking.with_context(force_detailed_view=True))
# The test specifically removes the ability to see the location fields
# grp_multi_loc = self.env.ref('stock.group_stock_multi_locations')
# self.env.user.write({'groups_id': [(3, grp_multi_loc.id)]})
@@ -758,8 +774,12 @@ class TestPacking(TestPackingCommon):
dest_package1 = self.env["stock.quant.package"].create({"name": "Dest Pack1"})
# Create new picking: 120 productA
picking_form = Form(self.env['stock.picking'])
picking_form.picking_type_id = self.warehouse.pick_type_id
picking = self.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': self.warehouse.pick_type_id.id,
})
picking_form = Form(picking)
with picking_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productA
move_line.product_uom_qty = 120
@@ -819,6 +839,8 @@ class TestPacking(TestPackingCommon):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.warehouse.out_type_id.id,
'state': 'draft',
'immediate_transfer': False,
})
with Form(picking) as picking_form:
with picking_form.move_ids_without_package.new() as move:
@@ -863,6 +885,8 @@ class TestPacking(TestPackingCommon):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
'picking_type_id': self.warehouse.out_type_id.id,
'state': 'draft',
'immediate_transfer': False,
})
with Form(picking) as picking_form:
with picking_form.move_ids_without_package.new() as move:
@@ -882,35 +906,35 @@ class TestPacking(TestPackingCommon):
self.assertEqual(len(picking.move_ids), 1, 'Should have only 1 stock move')
def test_picking_state_with_null_qty(self):
receipt_form = Form(self.env['stock.picking'].with_context(default_immediate_transfer=False))
delivery_form = Form(self.env['stock.picking'])
picking_type_id = self.warehouse.out_type_id
receipt_form.picking_type_id = picking_type_id
with receipt_form.move_ids_without_package.new() as move_line:
delivery_form.picking_type_id = picking_type_id
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productA
move_line.product_uom_qty = 10
with receipt_form.move_ids_without_package.new() as move_line:
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productB
move_line.product_uom_qty = 10
receipt = receipt_form.save()
receipt.action_confirm()
self.assertEqual(receipt.state, 'confirmed')
receipt.move_ids_without_package[1].product_uom_qty = 0
self.assertEqual(receipt.state, 'confirmed')
delivery = delivery_form.save()
delivery.action_reset_draft()
delivery.action_confirm()
self.assertEqual(delivery.state, 'confirmed')
delivery.move_ids_without_package[1].product_uom_qty = 0
self.assertEqual(delivery.state, 'confirmed')
receipt_form = Form(self.env['stock.picking'].with_context(default_immediate_transfer=True))
delivery_form = Form(self.env['stock.picking'])
picking_type_id = self.warehouse.out_type_id
receipt_form.picking_type_id = picking_type_id
with receipt_form.move_ids_without_package.new() as move_line:
delivery_form.picking_type_id = picking_type_id
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productA
move_line.quantity_done = 10
with receipt_form.move_ids_without_package.new() as move_line:
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productB
move_line.quantity_done = 10
receipt = receipt_form.save()
receipt.action_confirm()
self.assertEqual(receipt.state, 'assigned')
receipt.move_ids_without_package[1].product_uom_qty = 0
self.assertEqual(receipt.state, 'assigned')
delivery = delivery_form.save()
self.assertEqual(delivery.state, 'assigned')
delivery.move_ids_without_package[1].product_uom_qty = 0
self.assertEqual(delivery.state, 'assigned')
def test_2_steps_and_backorder(self):
""" When creating a backorder with a package, the latter should be reserved in the new picking. Moreover,
@@ -920,6 +944,8 @@ class TestPacking(TestPackingCommon):
'picking_type_id': pick_type.id,
'location_id': from_loc.id,
'location_dest_id': to_loc.id,
'state': 'draft',
'immediate_transfer': False,
})
move_A, move_B = self.env['stock.move'].create([{
'name': self.productA.name,
@@ -1000,6 +1026,8 @@ class TestPacking(TestPackingCommon):
'picking_type_id': self.warehouse.in_type_id.id,
'location_id': self.pack_location.id,
'location_dest_id': shelf2_location.id,
'state': 'draft',
'immediate_transfer': False,
})
package_level = self.env['stock.package_level'].create({
'package_id': pack.id,
@@ -1070,6 +1098,8 @@ class TestPacking(TestPackingCommon):
'picking_type_id': warehouse.in_type_id.id,
'location_id': self.env.ref('stock.stock_location_suppliers').id,
'location_dest_id': warehouse.wh_input_stock_loc_id.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': self.productA.name,
@@ -1184,6 +1214,8 @@ class TestPacking(TestPackingCommon):
'picking_type_id': warehouse.in_type_id.id,
'location_id': self.env.ref('stock.stock_location_suppliers').id,
'location_dest_id': warehouse.wh_input_stock_loc_id.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create([{
'name': p.name,
@@ -1273,6 +1305,8 @@ class TestPacking(TestPackingCommon):
'picking_type_id': self.warehouse.in_type_id.id,
'location_id': supplier_location.id,
'location_dest_id': input_location.id,
'state': 'draft',
'immediate_transfer': False,
'move_ids': [(0, 0, {
'name': p.name,
'location_id': supplier_location.id,
@@ -1350,6 +1384,8 @@ class TestPacking(TestPackingCommon):
'location_dest_id': self.customer_location.id,
'picking_type_id': self.warehouse.out_type_id.id,
})],
'state': 'draft',
'immediate_transfer': False,
})
picking.action_confirm()
@@ -1386,6 +1422,8 @@ class TestPacking(TestPackingCommon):
'location_id': loc_1.id,
'location_dest_id': loc_2.id,
'picking_type_id': self.warehouse.int_type_id.id,
'state': 'draft',
'immediate_transfer': False,
})
moveA = self.env['stock.move'].create({
'name': self.productA.name,
+6
View File
@@ -47,6 +47,8 @@ class TestPackingNeg(TransactionCase):
'location_id': self.ref('stock.stock_location_suppliers'),
'location_dest_id': self.ref('stock.stock_location_stock'),
})],
'state': 'draft',
'immediate_transfer': False,
}
pick_neg = self.env['stock.picking'].create(vals)
pick_neg._onchange_picking_type()
@@ -104,6 +106,8 @@ class TestPackingNeg(TransactionCase):
'location_id': self.ref('stock.stock_location_stock'),
'location_dest_id': self.ref('stock.stock_location_customers'),
})],
'state': 'draft',
'immediate_transfer': False,
}
delivery_order_neg = self.env['stock.picking'].create(vals)
delivery_order_neg._onchange_picking_type()
@@ -161,6 +165,8 @@ class TestPackingNeg(TransactionCase):
'location_id': self.ref('stock.stock_location_suppliers'),
'location_dest_id': self.ref('stock.stock_location_stock'),
})],
'state': 'draft',
'immediate_transfer': False,
}
delivery_reconcile = self.env['stock.picking'].create(vals)
delivery_reconcile._onchange_picking_type()
+2
View File
@@ -91,6 +91,8 @@ class TestProcRule(TransactionCase):
'location_id': self.ref('stock.stock_location_output'),
'location_dest_id': self.ref('stock.stock_location_customers'),
})],
'state': 'draft',
'immediate_transfer': False,
}
pick_output = self.env['stock.picking'].create(vals)
pick_output.move_ids._onchange_product_id()
+9 -1
View File
@@ -30,7 +30,11 @@ class TestVirtualAvailable(TestStockCommon):
'quantity': 10.0,
'owner_id': cls.user_stock_user.partner_id.id})
cls.picking_out = cls.env['stock.picking'].create({'picking_type_id': cls.env.ref('stock.picking_type_out').id})
cls.picking_out = cls.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': cls.env.ref('stock.picking_type_out').id
})
cls.env['stock.move'].create({
'name': 'a move',
'product_id': cls.product_3.id,
@@ -41,6 +45,8 @@ class TestVirtualAvailable(TestStockCommon):
'location_dest_id': cls.env.ref('stock.stock_location_customers').id})
cls.picking_out_2 = cls.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': cls.env.ref('stock.picking_type_out').id})
cls.env['stock.move'].create({
'restrict_partner_id': cls.user_stock_user.partner_id.id,
@@ -143,6 +149,8 @@ class TestVirtualAvailable(TestStockCommon):
'location_id': self.env.ref('stock.stock_location_customers').id,
'location_dest_id': self.env.ref('stock.stock_location_stock').id,
'picking_type_id': self.ref('stock.picking_type_in'),
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': 'test',
+2
View File
@@ -773,6 +773,8 @@ class StockQuant(TransactionCase):
'product_uom_qty': 10,
'product_uom': self.product.uom_id.id,
})],
'state': 'draft',
'immediate_transfer': False,
})
picking.action_confirm()
+51 -45
View File
@@ -319,8 +319,9 @@ class TestReports(TestReportsCommon):
receipt = receipt_form.save()
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 2
move_line.quantity_done = 2
receipt = receipt_form.save()
receipt.action_reset_draft()
report_values, docs, lines = self.get_report_forecast(product_template_ids=self.product_template.ids)
draft_picking_qty = docs['draft_picking_qty']
@@ -337,8 +338,9 @@ class TestReports(TestReportsCommon):
delivery = delivery_form.save()
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 5
move_line.quantity_done = 5
delivery = delivery_form.save()
delivery.action_reset_draft()
report_values, docs, lines = self.get_report_forecast(product_template_ids=self.product_template.ids)
draft_picking_qty = docs['draft_picking_qty']
@@ -677,8 +679,9 @@ class TestReports(TestReportsCommon):
delivery = delivery_form.save()
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 5
move_line.quantity_done = 5
delivery = delivery_form.save()
delivery.action_reset_draft()
report_values, docs, lines = self.get_report_forecast(product_template_ids=self.product_template.ids)
draft_picking_qty = docs['draft_picking_qty']
@@ -719,8 +722,9 @@ class TestReports(TestReportsCommon):
delivery_2 = delivery_form.save()
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 8
move_line.quantity_done = 8
delivery_2 = delivery_form.save()
delivery_2.action_reset_draft()
report_values, docs, lines = self.get_report_forecast(product_template_ids=self.product_template.ids)
draft_picking_qty = docs['draft_picking_qty']
@@ -773,8 +777,9 @@ class TestReports(TestReportsCommon):
wh_1_receipt = receipt_form.save()
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 2
move_line.quantity_done = 2
wh_1_receipt = receipt_form.save()
wh_1_receipt.action_reset_draft()
# Creates a receipt then checks draft picking quantities.
receipt_form = Form(self.env['stock.picking'].with_context(
@@ -785,8 +790,9 @@ class TestReports(TestReportsCommon):
wh_2_receipt = receipt_form.save()
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 5
move_line.quantity_done = 5
wh_2_receipt = receipt_form.save()
wh_2_receipt.action_reset_draft()
report_values, docs, lines = self.get_report_forecast(product_template_ids=self.product_template.ids)
draft_picking_qty = docs['draft_picking_qty']
@@ -945,7 +951,7 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = self.picking_type_out
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 100
move_line.quantity_done = 100
delivery = delivery_form.save()
delivery.action_confirm()
@@ -956,7 +962,7 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = self.picking_type_out
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 200
move_line.quantity_done = 200
delivery2 = delivery_form.save()
delivery2.action_confirm()
@@ -968,7 +974,7 @@ class TestReports(TestReportsCommon):
receipt = receipt_form.save()
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 200
move_line.quantity_done = 200
receipt = receipt_form.save()
receipt.move_ids[0].write({
'move_dest_ids': [(4, delivery2.move_ids[0].id)],
@@ -1005,7 +1011,7 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = self.picking_type_out
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 100
move_line.quantity_done = 100
delivery = delivery_form.save()
delivery.action_confirm()
@@ -1016,7 +1022,7 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = self.picking_type_out
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 200
move_line.quantity_done = 200
delivery2 = delivery_form.save()
delivery2.action_confirm()
@@ -1028,7 +1034,7 @@ class TestReports(TestReportsCommon):
receipt = receipt_form.save()
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 300
move_line.quantity_done = 300
receipt = receipt_form.save()
receipt.move_ids[0].write({
'move_dest_ids': [(4, delivery2.move_ids[0].id)],
@@ -1062,9 +1068,8 @@ class TestReports(TestReportsCommon):
delivery_form.scheduled_date = date.today()
with delivery_form.move_ids_without_package.new() as move:
move.product_id = self.product
move.product_uom_qty = 200
move.quantity_done = 200
delivery1 = delivery_form.save()
delivery1.action_confirm()
# Creation of one receipt with date 'today + 1' and smaller qty than the delivery
scheduled_date1 = datetime.now() + timedelta(days=1)
@@ -1074,9 +1079,8 @@ class TestReports(TestReportsCommon):
receipt_form.scheduled_date = scheduled_date1
with receipt_form.move_ids_without_package.new() as move:
move.product_id = self.product
move.product_uom_qty = 150
move.quantity_done = 150
receipt1 = receipt_form.save()
receipt1.action_confirm()
self.assertEqual(receipt1.move_ids.forecast_availability, -50.0)
self.assertEqual(delivery1.move_ids.forecast_availability, 150)
self.assertEqual(delivery1.move_ids.forecast_expected_date, scheduled_date1)
@@ -1089,11 +1093,8 @@ class TestReports(TestReportsCommon):
receipt_form.scheduled_date = scheduled_date2
with receipt_form.move_ids_without_package.new() as move:
move.product_id = self.product
move.product_uom_qty = 150
receipt2 = receipt_form.save()
receipt2.action_confirm()
for move in receipt2.move_ids:
move.quantity_done = 150
receipt2 = receipt_form.save()
# Check forecast_information of delivery1
delivery1.move_ids._compute_forecast_information() # Because depends not "complete"
@@ -1112,7 +1113,7 @@ class TestReports(TestReportsCommon):
delivery2_form = Form(delivery2)
delivery2_form.scheduled_date = datetime.now() + timedelta(days=1)
delivery2 = delivery2_form.save()
delivery2.action_confirm()
delivery2.move_ids.quantity_done = delivery1.move_ids.quantity_done
self.assertEqual(delivery2.move_ids.forecast_availability, 100)
# Check for both deliveries and receipts if the highlight (is_matched) corresponds to the correct picking
@@ -1156,9 +1157,8 @@ class TestReports(TestReportsCommon):
delivery_form.scheduled_date = datetime.now() - timedelta(days=10)
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 3
move_line.quantity_done = 3
delivery_manual = delivery_form.save()
delivery_manual.action_confirm()
# 'by_date' reservation => reservation_date = 1 day before today
delivery_form = Form(self.env['stock.picking'].with_context(
@@ -1169,7 +1169,7 @@ class TestReports(TestReportsCommon):
delivery_form.scheduled_date = datetime.now() + timedelta(days=5)
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 3
move_line.quantity_done = 3
delivery_by_date = delivery_form.save()
delivery_by_date.action_confirm()
@@ -1182,7 +1182,7 @@ class TestReports(TestReportsCommon):
delivery_form.scheduled_date = datetime.now() + timedelta(days=5)
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 3
move_line.quantity_done = 3
delivery_by_date_priority = delivery_form.save()
# <field name="priority" attrs="{'invisible': [('name','=','/')]}"/>
# The priority field is not visible until the name is set,
@@ -1199,8 +1199,9 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = picking_type_at_confirm
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 3
move_line.quantity_done = 3
delivery_at_confirm = delivery_form.save()
delivery_at_confirm.action_reset_draft()
delivery_at_confirm.action_confirm()
# Order should be: delivery_by_date, delivery_at_confirm, delivery_by_date_priority, delivery_manual
@@ -1221,7 +1222,7 @@ class TestReports(TestReportsCommon):
receipt_form.scheduled_date = date.today() + timedelta(days=1)
with receipt_form.move_ids_without_package.new() as move:
move.product_id = self.product
move.product_uom_qty = 6
move.quantity_done = 6
receipt1 = receipt_form.save()
receipt1.action_confirm()
@@ -1243,14 +1244,14 @@ class TestReports(TestReportsCommon):
outgoing.picking_type_id = self.picking_type_out
with outgoing.move_ids_without_package.new() as move:
move.product_id = self.product
move.product_uom_qty = 2
move.quantity_done = 2
outgoing = outgoing.save()
outgoing.action_confirm()
incoming = Form(self.env['stock.picking'])
incoming.picking_type_id = self.picking_type_in
with incoming.move_ids_without_package.new() as move:
move.product_id = self.product
move.product_uom_qty = 2
move.quantity_done = 2
incoming = incoming.save()
incoming.action_confirm()
incoming.action_set_quantities_to_reservation()
@@ -1286,10 +1287,10 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = self.picking_type_out
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 5
move_line.quantity_done = 5
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = product2
move_line.product_uom_qty = 10
move_line.quantity_done = 10
delivery1 = delivery_form.save()
delivery1.action_confirm()
@@ -1300,7 +1301,7 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = self.picking_type_out
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 2
move_line.quantity_done = 2
delivery2 = delivery_form.save()
delivery2.action_confirm()
@@ -1313,16 +1314,17 @@ class TestReports(TestReportsCommon):
with receipt_form.move_ids_without_package.new() as move_line:
# incoming qty greater than total (2 moves) outgoing amount => 2 report lines, each = outgoing qty
move_line.product_id = self.product
move_line.product_uom_qty = 15
move_line.quantity_done = 15
with receipt_form.move_ids_without_package.new() as move_line:
# outgoing qty greater than incoming amount => report line = incoming qty
move_line.product_id = product2
move_line.product_uom_qty = 5
move_line.quantity_done = 5
with receipt_form.move_ids_without_package.new() as move_line:
# not outgoing => shouldn't appear in report
move_line.product_id = product3
move_line.product_uom_qty = 5
move_line.quantity_done = 5
receipt = receipt_form.save()
receipt.action_reset_draft()
# check that reception report has correct number of deliveries/outgoing moves
# but the quantities aren't available for assignment yet (i.e. can link as chained moves)
@@ -1392,8 +1394,9 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = self.picking_type_out
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 100
move_line.quantity_done = 100
delivery = delivery_form.save()
delivery.action_reset_draft()
delivery.action_confirm()
# Create 2 receipts and check its reception report values
@@ -1404,8 +1407,9 @@ class TestReports(TestReportsCommon):
receipt_form.picking_type_id = self.picking_type_in
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 5
move_line.quantity_done = 5
receipt1 = receipt_form.save()
receipt1.action_reset_draft()
receipt_form = Form(self.env['stock.picking'].with_context(
force_detailed_view=True
@@ -1414,8 +1418,9 @@ class TestReports(TestReportsCommon):
receipt_form.picking_type_id = self.picking_type_in
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 3
move_line.quantity_done = 3
receipt2 = receipt_form.save()
receipt2.action_reset_draft()
# check that report correctly merges not draft incoming quantities
report = self.env['report.stock.report_reception']
@@ -1470,7 +1475,7 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = picking_type_out_2
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 100
move_line.quantity_done = 100
delivery = delivery_form.save()
delivery.action_confirm()
@@ -1482,7 +1487,7 @@ class TestReports(TestReportsCommon):
receipt_form.picking_type_id = self.picking_type_in
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 15
move_line.quantity_done = 15
receipt = receipt_form.save()
report = self.env['report.stock.report_reception']
@@ -1525,7 +1530,7 @@ class TestReports(TestReportsCommon):
receipt_form.picking_type_id = self.picking_type_in
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = 15
move_line.quantity_done = 15
receipt = receipt_form.save()
report = self.env['report.stock.report_reception']
@@ -1553,7 +1558,7 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = self.picking_type_out
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = outgoing_qty
move_line.quantity_done = outgoing_qty
delivery = delivery_form.save()
delivery.action_confirm()
@@ -1564,7 +1569,7 @@ class TestReports(TestReportsCommon):
receipt_form.picking_type_id = self.picking_type_in
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = incoming_qty
move_line.quantity_done = incoming_qty
receipt = receipt_form.save()
receipt.action_confirm()
@@ -1619,7 +1624,7 @@ class TestReports(TestReportsCommon):
delivery_form.picking_type_id = self.picking_type_out
with delivery_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = outgoing_qty
move_line.quantity_done = outgoing_qty
delivery = delivery_form.save()
delivery.action_confirm()
@@ -1631,8 +1636,9 @@ class TestReports(TestReportsCommon):
receipt_form.picking_type_id = self.picking_type_in
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.product
move_line.product_uom_qty = incoming_qty
move_line.quantity_done = incoming_qty
receipt = receipt_form.save()
receipt.action_reset_draft()
receipt.action_confirm()
report = self.env['report.stock.report_reception']
+89 -15
View File
@@ -39,6 +39,8 @@ class TestStockFlow(TestStockCommon):
picking_in = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
move_a = self.MoveObj.create({
'name': self.productA.name,
@@ -175,6 +177,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
move_cust_a = self.MoveObj.create({
'name': self.productA.name,
@@ -455,6 +459,8 @@ class TestStockFlow(TestStockCommon):
picking_in_A = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
self.MoveObj.create({
'name': self.DozA.name,
@@ -553,6 +559,8 @@ class TestStockFlow(TestStockCommon):
picking_in_B = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
move_in_a = self.MoveObj.create({
'name': self.DozA.name,
@@ -743,6 +751,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
self.MoveObj.create({
'name': self.kgB.name,
@@ -784,6 +794,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
self.MoveObj.create({
'name': self.DozA.name,
@@ -904,6 +916,8 @@ class TestStockFlow(TestStockCommon):
picking_in = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
self.MoveObj.create({
'name': productKG.name,
@@ -952,6 +966,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
self.MoveObj.create({
'name': productKG.name,
@@ -1129,6 +1145,8 @@ class TestStockFlow(TestStockCommon):
picking_in = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
self.MoveObj.create({
'name': self.productA.name,
@@ -1156,6 +1174,8 @@ class TestStockFlow(TestStockCommon):
'name': 'testpicking',
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
move_out = self.MoveObj.create({
'name': self.productA.name,
@@ -1186,6 +1206,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.pack_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
move_out = self.MoveObj.create({
'name': self.productA.name,
@@ -1198,6 +1220,8 @@ class TestStockFlow(TestStockCommon):
picking_pack = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.pack_location})
move_pack = self.MoveObj.create({
'name': self.productA.name,
@@ -1211,6 +1235,8 @@ class TestStockFlow(TestStockCommon):
picking_in = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
move_in = self.MoveObj.create({
'name': self.productA.name,
@@ -1304,6 +1330,8 @@ class TestStockFlow(TestStockCommon):
picking_in = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
self.MoveObj.create({
'name': self.productE.name,
@@ -1331,6 +1359,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
self.MoveObj.create({
'name': self.productE.name,
@@ -1361,6 +1391,8 @@ class TestStockFlow(TestStockCommon):
picking_in = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
self.MoveObj.create({
'name': self.productE.name,
@@ -1389,6 +1421,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
self.MoveObj.create({
'name': self.productE.name,
@@ -1446,6 +1480,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
picking_out.move_type = 'one'
@@ -1484,6 +1520,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
picking_out.move_type = 'direct'
@@ -1522,6 +1560,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
picking_out.move_type = 'direct'
@@ -1559,6 +1599,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
picking_out.move_type = 'direct'
@@ -1583,6 +1625,8 @@ class TestStockFlow(TestStockCommon):
picking_out = self.PickingObj.create({
'picking_type_id': self.picking_type_out,
'location_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.customer_location})
move_mto_alone = self.MoveObj.create({
'name': self.productA.name,
@@ -1641,6 +1685,8 @@ class TestStockFlow(TestStockCommon):
picking = self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
move_a = self.MoveObj.create({
'name': self.productA.name,
@@ -1698,6 +1744,8 @@ class TestStockFlow(TestStockCommon):
picking_ask = self.PickingObj.create({
'picking_type_id': picking_type_ask.id,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
self.MoveObj.create({
'name': self.productA.name,
@@ -1710,6 +1758,8 @@ class TestStockFlow(TestStockCommon):
picking_always = self.PickingObj.create({
'picking_type_id': picking_type_always.id,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
self.MoveObj.create({
'name': self.productA.name,
@@ -1722,6 +1772,8 @@ class TestStockFlow(TestStockCommon):
picking_never = self.PickingObj.create({
'picking_type_id': picking_type_never.id,
'location_id': self.supplier_location,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': self.stock_location})
self.MoveObj.create({
'name': self.productA.name,
@@ -1883,11 +1935,12 @@ class TestStockFlow(TestStockCommon):
f.picking_type_id = warehouse_company_1.out_type_id
with f.move_ids_without_package.new() as move:
move.product_id = product_from_company_2
move.product_uom_qty = 5
move.quantity_done = 5
with f.move_ids_without_package.new() as move:
move.product_id = product_from_company_3
move.product_uom_qty = 5
move.quantity_done = 5
picking = f.save()
picking.action_reset_draft()
picking.move_ids_without_package.write({'procure_method': 'make_to_order'})
picking.action_confirm()
@@ -1916,9 +1969,13 @@ class TestStockFlow(TestStockCommon):
product = self.env['product.product'].create({'name': 'Un petit coup de polish', 'type': 'product'})
wh = self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)], limit=1)
f = Form(self.env['stock.picking'], view='stock.view_picking_form')
picking = self.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': wh.out_type_id.id,
})
f = Form(picking, view='stock.view_picking_form')
f.partner_id = partner
f.picking_type_id = wh.out_type_id
with f.move_ids_without_package.new() as move:
move.product_id = product
move.product_uom_qty = 5
@@ -1971,7 +2028,7 @@ class TestStockFlow(TestStockCommon):
f.scrap_location_id = wh.wh_input_stock_loc_id
def test_picking_form_immediate_transfer(self):
picking_form = Form(self.env['stock.picking'].with_context(default_immediate_transfer=True))
picking_form = Form(self.env['stock.picking'])
picking_form.picking_type_id = self.env.ref('stock.picking_type_in')
with picking_form.move_ids_without_package.new() as move:
@@ -1984,9 +2041,9 @@ class TestStockFlow(TestStockCommon):
self.assertEqual(picking.state, 'assigned')
picking_form = Form(self.env['stock.picking'].with_context(default_immediate_transfer=False))
picking.action_reset_draft()
picking_form = Form(picking)
picking_form.picking_type_id = self.env.ref('stock.picking_type_in')
with picking_form.move_ids_without_package.new() as move:
self.assertTrue(move._get_modifier('quantity_done', 'column_invisible'))
self.assertTrue(move._get_modifier('forecast_availability', 'column_invisible'))
@@ -2018,8 +2075,9 @@ class TestStockFlow(TestStockCommon):
picking_form.picking_type_id = picking_type
with picking_form.move_ids_without_package.new() as move:
move.product_id = product_lot
move.product_uom_qty = 8
move.quantity_done = 8
receipt_1 = picking_form.save()
receipt_1.action_reset_draft()
receipt_1.action_confirm()
move_form = Form(receipt_1.move_ids, view="stock.view_stock_move_operations")
@@ -2038,8 +2096,9 @@ class TestStockFlow(TestStockCommon):
picking_form.picking_type_id = picking_type
with picking_form.move_ids_without_package.new() as move:
move.product_id = product_lot
move.product_uom_qty = 8
move.quantity_done = 8
receipt_2 = picking_form.save()
receipt_2.action_reset_draft()
receipt_2.action_confirm()
move_form = Form(receipt_2.move_ids, view="stock.view_stock_move_operations")
@@ -2078,8 +2137,12 @@ class TestStockFlow(TestStockCommon):
# Checks also it still raise an error when it tries to create multiple time
# the same serial numbers (same scenario but with SN instead of lots).
picking_type = self.env['stock.picking.type'].browse(self.picking_type_in)
picking_form = Form(self.env['stock.picking'])
picking_form.picking_type_id = picking_type
picking = self.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': picking_type.id,
})
picking_form = Form(picking)
with picking_form.move_ids_without_package.new() as move:
move.product_id = product_serial
move.product_uom_qty = 2
@@ -2093,8 +2156,12 @@ class TestStockFlow(TestStockCommon):
line.lot_name = 'sn-002'
move = move_form.save()
picking_form = Form(self.env['stock.picking'])
picking_form.picking_type_id = picking_type
picking = self.env['stock.picking'].create({
'state': 'draft',
'immediate_transfer': False,
'picking_type_id': picking_type.id,
})
picking_form = Form(picking)
with picking_form.move_ids_without_package.new() as move:
move.product_id = product_serial
move.product_uom_qty = 2
@@ -2121,6 +2188,8 @@ class TestStockFlow(TestStockCommon):
'picking_type_id': picking_type,
'location_id': from_loc,
'location_dest_id': to_loc,
'state': 'draft',
'immediate_transfer': False,
})
self.MoveObj.create({
'name': self.productA.name,
@@ -2173,6 +2242,8 @@ class TestStockFlow(TestStockCommon):
'picking_type_id': picking_type_out.id,
'location_id': stock_location.id,
'location_dest_id': self.customer_location,
'state': 'draft',
'immediate_transfer': False,
})
move_out = self.MoveObj.create({
'name': self.productA.name,
@@ -2198,6 +2269,8 @@ class TestStockFlow(TestStockCommon):
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'location_dest_id': self.stock_location,
'state': 'draft',
'immediate_transfer': False,
})
move_a = self.MoveObj.create({
'name': self.productA.name,
@@ -2314,7 +2387,7 @@ class TestStockFlow(TestStockCommon):
self.productA.tracking = 'serial'
type_in = self.env['stock.picking.type'].browse(self.picking_type_in)
receipt_form = Form(self.env['stock.picking'].with_context(default_immediate_transfer=True))
receipt_form = Form(self.env['stock.picking'])
receipt_form.picking_type_id = type_in
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productA
@@ -2447,11 +2520,12 @@ class TestStockFlow(TestStockCommon):
self.productA.tracking = 'lot'
receipt_form = Form(self.env['stock.picking'].with_context(default_immediate_transfer=True))
receipt_form = Form(self.env['stock.picking'])
receipt_form.picking_type_id = self.env.ref('stock.picking_type_in')
with receipt_form.move_ids_without_package.new() as move:
move.product_id = self.productA
receipt = receipt_form.save()
receipt.action_confirm()
with Form(receipt.move_ids, view='stock.view_stock_move_nosuggest_operations') as move_form:
with move_form.move_line_nosuggest_ids.new() as sml:
+5
View File
@@ -283,6 +283,7 @@ class TestWarehouse(TestStockCommon):
'location_id': warehouse_shop.lot_stock_id.id,
'location_dest_id': self.env.ref('stock.stock_location_customers').id,
})
picking_out.action_reset_draft()
self.env['stock.move'].create({
'name': product.name,
'product_id': product.id,
@@ -365,6 +366,8 @@ class TestWarehouse(TestStockCommon):
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'location_id': warehouse_shop_namur.lot_stock_id.id,
'location_dest_id': customer_location.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': product.name,
@@ -409,6 +412,8 @@ class TestWarehouse(TestStockCommon):
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'location_id': warehouse_shop_wavre.lot_stock_id.id,
'location_dest_id': customer_location.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': product.name,
+6
View File
@@ -48,6 +48,8 @@ class TestWiseOperator(TransactionCase):
'location_id': self.ref('stock.stock_location_suppliers'),
'location_dest_id': self.ref('stock.stock_location_stock'),
})],
'state': 'draft',
'immediate_transfer': False,
}
pick1_wise = self.env['stock.picking'].create(vals)
pick1_wise._onchange_picking_type()
@@ -95,6 +97,8 @@ class TestWiseOperator(TransactionCase):
'location_id': self.ref('stock.stock_location_stock'),
'location_dest_id': self.ref('stock.stock_location_customers'),
})],
'state': 'draft',
'immediate_transfer': False,
}
delivery_order_wise1 = self.env['stock.picking'].create(vals)
delivery_order_wise1._onchange_picking_type()
@@ -120,6 +124,8 @@ class TestWiseOperator(TransactionCase):
'location_id': self.ref('stock.stock_location_stock'),
'location_dest_id': self.ref('stock.stock_location_customers'),
})],
'state': 'draft',
'immediate_transfer': False,
}
delivery_order_wise2 = self.env['stock.picking'].create(vals)
delivery_order_wise2._onchange_picking_type()
+1 -1
View File
@@ -292,7 +292,7 @@
<field name="lot_id" groups="stock.group_production_lot" attrs="{'column_invisible': [('parent.show_lots_text', '=', True)], 'invisible': [('lots_visible', '=', False)]}" context="{'default_product_id': product_id, 'default_company_id': company_id, 'active_picking_id': picking_id}" optional="show"/>
<field name="lot_name" groups="stock.group_production_lot" attrs="{'column_invisible': [('parent.show_lots_text', '=', False)], 'invisible': [('lots_visible', '=', False)]}" context="{'default_product_id': product_id}"/>
<field name="is_initial_demand_editable" invisible="1"/>
<field name="reserved_uom_qty" attrs="{'column_invisible': ['|',('parent.immediate_transfer', '=', True),('parent.picking_type_code','=','incoming')], 'readonly': [('id', '=', False)]}" optional="show"/>
<field name="reserved_uom_qty" attrs="{'column_invisible': [('parent.picking_type_code','=','incoming')], 'readonly': [('id', '=', False)]}" optional="show"/>
<field name="is_locked" invisible="1"/>
<field name="qty_done" attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)]}" force_save="1"/>
<field name="product_uom_id" force_save="1" attrs="{'readonly': [('state', '!=', 'draft'), ('id', '!=', False)]}" groups="uom.group_uom"/>
@@ -161,13 +161,7 @@
</div>
<div class="col-6 o_kanban_card_manage_section o_kanban_manage_new">
<div role="menuitem" class="o_kanban_card_manage_title">
<span>New</span>
</div>
<div role="menuitem">
<a name="%(action_picking_form)d" type="action" context="{'default_immediate_transfer': True}">Immediate Transfer</a>
</div>
<div role="menuitem">
<a name="%(action_picking_form)d" type="action">Planned Transfer</a>
<a name="%(action_picking_form)d" type="action">New</a>
</div>
</div>
</div>
+10 -11
View File
@@ -108,9 +108,7 @@
<form string="Transfer" js_class="picking_form">
<field name="is_locked" invisible="1"/>
<field name="show_mark_as_todo" invisible="1"/>
<field name="show_check_availability" invisible="1"/>
<field name="show_validate" invisible="1"/>
<field name="show_lots_text" invisible="1"/>
<field name="immediate_transfer" invisible="1"/>
<field name="picking_type_code" invisible="1"/>
@@ -127,10 +125,11 @@
<field name="company_id" invisible="1"/>
<header>
<button name="action_confirm" attrs="{'invisible': [('show_mark_as_todo', '=', False)]}" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user" data-hotkey="x"/>
<button name="action_confirm" attrs="{'invisible': [('state', '!=', 'draft')]}" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user" data-hotkey="x"/>
<button name="action_assign" attrs="{'invisible': [('show_check_availability', '=', False)]}" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user" data-hotkey="q"/>
<button name="button_validate" attrs="{'invisible': ['|', ('state', 'in', ('waiting','confirmed')), ('show_validate', '=', False)]}" string="Validate" type="object" class="oe_highlight" groups="stock.group_stock_user" data-hotkey="v"/>
<button name="button_validate" attrs="{'invisible': ['|', ('state', 'not in', ('waiting', 'confirmed')), ('show_validate', '=', False)]}" string="Validate" type="object" groups="stock.group_stock_user" class="o_btn_validate" data-hotkey="v"/>
<button name="button_validate" attrs="{'invisible': [('state', 'in', ('waiting','confirmed', 'draft', 'done', 'cancel'))]}" string="Validate" type="object" class="oe_highlight" groups="stock.group_stock_user" data-hotkey="v"/>
<button name="button_validate" attrs="{'invisible': [('state', 'in', ('draft', 'assigned', 'done', 'cancel'))]}" string="Validate" type="object" groups="stock.group_stock_user" class="o_btn_validate" data-hotkey="v"/>
<button name="action_reset_draft" attrs="{'invisible': [('state', 'in', ('draft', 'done', 'cancel'))]}" string="Set Draft" type="object" groups="stock.group_stock_user" class="o_highlight" data-hotkey="d"/>
<button name="action_set_quantities_to_reservation" attrs="{'invisible': [('show_set_qty_button', '=', False)]}" string="Set quantities" type="object" groups="stock.group_stock_user" class="o_btn_validate" data-hotkey="g"/>
<button name="action_clear_quantities_to_zero" attrs="{'invisible': [('show_clear_qty_button', '=', False)]}" string="Clear quantities" type="object" groups="stock.group_stock_user" class="o_btn_validate" data-hotkey="g"/>
<widget name="signature" string="Sign" highlight="1"
@@ -143,7 +142,7 @@
<button string="Print Labels" type="object" name="action_open_label_type"/>
<button name="%(action_report_delivery)d" string="Print" attrs="{'invisible': [('state', '!=', 'done')]}" type="action" groups="base.group_user" data-hotkey="o"/>
<button name="%(act_stock_return_picking)d" string="Return" attrs="{'invisible': [('state', '!=', 'done')]}" type="action" groups="base.group_user" data-hotkey="k"/>
<button name="do_unreserve" string="Unreserve" groups="base.group_user" type="object" attrs="{'invisible': ['|', '|', '|', ('picking_type_code', '=', 'incoming'), ('immediate_transfer', '=', True), '&amp;', ('state', '!=', 'assigned'), ('move_type', '!=', 'one'), '&amp;', ('state', 'not in', ('assigned', 'confirmed')), ('move_type', '=', 'one')]}" data-hotkey="w"/>
<button name="do_unreserve" string="Unreserve" groups="base.group_user" type="object" attrs="{'invisible': ['|', '|', ('picking_type_code', '=', 'incoming'), '&amp;', ('state', '!=', 'assigned'), ('move_type', '!=', 'one'), '&amp;', ('state', 'not in', ('assigned', 'confirmed')), ('move_type', '=', 'one')]}" data-hotkey="w"/>
<button name="button_scrap" type="object" string="Scrap" attrs="{'invisible': ['|', '&amp;', ('picking_type_code', '=', 'incoming'), ('state', '!=', 'done'), '&amp;', ('picking_type_code', '=', 'outgoing'), ('state', '=', 'done')]}" data-hotkey="y"/>
<button name="action_toggle_is_locked" attrs="{'invisible': ['|', ('state', 'in', ('draft','cancel')), ('is_locked', '=', False)]}" string="Unlock" groups="stock.group_stock_manager" type="object" help="If the picking is unlocked you can edit initial demand (for a draft picking) or done quantities (for a done picking)." data-hotkey="l"/>
<button name="action_toggle_is_locked" attrs="{'invisible': [('is_locked', '=', True)]}" string="Lock" groups="stock.group_stock_manager" type="object" data-hotkey="l"/>
@@ -206,7 +205,7 @@
</div>
<field name="partner_id" nolabel="1"/>
<field name="picking_type_id" options="{'no_open': True}"
attrs="{'invisible': [('hide_picking_type', '=', True)], 'readonly': [('state', '!=', 'draft')]}"
attrs="{'invisible': [('hide_picking_type', '=', True)], 'readonly': [('id', '!=', False)]}"
domain="context.get('restricted_picking_type_code', []) and [('code', '=', context.get('restricted_picking_type_code'))]"/>
<field name="location_id" groups="!stock.group_stock_multi_locations" invisible="1"/>
<field name="location_dest_id" groups="!stock.group_stock_multi_locations" invisible="1"/>
@@ -261,7 +260,7 @@
attrs="{'readonly': ['&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}"
context="{'default_company_id': company_id, 'default_date': scheduled_date, 'default_date_deadline': date_deadline, 'picking_type_code': picking_type_code, 'default_picking_id': id, 'form_view_ref':'stock.view_move_form', 'address_in_id': partner_id, 'default_picking_type_id': picking_type_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id, 'default_partner_id': partner_id}"
add-label="Add a Product">
<tree decoration-danger="not parent.immediate_transfer and state != 'done' and quantity_done > reserved_availability and show_reserved_availability" decoration-muted="scrapped == True or state == 'cancel' or (state == 'done' and is_locked == True)" string="Stock Moves" editable="bottom">
<tree decoration-danger="state != 'done' and quantity_done > reserved_availability and show_reserved_availability" decoration-muted="scrapped == True or state == 'cancel' or (state == 'done' and is_locked == True)" string="Stock Moves" editable="bottom">
<field name="company_id" invisible="1"/>
<field name="name" invisible="1"/>
<field name="state" invisible="1" readonly="0"/>
@@ -290,7 +289,7 @@
<field name="product_packaging_id" groups="product.group_stock_packaging"
context="{'default_product_id': product_id}"
attrs="{'readonly': [('product_id', '=', False)]}"/>
<field name="product_uom_qty" string="Demand" attrs="{'column_invisible': [('parent.immediate_transfer', '=', True)], 'readonly': ['|', ('is_initial_demand_editable', '=', False), '&amp;', '&amp;', ('show_operations', '=', True), ('is_locked', '=', True), ('is_initial_demand_editable', '=', False)]}"/>
<field name="product_uom_qty" string="Demand" attrs="{'column_invisible': [('parent.immediate_transfer', '=', True)], 'readonly': [('state', '!=', 'draft'), '|', ('is_initial_demand_editable', '=', False), '&amp;', '&amp;', ('show_operations', '=', True), ('is_locked', '=', True), ('is_initial_demand_editable', '=', False)]}"/>
<button type="object" name="action_product_forecast_report" title="Forecast Report" icon="fa-area-chart"
attrs="{'invisible': ['|', ('forecast_availability', '&lt;', 0), '|', ('parent.immediate_transfer', '=', True), '&amp;', ('parent.picking_type_code', '=', 'outgoing'), ('state', '!=', 'draft')]}"/>
<button type="object" name="action_product_forecast_report" title="Forecast Report" icon="fa-area-chart text-danger"
@@ -330,8 +329,8 @@
<field name="product_id" required="1" attrs="{'readonly': ['|', '&amp;', ('state', '!=', 'draft'), ('additional', '=', False), ('move_lines_count', '&gt;', 0)]}"/>
<field name="is_initial_demand_editable" invisible="1"/>
<field name="is_quantity_done_editable" invisible="1"/>
<field name="product_uom_qty" attrs="{'invisible': [('parent.immediate_transfer', '=', True)], 'readonly': [('is_initial_demand_editable', '=', False)]}"/>
<field name="reserved_availability" string="Reserved" attrs="{'invisible': (['|','|', ('parent.state','=', 'done'), ('parent.picking_type_code', 'in', ['outgoing', 'incoming']), ('parent.immediate_transfer', '=', True)])}"/>
<field name="product_uom_qty" attrs="{'invisible': [('product_uom_qty', '=', 0)], 'readonly': [('is_initial_demand_editable', '=', False)]}"/>
<field name="reserved_availability" string="Reserved" attrs="{'invisible': (['|','|', ('parent.state','=', 'done'), ('parent.picking_type_code', 'in', ['outgoing', 'incoming']), ('parent.state', '=', 'assigned')])}"/>
<field name="product_qty" invisible="1" readonly="1"/>
<field name="forecast_expected_date" invisible="1"/>
<field name="forecast_availability" string="Reserved" attrs="{'invisible': ['|', ('parent.picking_type_code', '!=', 'outgoing'), ('parent.state','=', 'done')]}" widget="forecast_widget"/>
@@ -916,6 +916,8 @@ class TestStockValuation(TransactionCase):
'location_dest_id': self.customer_location.id,
'partner_id': self.env['res.partner'].search([], limit=1).id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move3 = self.env['stock.move'].create({
'name': 'out 10',
@@ -926,8 +928,9 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'picking_id': out_pick.id,
})
move3._action_confirm()
move3._action_assign()
out_pick.action_reset_draft()
out_pick.action_confirm()
out_pick.action_assign()
move3.move_line_ids.qty_done = 10.0
move3._action_done()
@@ -1458,6 +1461,8 @@ class TestStockValuation(TransactionCase):
'location_dest_id': self.stock_location.id,
'partner_id': self.partner.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'state': 'draft',
'immediate_transfer': False,
})
move1 = self.env['stock.move'].create({
@@ -1540,6 +1545,8 @@ class TestStockValuation(TransactionCase):
'location_dest_id': self.customer_location.id,
'partner_id': self.partner.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
'state': 'draft',
'immediate_transfer': False,
})
move3 = self.env['stock.move'].create({
'picking_id': delivery.id,
@@ -3916,6 +3923,8 @@ class TestStockValuation(TransactionCase):
'location_dest_id': self.stock_location.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'owner_id': self.env.company.partner_id.id,
'state': 'draft',
'immediate_transfer': False,
})
move = self.env['stock.move'].create({
@@ -3947,6 +3956,8 @@ class TestStockValuation(TransactionCase):
'location_dest_id': self.stock_location.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'owner_id': self.env.company.partner_id.id,
'state': 'draft',
'immediate_transfer': False,
})
move = self.env['stock.move'].create({
@@ -53,6 +53,8 @@ class TestStockValuationCommon(TransactionCase):
'picking_type_id': in_move.picking_type_id.id,
'location_id': in_move.location_id.id,
'location_dest_id': in_move.location_dest_id.id,
'state': 'draft',
'immediate_transfer': False,
})
in_move.write({'picking_id': picking.id})
@@ -84,6 +86,8 @@ class TestStockValuationCommon(TransactionCase):
'picking_type_id': out_move.picking_type_id.id,
'location_id': out_move.location_id.id,
'location_dest_id': out_move.location_dest_id.id,
'state': 'draft',
'immediate_transfer': False,
})
out_move.write({'picking_id': picking.id})
@@ -281,6 +285,8 @@ class TestStockValuationStandard(TestStockValuationCommon):
'picking_type_id': self.picking_type_in.id,
'location_id': self.supplier_location.id,
'location_dest_id': self.stock_location.id,
'state': 'draft',
'immediate_transfer': False,
})
for product in (product1, product2):
product.standard_price = 10
@@ -63,7 +63,6 @@ class TestPacking(TestPackingCommon):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id
})
picking_ship.action_confirm()
pack_action = picking_ship.action_put_in_pack()
pack_action_ctx = pack_action['context']
pack_action_model = pack_action['res_model']
@@ -97,9 +96,7 @@ class TestPacking(TestPackingCommon):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id
})
self.assertEqual(picking_ship.state, 'draft', 'Delivery state should be draft.')
self.assertEqual(picking_ship.state, 'assigned', 'Delivery state should be assigned.')
self.assertFalse(picking_ship.sale_id.id, 'Sale order shouldn\'t be set')
picking_ship.action_confirm()
picking_ship.button_validate()
self.assertEqual(picking_ship.state, 'done')
@@ -100,7 +100,7 @@ class TestLifoPrice(ValuationReconciliationTestCommon):
# ...
# }
# ...
out_form = Form(self.env['stock.picking'].with_context(default_immediate_transfer=True))
out_form = Form(self.env['stock.picking'])
out_form.picking_type_id = self.company_data['default_warehouse'].out_type_id
with out_form.move_ids_without_package.new() as move:
move.product_id = product_lifo_icecream
@@ -19,6 +19,8 @@ class TestLandedCosts(TestStockLandedCostsCommon):
'partner_id': cls.supplier_id,
'picking_type_id': cls.warehouse.in_type_id.id,
'location_id': cls.supplier_location_id,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': cls.warehouse.lot_stock_id.id})
cls.Move.create({
'name': cls.product_refrigerator.name,
@@ -41,6 +43,8 @@ class TestLandedCosts(TestStockLandedCostsCommon):
'partner_id': cls.customer_id,
'picking_type_id': cls.warehouse.out_type_id.id,
'location_id': cls.warehouse.lot_stock_id.id,
'state': 'draft',
'immediate_transfer': False,
'location_dest_id': cls.customer_location_id})
cls.Move.create({
'name': cls.product_refrigerator.name,
@@ -293,6 +297,7 @@ class TestLandedCosts(TestStockLandedCostsCommon):
def _process_incoming_shipment(self):
""" Two product incoming shipment. """
# Confirm incoming shipment.
self.picking_in.action_reset_draft()
self.picking_in.action_confirm()
# Transfer incoming shipment
res_dict = self.picking_in.button_validate()
@@ -303,6 +308,7 @@ class TestLandedCosts(TestStockLandedCostsCommon):
def _process_outgoing_shipment(self):
""" One product Outgoing shipment. """
# Confirm outgoing shipment.
self.picking_out.action_reset_draft()
self.picking_out.action_confirm()
# Product assign to outgoing shipments
self.picking_out.action_assign()
@@ -29,6 +29,8 @@
<field name="move_type">one</field>
<field name="priority">1</field>
<field name="user_id" eval="False"/>
<field name="state">draft</field>
<field name="immediate_transfer" eval="False"/>
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
@@ -38,6 +40,8 @@
<field name="move_type">one</field>
<field name="priority">0</field>
<field name="user_id" eval="False"/>
<field name="state">draft</field>
<field name="immediate_transfer" eval="False"/>
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
@@ -47,6 +51,8 @@
<field name="move_type">one</field>
<field name="priority">0</field>
<field name="user_id" eval="False"/>
<field name="state">draft</field>
<field name="immediate_transfer" eval="False"/>
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
@@ -56,6 +62,8 @@
<field name="move_type">one</field>
<field name="priority">1</field>
<field name="user_id" eval="False"/>
<field name="state">draft</field>
<field name="immediate_transfer" eval="False"/>
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_customers"/>
@@ -73,6 +73,7 @@ class StockMoveLine(models.Model):
'move_ids': [],
'move_line_ids': [],
'batch_id': wave.id,
'immediate_transfer': False,
})[0]
for move, move_lines in line_by_move.items():
picking_to_wave_vals['move_line_ids'] += [Command.link(line.id) for line in lines]
@@ -36,6 +36,8 @@ class TestBatchPicking(TransactionCase):
'picking_type_id': cls.picking_type_out,
'partner_id': cls.client_1.id,
'company_id': cls.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
cls.env['stock.move'].create({
@@ -55,6 +57,8 @@ class TestBatchPicking(TransactionCase):
'picking_type_id': cls.picking_type_out,
'partner_id': cls.client_2.id,
'company_id': cls.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
cls.env['stock.move'].create({
@@ -72,6 +76,8 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': cls.customer_location.id,
'picking_type_id': cls.picking_type_out,
'company_id': cls.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
cls.env['stock.move'].create({
@@ -441,6 +447,8 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': self.customer_location.id,
'picking_type_id': type_special_out.id,
'company_id': self.env.company.id,
'state': 'draft',
'immediate_transfer': False,
'partner_id': partner_1.id
})
self.env['stock.move'].create({
@@ -458,6 +466,8 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': self.customer_location.id,
'picking_type_id': type_special_out.id,
'company_id': self.env.company.id,
'state': 'draft',
'immediate_transfer': False,
'partner_id': partner_2.id
})
self.env['stock.move'].create({
@@ -475,6 +485,8 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': self.customer_location.id,
'picking_type_id': type_special_out.id,
'company_id': self.env.company.id,
'state': 'draft',
'immediate_transfer': False,
'partner_id': partner_1.id
})
self.env['stock.move'].create({
@@ -646,6 +658,8 @@ class TestBatchPicking02(TransactionCase):
'location_id': loc1.id,
'location_dest_id': loc2.id,
'picking_type_id': self.picking_type_internal.id,
'state': 'draft',
'immediate_transfer': False,
'move_ids': [(0, 0, {
'name': 'test_put_in_pack_from_multiple_pages',
'location_id': loc1.id,
@@ -685,6 +699,8 @@ class TestBatchPicking02(TransactionCase):
'location_dest_id': loc2.id,
'picking_type_id': self.picking_type_internal.id,
'company_id': self.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': self.productA.name,
@@ -701,6 +717,8 @@ class TestBatchPicking02(TransactionCase):
'location_dest_id': loc2.id,
'picking_type_id': self.picking_type_internal.id,
'company_id': self.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': self.productB.name,
@@ -67,6 +67,8 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': cls.customer_location.id,
'picking_type_id': cls.picking_type_out,
'company_id': cls.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
cls.env['stock.move'].create({
@@ -94,6 +96,8 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': cls.customer_location.id,
'picking_type_id': cls.picking_type_out,
'company_id': cls.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
cls.env['stock.move'].create({
@@ -111,6 +115,8 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': cls.customer_location.id,
'picking_type_id': cls.picking_type_out,
'company_id': cls.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
cls.env['stock.move'].create({
@@ -128,6 +134,8 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': cls.customer_location.id,
'picking_type_id': cls.picking_type_internal,
'company_id': cls.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
cls.env['stock.move'].create({
@@ -334,7 +342,6 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': self.customer_location.id,
'picking_type_id': self.picking_type_out,
'company_id': self.env.company.id,
'immediate_transfer': True,
})
ml1 = self.env['stock.move.line'].create({
'product_id': self.productA.id,
@@ -361,7 +368,6 @@ class TestBatchPicking(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.customer_location.id,
})
picking.action_confirm()
ml1._add_to_wave()
wave = self.env['stock.picking.batch'].search([
@@ -414,6 +420,8 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': self.customer_location.id,
'picking_type_id': self.picking_type_out,
'company_id': self.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': 'Test Wave',
@@ -467,6 +475,8 @@ class TestBatchPicking(TransactionCase):
'location_dest_id': self.stock_location.id,
'picking_type_id': self.picking_type_in,
'company_id': self.env.company.id,
'state': 'draft',
'immediate_transfer': False,
})
self.env['stock.move'].create({
'name': self.productA.name,