mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 18:52:07 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -12,19 +12,20 @@ class TestMultistepManufacturing(TestMrpCommon):
|
|||
super().setUpClass()
|
||||
|
||||
# Required for `uom_id ` to be visible in the view
|
||||
cls.env.user.groups_id += cls.env.ref('uom.group_uom')
|
||||
cls.env.user.group_ids += cls.env.ref('uom.group_uom')
|
||||
# Required for `manufacture_steps` to be visible in the view
|
||||
cls.env.user.groups_id += cls.env.ref('stock.group_adv_location')
|
||||
cls.env.user.group_ids += cls.env.ref('stock.group_adv_location')
|
||||
# Required for `product_id` to be visible in the view
|
||||
cls.env.user.groups_id += cls.env.ref('product.group_product_variant')
|
||||
cls._enable_variants()
|
||||
|
||||
cls.env.ref('stock.route_warehouse0_mto').active = True
|
||||
cls.route_mto.active = True
|
||||
cls.MrpProduction = cls.env['mrp.production']
|
||||
# Create warehouse
|
||||
warehouse_form = Form(cls.env['stock.warehouse'])
|
||||
warehouse_form.name = 'Test'
|
||||
warehouse_form.code = 'Test'
|
||||
cls.warehouse = warehouse_form.save()
|
||||
cls.warehouse.mto_pull_id.route_id.rule_ids.procure_method = "make_to_order"
|
||||
|
||||
cls.uom_unit = cls.env.ref('uom.product_uom_unit')
|
||||
|
||||
|
|
@ -32,7 +33,6 @@ class TestMultistepManufacturing(TestMrpCommon):
|
|||
product_form = Form(cls.env['product.product'])
|
||||
product_form.name = 'Stick'
|
||||
product_form.uom_id = cls.uom_unit
|
||||
product_form.uom_po_id = cls.uom_unit
|
||||
product_form.route_ids.clear()
|
||||
product_form.route_ids.add(cls.warehouse.manufacture_pull_id.route_id)
|
||||
product_form.route_ids.add(cls.warehouse.mto_pull_id.route_id)
|
||||
|
|
@ -42,12 +42,10 @@ class TestMultistepManufacturing(TestMrpCommon):
|
|||
product_form = Form(cls.env['product.product'])
|
||||
product_form.name = 'Raw Stick'
|
||||
product_form.uom_id = cls.uom_unit
|
||||
product_form.uom_po_id = cls.uom_unit
|
||||
cls.product_raw = product_form.save()
|
||||
|
||||
# Create bom for manufactured product
|
||||
bom_product_form = Form(cls.env['mrp.bom'])
|
||||
bom_product_form.product_id = cls.product_manu
|
||||
bom_product_form.product_tmpl_id = cls.product_manu.product_tmpl_id
|
||||
bom_product_form.product_qty = 1.0
|
||||
bom_product_form.type = 'normal'
|
||||
|
|
@ -65,7 +63,6 @@ class TestMultistepManufacturing(TestMrpCommon):
|
|||
line.name = cls.product_manu.name
|
||||
line.product_id = cls.product_manu
|
||||
line.product_uom_qty = 1.0
|
||||
line.product_uom = cls.uom_unit
|
||||
line.price_unit = 10.0
|
||||
cls.sale_order = sale_form.save()
|
||||
|
||||
|
|
@ -120,7 +117,6 @@ class TestMultistepManufacturing(TestMrpCommon):
|
|||
|
||||
# New BoM for raw material product, it will generate another Production order i.e. child Production order
|
||||
bom_product_form = Form(self.env['mrp.bom'])
|
||||
bom_product_form.product_id = self.product_raw
|
||||
bom_product_form.product_tmpl_id = self.product_raw.product_tmpl_id
|
||||
bom_product_form.product_qty = 1.0
|
||||
with bom_product_form.bom_line_ids.new() as bom_line:
|
||||
|
|
@ -157,3 +153,56 @@ class TestMultistepManufacturing(TestMrpCommon):
|
|||
|
||||
self.assertEqual(self.sale_order.action_view_mrp_production()['res_id'], mo.id)
|
||||
self.assertEqual(mo.action_view_sale_orders()['res_id'], self.sale_order.id)
|
||||
|
||||
def test_sales_order_with_mto_manufacturing(self):
|
||||
self.route_mto.active = True
|
||||
warehouse = self.warehouse_1
|
||||
warehouse.manufacture_steps = 'pbm_sam'
|
||||
prod1 = self.env['product.product'].create({
|
||||
'name': 'elct1',
|
||||
'type': 'consu',
|
||||
'route_ids': [(6, 0, [
|
||||
warehouse.manufacture_pull_id.route_id.id,
|
||||
warehouse.mto_pull_id.route_id.id
|
||||
])],
|
||||
})
|
||||
prod2 = self.env['product.product'].create({
|
||||
'name': 'elct2',
|
||||
'type': 'consu',
|
||||
'route_ids': [(6, 0, [
|
||||
warehouse.manufacture_pull_id.route_id.id,
|
||||
warehouse.mto_pull_id.route_id.id
|
||||
])],
|
||||
})
|
||||
partner = self.env['res.partner'].create({'name': 'Steve Buscemi'})
|
||||
so = self.env['sale.order'].create({
|
||||
'partner_id': partner.id,
|
||||
'order_line': [(0, 0, {'product_id': prod1.id, 'product_uom_qty': 1}),
|
||||
(0, 0, {'product_id': prod2.id, 'product_uom_qty': 1})],
|
||||
'client_order_ref': 'Test Reference'
|
||||
})
|
||||
so.action_confirm()
|
||||
|
||||
def test_mto_cancel_3_steps_mo(self):
|
||||
'''
|
||||
In 3 step manufacturing, test that when the MO gets cancelled, the
|
||||
delivery (to the client) can be made from stock.
|
||||
'''
|
||||
self.warehouse.manufacture_steps = 'pbm_sam'
|
||||
self.sale_order.order_line.product_id.is_storable = True
|
||||
self.env['stock.quant']._update_available_quantity(
|
||||
self.sale_order.order_line.product_id,
|
||||
self.sale_order.warehouse_id.lot_stock_id,
|
||||
10
|
||||
)
|
||||
self.sale_order.action_confirm()
|
||||
self.assertEqual(self.sale_order.picking_ids.state, 'waiting')
|
||||
self.assertEqual(self.sale_order.picking_ids.move_ids.procure_method, 'make_to_order')
|
||||
mo = self.sale_order.mrp_production_ids
|
||||
self.assertTrue(mo)
|
||||
self.assertEqual(self.sale_order.picking_ids.move_ids.move_orig_ids, mo.move_finished_ids)
|
||||
mo.action_cancel()
|
||||
self.assertEqual(self.sale_order.picking_ids.state, 'confirmed')
|
||||
self.assertFalse(self.sale_order.picking_ids.move_ids.move_orig_ids)
|
||||
self.sale_order.picking_ids.action_assign()
|
||||
self.assertEqual(self.sale_order.picking_ids.move_ids.quantity, 1.0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue