-
  I first create a new product
-
    !record {model: product.product, id: move_product}:
         name: move prod
         type: product
-
  In order to test the negative quants, I create a move of 5 products from stock to customer
-
  !record {model: stock.move, id: move_test0}:
    name: Move Products
    product_id: move_product
    product_uom_qty: 5
    product_uom: product.product_uom_unit
    product_uos_qty: 5
    product_uos: product.product_uom_unit
    location_id: stock.stock_location_stock
    location_dest_id: stock.stock_location_customers
-
  I confirm the move to be processed in the future
-
  !python {model: stock.move}: |
    self.action_confirm(cr, uid, [ref('move_test0')], context=context)
-
  I check that the quantity on hand is 0 and virtual is -5
-
  !python {model: product.product}: |
    context['location'] = False
    product = self.browse(cr, uid, ref('move_product'), context=context)
    assert product.qty_available == 0, 'Expecting 0 products in stock, got %.2f!' % (product.qty_available,)
    assert product.virtual_available == -5.0, 'Expecting -5 products in virtual stock, got %.2f!' % (product.virtual_available,)
-
  I validate the move
-
  !python {model: stock.move}: |
    self.action_done(cr, uid, [ref('move_test0')], context=context)
-
  I check that the quantity on hand is -5 and 5 products are at customer location
-
  !python {model: product.product}: |
    context['location'] = False
    product = self.browse(cr, uid, ref('move_product'), context=context)
    assert product.qty_available == -5, 'Expecting -5 products in stock, got %.2f!' % (product.qty_available,)

    context['location'] = ref('stock.stock_location_customers')
    product = self.browse(cr, uid, ref('move_product'), context=context)
    assert product.qty_available == 5, 'Expecting 5 products in customer location, got %.2f!' % (product.qty_available,)
-
  To compensate negative quants, I will receive 15 products from the supplier
-
  !record {model: stock.move, id: move_test2}:
    name: Move 15 Products
    product_id: move_product
    product_uom_qty: 15
    product_uom: product.product_uom_unit
    product_uos_qty: 15
    product_uos: product.product_uom_unit
    location_id: stock.stock_location_suppliers
    location_dest_id: stock.stock_location_stock
-
  I confirm and validate the move
-
  !python {model: stock.move}: |
    self.action_confirm(cr, uid, [ref('move_test2')], context=context)
    self.action_done(cr, uid, [ref('move_test2')], context=context)
-
  I check that the quantity on hand is 10
-
  !python {model: product.product}: |
    context['location'] = False
    product = self.browse(cr, uid, ref('move_product'), context=context)
    assert product.qty_available == 10, 'Expecting 10 products in stock, got %.2f!' % (product.qty_available,)
    assert product.virtual_available == 10.0, 'Expecting 10 products in virtual stock, got %.2f!' % (product.virtual_available,)
-
  I create a move of 2 products from stock to customer
-
  !record {model: stock.move, id: move_test1}:
    name: Move Products
    product_id: move_product
    product_uom_qty: 2
    product_uom: product.product_uom_unit
    product_uos_qty: 2
    product_uos: product.product_uom_unit
    location_id: stock.stock_location_stock
    location_dest_id: stock.stock_location_customers
-
  I confirm the move to be processed in the future
-
  !python {model: stock.move}: |
    self.action_confirm(cr, uid, [ref('move_test1')], context=context)
-
  I check that the quantity on hand is 10 and virtual is 8
-
  !python {model: product.product}: |
    context['location'] = False
    product = self.browse(cr, uid, ref('move_product'), context=context)
    assert product.qty_available == 10, 'Expecting 10 products in stock, got %.2f!' % (product.qty_available,)
    assert product.virtual_available == 8.0, 'Expecting 8 products in virtual stock, got %.2f!' % (product.virtual_available,)
-
  I validate the move
-
  !python {model: stock.move}: |
    self.action_done(cr, uid, [ref('move_test1')], context=context)
-
  I check that the quantity on hand is 8 and 7 products are at customer location
-
  !python {model: product.product}: |
    context['location'] = False
    product = self.browse(cr, uid, ref('move_product'), context=context)
    assert product.qty_available == 8, 'Expecting 10 products in stock, got %.2f!' % (product.qty_available,)

    context['location'] = ref('stock.stock_location_customers')
    product = self.browse(cr, uid, ref('move_product'), context=context)
    assert product.qty_available == 7, 'Expecting 7 products in customer location, got %.2f!' % (product.qty_available,)
