2 I first create a new product
4 !record {model: product.product, id: move_product}:
8 In order to test the negative quants, I create a move of 5 products from stock to customer
10 !record {model: stock.move, id: move_test0}:
12 product_id: move_product
14 product_uom: product.product_uom_unit
16 product_uos: product.product_uom_unit
17 location_id: stock.stock_location_stock
18 location_dest_id: stock.stock_location_customers
20 I confirm the move to be processed in the future
22 !python {model: stock.move}: |
23 self.action_confirm(cr, uid, [ref('move_test0')], context=context)
25 I check that the quantity on hand is 0 and virtual is -5
27 !python {model: product.product}: |
28 context['location'] = False
29 product = self.browse(cr, uid, ref('move_product'), context=context)
30 assert product.qty_available == 0, 'Expecting 0 products in stock, got %.2f!' % (product.qty_available,)
31 assert product.virtual_available == -5.0, 'Expecting -5 products in virtual stock, got %.2f!' % (product.virtual_available,)
35 !python {model: stock.move}: |
36 self.action_done(cr, uid, [ref('move_test0')], context=context)
38 I check that the quantity on hand is -5 and 5 products are at customer location
40 !python {model: product.product}: |
41 context['location'] = False
42 product = self.browse(cr, uid, ref('move_product'), context=context)
43 assert product.qty_available == -5, 'Expecting -5 products in stock, got %.2f!' % (product.qty_available,)
45 context['location'] = ref('stock.stock_location_customers')
46 product = self.browse(cr, uid, ref('move_product'), context=context)
47 assert product.qty_available == 5, 'Expecting 5 products in customer location, got %.2f!' % (product.qty_available,)
49 To compensate negative quants, I will receive 15 products from the supplier
51 !record {model: stock.move, id: move_test2}:
52 name: Move 15 Products
53 product_id: move_product
55 product_uom: product.product_uom_unit
57 product_uos: product.product_uom_unit
58 location_id: stock.stock_location_suppliers
59 location_dest_id: stock.stock_location_stock
61 I confirm and validate the move
63 !python {model: stock.move}: |
64 self.action_confirm(cr, uid, [ref('move_test2')], context=context)
65 self.action_done(cr, uid, [ref('move_test2')], context=context)
67 I check that the quantity on hand is 10
69 !python {model: product.product}: |
70 context['location'] = False
71 product = self.browse(cr, uid, ref('move_product'), context=context)
72 assert product.qty_available == 10, 'Expecting 10 products in stock, got %.2f!' % (product.qty_available,)
73 assert product.virtual_available == 10.0, 'Expecting 10 products in virtual stock, got %.2f!' % (product.virtual_available,)
75 I create a move of 2 products from stock to customer
77 !record {model: stock.move, id: move_test1}:
79 product_id: move_product
81 product_uom: product.product_uom_unit
83 product_uos: product.product_uom_unit
84 location_id: stock.stock_location_stock
85 location_dest_id: stock.stock_location_customers
87 I confirm the move to be processed in the future
89 !python {model: stock.move}: |
90 self.action_confirm(cr, uid, [ref('move_test1')], context=context)
92 I check that the quantity on hand is 10 and virtual is 8
94 !python {model: product.product}: |
95 context['location'] = False
96 product = self.browse(cr, uid, ref('move_product'), context=context)
97 assert product.qty_available == 10, 'Expecting 10 products in stock, got %.2f!' % (product.qty_available,)
98 assert product.virtual_available == 8.0, 'Expecting 8 products in virtual stock, got %.2f!' % (product.virtual_available,)
102 !python {model: stock.move}: |
103 self.action_done(cr, uid, [ref('move_test1')], context=context)
105 I check that the quantity on hand is 8 and 7 products are at customer location
107 !python {model: product.product}: |
108 context['location'] = False
109 product = self.browse(cr, uid, ref('move_product'), context=context)
110 assert product.qty_available == 8, 'Expecting 10 products in stock, got %.2f!' % (product.qty_available,)
112 context['location'] = ref('stock.stock_location_customers')
113 product = self.browse(cr, uid, ref('move_product'), context=context)
114 assert product.qty_available == 7, 'Expecting 7 products in customer location, got %.2f!' % (product.qty_available,)