Skip to content

Commit

Permalink
[ADD] MRP : Test auto cancelation MO based on outgoing shipment cancel.
Browse files Browse the repository at this point in the history
  • Loading branch information
jir-odoo committed Apr 16, 2019
1 parent 1fc28f5 commit a62c882
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions addons/sale_mrp/tests/test_sale_mrp_lead_time.py
Expand Up @@ -147,3 +147,37 @@ def test_01_product_route_level_delays(self):
delta=timedelta(seconds=10),
msg="Schedule date of manufacturing order should be equal to: Schedule date of pack type picking - product's Manufacturing Lead Time."
)

def test_02_forward_cancel_confirm_manufacturing_order(self):
""" Test confirm manufacturing order based on rule with option forward cancelation."""

# Update warehouse_1 with Outgoing Shippings pick + pack + ship
self.warehouse_1.write({'delivery_steps': 'pick_pack_ship'})

# Set delay on pull rule
self.warehouse_1.delivery_route_id.rule_ids.write({'previous_move_propagate': True})
self.warehouse_1.mto_pull_id.write({'previous_move_propagate': True})

# Create sale order of product_1
order_form = Form(self.env['sale.order'])
order_form.partner_id = self.partner_1
order_form.warehouse_id = self.warehouse_1
with order_form.order_line.new() as line:
line.product_id = self.product_1
line.product_uom_qty = 6
order = order_form.save()
# Confirm sale order
order.action_confirm()

# Run scheduler
self.env['procurement.group'].run_scheduler()

# Check manufacturing order created or not
manufacturing_order = self.env['mrp.production'].search([('product_id', '=', self.product_1.id)])
self.assertTrue(manufacturing_order, 'Manufacturing order should be created.')
# Check status of manufacturing orders.
self.assertEqual(manufacturing_order.state, 'confirmed')
# Cancel the delivery order.
out = order.picking_ids.filtered(lambda r: r.picking_type_id == self.warehouse_1.out_type_id)
out.action_cancel()
self.assertEqual(manufacturing_order.state, 'confirmed')

0 comments on commit a62c882

Please sign in to comment.