test_picking_split.yml 2.85 KB
Newer Older
François C. committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
-
  In order to test stock picking out spliting
  I have to ensure when I split out picking, related backorder is not in state done
-
  I create a new GameBoy product for my tests
-
  !record {model: product.product, id: product_gameboy}:
    categ_id: product.product_category_1
    name: GameBoy
    type: product
    uom_id: product.product_uom_unit
    uom_po_id: product.product_uom_unit
    property_stock_inventory: stock.location_inventory
    property_stock_procurement: stock.location_procurement
    property_stock_production: stock.location_production
-
  I create a manual stock picking out
-
 !record {model: stock.picking, id: outgoing_shipment_gameboy}:
    picking_type_id: stock.picking_type_out
    origin: 'outgoing shipment main_warehouse'
    partner_id: base.res_partner_6
    move_lines:
      - product_id: product_gameboy
        product_uom: product.product_uom_unit
        product_uom_qty: 130.0
        product_uos_qty: 130.0
        picking_type_id: stock.picking_type_out
        location_id: stock.stock_location_stock
        location_dest_id: stock.stock_location_7
-
  I confirm the picking
-
 !python {model: stock.picking, id: outgoing_shipment_gameboy}:
     self.action_confirm()
-
  Then I split my shippement in two 40/90
-
  !python {model: stock.transfer_details}: |
    context.update({'active_model': 'stock.picking',
                    'active_id': ref('outgoing_shipment_gameboy'),
                    'active_ids': [ref('outgoing_shipment_gameboy')]})
-
  !record {model: stock.transfer_details, id: partial_pick}:
    picking_id: outgoing_shipment_gameboy
    item_ids:
        - quantity: 40
          product_id: product_gameboy
          product_uom_id: product.product_uom_unit
          sourceloc_id: stock.stock_location_stock
          destinationloc_id: stock.stock_location_7
-
  !python {model: stock.transfer_details}: |
    wiz = self.browse(cr, uid, ref("partial_pick"))
    wiz.with_context(do_only_split=True).do_detailed_transfer()
-
  I check that the backorder has 40 units with state set to assigned not done
-
  !python {model: stock.picking, id: outgoing_shipment_gameboy}: |
    # we switch self and backorder to mimick what Odoo is doing
    # When creating a backorder
    self = self.search([('backorder_id', '=', self.id)])
    backorder = self.backorder_id
    assert backorder, "Backorder should be created after partial split."
    assert backorder.state == 'confirmed', "Backorder should not be close."
    for move_line in backorder.move_lines:
        assert move_line.product_qty == 40, "Qty in backorder does not correspond."
        assert move_line.state == 'confirmed', "Move line of backorder should not be closed."
    for move_line in self.move_lines:
        assert move_line.product_qty == 90, "Qty in backorder does not correspond."
        assert move_line.state == 'confirmed', "Move line of backorder should not be closed."