hunk.code_window:     Use 'Receive Products' button to immediately view this picking, it should have created a picking with 200 pieces
   -
       !python {model: purchase.order}: |
            po_id = self.search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))])
            self.view_picking(cr, uid, po_id)
   -
       Send the 200 pieces.
   - 
  
hunk.labels: keep keep keep keep replace keep keep keep
hunk.after_edit:          assert len(po_id) == 1, 'There should be one picking'
  
hunk.file_path: addons/stock_dropshipping/test/dropship.yml
hunk.type: replace
file: -
      Create a vendor
  -
    !record {model: res.partner, id: supplier_dropship}:
      name: Vendor of Dropshipping test
  - 
      Create new product without any routes
  - 
      !record {model: product.product, id: drop_shop_product}:
          name: Pen drive
          type: product
          categ_id: product.product_category_1
          list_price: 100.0
          standard_price: 0.0
          type: product
          seller_ids:
            - delay: 1
              name: supplier_dropship
              min_qty: 2.0
              qty: 5.0
          uom_id: product.product_uom_unit
          uom_po_id: product.product_uom_unit
  - 
      Create a sales order with a line of 200 PCE incoming shipment, with route_id drop shipping.
  - 
      !record {model: sale.order, id: sale_order_drp_shpng}:
            partner_id: base.res_partner_2
            note: Create sale order for drop shipping
            payment_term_id: account.account_payment_term
            order_line: 
              - product_id: drop_shop_product
                product_uom_qty: 200
                price_unit: 1.00
                route_id: route_drop_shipping
  - 
      Confirm sales order
  - 
      !python {model: sale.order}: |
          self.action_confirm(cr, uid, ref("sale_order_drp_shpng"), context=context)
  - 
      Check the sales order created a procurement group which has a procurement of 200 pieces
  - 
      !python {model: procurement.group}: |
          sale_record = self.pool.get("sale.order").browse(cr, uid, ref('sale_order_drp_shpng'))
          assert self.browse(cr, uid, sale_record.procurement_group_id.id).procurement_ids[0].product_qty == 200
  - 
      Check a quotation was created to a certain vendor and confirm so it becomes a confirmed purchase order
  -
      !python {model: purchase.order}: |
          from openerp import netsvc, workflow
          sale_record = self.pool.get("sale.order").browse(cr, uid, ref('sale_order_drp_shpng'))
          procurement_order = self.pool.get("procurement.group").browse(cr, uid, sale_record.procurement_group_id.id).procurement_ids[0]
          purchase_id = procurement_order.purchase_line_id.order_id.id
          
          workflow.trg_validate(uid, 'purchase.order', purchase_id, 'purchase_confirm', cr)
          po_id = self.pool.get('purchase.order').search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))])
          assert self.browse(cr, uid, purchase_id).state == 'approved', 'Purchase order should be in the approved state'
  - 
      Use 'Receive Products' button to immediately view this picking, it should have created a picking with 200 pieces
  -
      !python {model: purchase.order}: |
           po_id = self.search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))])
           self.view_picking(cr, uid, po_id)
  -
      Send the 200 pieces.
  - 
      !python {model: stock.picking}: |
          po_id = self.pool.get('purchase.order').search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))])
          assert po_id and len(po_id) == 1, 'Problem with the Purchase Order detected'
          picking_ids = [pick.id for pick in self.pool.get('purchase.order').browse(cr, uid, po_id[0]).picking_ids]
          self.do_transfer(cr, uid, picking_ids)
  - 
    Check one quant was created in Customers location with 200 pieces and one move in the history_ids
  - 
      !python {model: stock.quant}: |
          quant_ids = self.search(cr, uid, [('location_id', '=', ref('stock.stock_location_customers')), ('product_id', '=', ref("drop_shop_product"))])
          assert quant_ids, 'No Quant found'
          assert len(quant_ids) == 1, 'There should be exactly one quant'
          assert len(self.browse(cr, uid, quant_ids)[0].history_ids) == 1, 'The quant should have exactly 1 move in its history'
  