[IMP] inventory yaml fixed (merged from csn branch then improved)
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Mon, 2 Sep 2013 14:37:43 +0000 (16:37 +0200)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Mon, 2 Sep 2013 14:37:43 +0000 (16:37 +0200)
bzr revid: qdp-launchpad@openerp.com-20130902143743-rup39393lk6bs5xk

1  2 
addons/stock/product.py
addons/stock/stock.py
addons/stock/test/inventory.yml

@@@ -208,6 -208,6 +208,7 @@@ class product_product(osv.osv)
          'track_outgoing': fields.boolean('Track Outgoing Lots', help="Forces to specify a Serial Number for all moves containing this product and going to a Customer Location"),
          'location_id': fields.dummy(string='Location', relation='stock.location', type='many2one'),
          'warehouse_id': fields.dummy(string='Warehouse', relation='stock.warehouse', type='many2one'),
++        'orderpoint_ids': fields.one2many('stock.warehouse.orderpoint', 'product_id', 'Minimum Stock Rules'),
      }
  
      def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
@@@ -258,6 -258,6 +259,7 @@@ class product_template(osv.osv)
      _name = 'product.template'
      _inherit = 'product.template'
      _columns = {
++        'type': fields.selection([('product', 'Stockable Product'), ('consu', 'Consumable'), ('service', 'Service')], 'Product Type', required=True, help="Consumable: Will not imply stock management for this product. \nStockable product: Will imply stock management for this product."),
          'property_stock_procurement': fields.property(
              type='many2one',
              relation='stock.location',
@@@ -2272,19 -2087,19 +2273,12 @@@ class stock_warehouse_orderpoint(osv.os
  class product_template(osv.osv):
      _inherit = "product.template"
      _columns = {
--        'type': fields.selection([('product', 'Stockable Product'), ('consu', 'Consumable'), ('service', 'Service')], 'Product Type', required=True, help="Consumable: Will not imply stock management for this product. \nStockable product: Will imply stock management for this product."),
          'supply_method': fields.selection([('produce', 'Manufacture'), ('buy', 'Buy'), ('wait', 'None')], 'Supply Method', required=True, help="Manufacture: When procuring the product, a manufacturing order or a task will be generated, depending on the product type. \nBuy: When procuring the product, a purchase order will be generated."),
      }
      _defaults = {
          'supply_method': 'buy',
      }
  
--class product_product(osv.osv):
--    _inherit = "product.product"
--    _columns = {
--        'orderpoint_ids': fields.one2many('stock.warehouse.orderpoint', 'product_id', 'Minimum Stock Rules'),
--    }
--
  class stock_picking_code(osv.osv):
      _name = "stock.picking.code"
      _description = "Will group picking types for kanban view"
  -
-   I create an inventory of 10 products
 -  I create an inventory
++  In order to test the inventory, I create a new product
++-
++    !record {model: product.product, id: inventory_product}:
++         name: inventory prod
++         type: product
++-
++  I create an inventory for this product only
  -
    !record {model: stock.inventory, id: inventory_test0}:
      name: Test
-     inventory_line_id:
-       - product_id: product.product_product_3
-         product_qty: 10
-         location_id: stock.stock_location_14
++    product_id: inventory_product
++
+ -
+   I create the wizard to confirm the inventory
+ -
+   !record {model: stock.fill.inventory, id: inventory_test0_wizard}:
+     set_stock_zero: False
+ -
+   I fill this inventory
+ -
+   !python {model: stock.inventory.line}: |
+     context = {'active_ids': [ref('inventory_test0')]}
+     self.pool.get('stock.fill.inventory').fill_inventory(cr, uid, [ref('inventory_test0_wizard')], context=context)
+ -
 -  I create an inventory line with 10 product
++  I check that my inventory has no line, as the product is a new one.
++-
++  !python {model: stock.inventory}: |
++    inv = self.browse(cr, uid, ref('inventory_test0'), context=context)
++    assert len(inv.line_ids) == 0, "Wrong number of inventory lines."
++-
++  I add an inventory line and say i have 10 products in stock
+ -
+   !record {model: stock.inventory.line, id: inventory_testline0}:
+     inventory_id: stock.inventory_test0
 -    product_id: product.product_product_3
++    product_id: inventory_product
+     product_qty: 10
+     location_id: stock.stock_location_14
  -
-   I post this inventory
+   I confirm this inventory
  -
    !python {model: stock.inventory}: |
-     self.action_confirm(cr, uid, [ref('inventory_test0')], context=context)
      self.action_done(cr, uid, [ref('inventory_test0')], context=context)
  -
    I check that this inventory has a stock.move and a quant
  -
    !python {model: stock.inventory}: |
      inv = self.browse(cr, uid, ref('inventory_test0'), context=context)
-     assert len(inv.move_ids) == 1, "No move created for the inventory."
+     assert len(inv.move_ids) >= 1, "No move created for the inventory."
      assert len(inv.move_ids[0].quant_ids) >= 1, "No quant created for this inventory"
  -
--  I check that the quantity on hand is 10 on the location and it's parent.
++  I check that the quantity on hand is 10 on the location and its parent.
  -
    !python {model: product.product}: |
      context['location'] = ref('stock.stock_location_14')
      product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
--    assert product.qty_available==10, 'Expecting 10 products, got %.2f on location stock_location_14!' % (product.qty_available,)
++    assert product.qty_available == 10, 'Expecting 10 products, got %.2f on location stock_location_14!' % (product.qty_available,)
      context['location'] = ref('stock.stock_location_stock')
      product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
--    assert product.qty_available==10, 'Expecting 10 products, got %.2f on location stock_location_stock!' % (product.qty_available,)
++    assert product.qty_available == 10, 'Expecting 10 products, got %.2f on location stock_location_stock!' % (product.qty_available,)
  -
    I check that the quantity on hand is 0 on a brother location
  -
    !python {model: product.product}: |
      context['location'] = ref('stock.stock_location_components')
      product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
--    assert product.qty_available==0, 'Expecting 0 products, got %.2f on location stock_location_components!' % (product.qty_available,)
++    assert product.qty_available == 0, 'Expecting 0 products, got %.2f on location stock_location_components!' % (product.qty_available,)
  -
-   I create an inventory of 20 products
+   I create another inventory
  -
    !record {model: stock.inventory, id: inventory_test1}:
--    name: Test
-     inventory_line_id:
-       - product_id: product.product_product_3
-         product_qty: 20
-         location_id: stock.stock_location_14
++    name: second test inventory 
++    product_id: inventory_product
  -
-   I post this new inventory
+   I fill this new inventory
  -
    !python {model: stock.inventory}: |
-     self.action_confirm(cr, uid, [ref('inventory_test1')], context=context)
-     self.action_done(cr, uid, [ref('inventory_test1')], context=context)
+     context = {'active_ids': [ref('inventory_test1')]}
+     self.pool.get('stock.fill.inventory').fill_inventory(cr, uid, [ref('inventory_test0_wizard')], context=context)
  -
-   I check that the quantity on hand is 20 on the location and it's parent.
 -  I create an inventory line with 20 product on this new inventory
++  I check that my inventory has one line, with a quantity of 10.
  -
-   !python {model: product.product}: |
-     context['location'] = ref('stock.stock_location_14')
-     product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
-     assert product.qty_available==20, 'Expecting 20 products, got %.2f on location stock_location_14!' % (product.qty_available,)
 -  !record {model: stock.inventory.line, id: inventory_testline0}:
 -    inventory_id: stock.inventory_test1
 -    product_id: product.product_product_3
 -    product_qty: 20
 -    location_id: stock.stock_location_14
++  !python {model: stock.inventory}: |
++    inv = self.browse(cr, uid, ref('inventory_test1'), context=context)
++    assert len(inv.line_ids) == 1, "Wrong number of inventory lines."
++    assert len(inv.line_ids[0].product_qty) == 10, "Wrong quantity in inventory line."
++    assert len(inv.line_ids[0].product_id.id) == ref('inventory_product'), "Wrong product in inventory line."
 +-
-   !record {model: stock.inventory, id: inventory_test2}:
-     name: Test
-     inventory_line_id:
-       - product_id: product.product_product_3
-         product_qty: 18
-         location_id: stock.stock_location_14
++  I modify the inventory line and set the quantity to 20 product on this new inventory
++-
++  !python {model: stock.inventory}: |
++    inv = self.browse(cr, uid, ref('inventory_test1'), context=context)
++    self.pool.get('stock.inventory.line').write(cr, uid, inv.line_ids[0].id, {'product_qty': 20})
  -
-   I post this new inventory
+   I confirm this inventory
  -
    !python {model: stock.inventory}: |
-     self.action_confirm(cr, uid, [ref('inventory_test2')], context=context)
-     self.action_done(cr, uid, [ref('inventory_test2')], context=context)
+     self.action_done(cr, uid, [ref('inventory_test1')], context=context)
  -
-   I check that the quantity on hand is 18 on the location and it's parent.
 -  I check that the quantity on hand is 20 on the location and it's parent.
++  I check that the quantity on hand is 20 on the location and its parent.
  -
    !python {model: product.product}: |
      context['location'] = ref('stock.stock_location_14')
--    product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
-     assert product.qty_available==18, 'Expecting 18 products, got %.2f on location stock_location_14!' % (product.qty_available,)
 -    assert product.qty_available==20, 'Expecting 20 products, got %.2f on location stock_location_14!' % (product.qty_available,)
++    product = self.browse(cr, uid, ref('inventory_product'), context=context)
++    assert product.qty_available == 20, 'Expecting 20 products, got %.2f on location stock_location_14!' % (product.qty_available,)