[IMP] stock: Improved stock ymls and demo data.

bzr revid: uco@tinyerp.com-20111213101511-j3b8paqfplgu83o1
This commit is contained in:
Ujjvala Collins (OpenERP) 2011-12-13 15:45:11 +05:30
parent 1adc056c6b
commit eff096d946
11 changed files with 116 additions and 151 deletions

View File

@ -322,7 +322,7 @@
<field name="categ_id" ref="product_category_10"/>
</record>
<record id="product_product_ice" model="product.product">
<field name="default_code">Ice</field>
<field name="default_code">ICE</field>
<field name="supply_method">buy</field>
<field name="list_price">100.0</field>
<field name="standard_price">70.0</field>
@ -330,7 +330,7 @@
<field name="uom_po_id" ref="product_uom_kgm"/>
<field name="procure_method">make_to_stock</field>
<field name="sale_delay">1.0</field>
<field name="name">Ice cream</field>
<field name="name">Ice Cream</field>
<field name="type">product</field>
<field name="categ_id" ref="product_category_marketableproduct0"/>
</record>

View File

@ -84,10 +84,9 @@ Thanks to the double entry management, the inventory controlling is powerful and
'test': [
'test/stock_physical_inventory.yml',
'test/stock_update.yml',
'test/stock_chain_location.yml',
'test/stock_demo_backorder.yml',
'test/delete_stock.yml',
'test/cancel_stock.yml',
'test/stock_report.yml',
],
'installable': True,
'application': True,

View File

@ -91,7 +91,6 @@
<field name="location_id" ref="stock_location_locations"/>
</record>
<record id="journal_delivery" model="stock.journal">
<field name="name">Delivery Orders</field>
</record>
@ -104,7 +103,6 @@
<field name="chained_picking_type">out</field>
<field name="chained_journal_id" ref="journal_delivery"/>
</record>
<record id="stock_location_stock" model="stock.location">
<field name="name">Stock</field>
<field name="location_id" ref="stock_location_company"/>

View File

@ -51,7 +51,7 @@
<field name="location_id" ref="stock_location_stock"/>
</record>
<record id="convenience_location_stock" model="stock.location">
<field name="name">Convenience Store</field>
<field name="name">Convenient Store</field>
<field name="location_id" ref="stock_location_company"/>
<field name="chained_auto_packing">auto</field>
<field name="chained_location_type">fixed</field>

View File

@ -23,4 +23,3 @@
location_id: stock.stock_location_stock
name: CPU3, Processor AMD Athlon XP 1800
picking_id: stock_picking_1

View File

@ -1,34 +1,35 @@
-
In order to test the cancel stock. I start from cancelling the delivery order.
In order to test the cancel process in stock, I test by cancelling the delivery order.
-
First, I create copies of delivery order.
I create two delivery orders to check cancel process with two different ways.
-
!python {model: stock.picking}: |
stock = self.pool.get('stock.move')
context.update({'active_id':ref('stock.stock_picking_1')})
id1 = self.copy(cr, uid, ref('stock.stock_picking_1'), context)
id2 = self.copy(cr, uid, ref('stock.stock_picking_1'), context)
context.update({'id1':id1,'id2':id2})
context.update({'id1': id1,'id2': id2})
-
Directlly cancel the delivery order.
I cancel a delivery order which is in draft state.
-
!python {model: stock.picking}: |
import netsvc
wf_service = netsvc.LocalService("workflow")
pick_id = context.get('id2')
picking = self.browse(cr, uid, pick_id, context=context)
wf_service.trg_validate(uid, 'stock.picking', pick_id, 'button_cancel', cr)
assert picking.state == 'cancel',"Delivery order should be cancelled."
-
Now, I cancel all related stock moves of delivery order so automatically delivery order goes to cancelled state.
Now, I cancel all related stock moves of another delivery order so automatically delivery order goes to cancelled state.
-
!python {model: stock.picking}: |
import netsvc
wf_service = netsvc.LocalService("workflow")
stock = self.pool.get('stock.move')
pick = self.browse(cr, uid, context.get('id1'))
move_ids = stock.search(cr, uid, [('picking_id','=',pick.name)])
for move in move_ids:
wf_service.trg_validate(uid, 'stock.move', move, 'action_confirm', cr)
stock.force_assign(cr, uid, move)
wf_service.trg_validate(uid, 'stock.move', move, 'action_cancel', cr)
move_obj = self.pool.get('stock.move')
picking = self.browse(cr, uid, context.get('id1'))
move_ids = move_obj.search(cr, uid, [('picking_id','=',picking.id)])
move_obj.action_confirm(cr, uid, move_ids)
move_obj.force_assign(cr, uid, move_ids)
move_obj.action_cancel(cr, uid, move_ids)
assert picking.state == 'cancel',"Delivery order should be cancelled."

View File

@ -1,23 +0,0 @@
-
In order to test the delete stock, create a copy of delivery order.
-
!python {model: stock.picking}: |
context.update({'active_id':ref('stock.stock_picking_1')})
id1 = self.copy(cr, uid, ref('stock.stock_picking_1'), context)
pick = self.browse(cr, uid, ref('stock.stock_picking_1'))
stock = self.pool.get('stock.move')
move_ids = stock.search(cr, uid, [('picking_id','=',pick.name)])
move_id = stock.copy(cr, uid, move_ids[0],context)
context.update({'id1':id1,'move':move_id})
-
I delete a related moves of delivery order.
-
!python {model: stock.move}: |
move = context.get('move')
self.unlink(cr, uid, [move])
-
Now, directe delete the delivery order.
-
!python {model: stock.picking}: |
id = context.get('id1')
self.unlink(cr, uid, [id])

View File

@ -1,57 +0,0 @@
-
In order to test chained locations, I update the stock of product.
-
I update product quantity and check the stock moves are properly done or not.
-
!python {model: product.product}: |
change_qty = self.pool.get('stock.change.product.qty')
product = self.browse(cr, uid, ref('product.product_product_ice'))
ids = change_qty.create(cr, uid, {'location_id' : ref('convenience_location_stock'), 'new_quantity': 5, 'product_id': product.id})
change_qty.change_product_qty(cr, uid, [ids], {'active_model':'product.product', 'active_id': product.id, 'active_ids':[product.id]})
-
I check stock moves of product.
-
!python {model: stock.move}: |
ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice'))])
for move in self.browse(cr, uid, ids):
assert move.product_qty >= 1,"Product is not correspond"
if move.location_id.name == 'Inventory loss':
assert move.location_dest_id.name == 'Convenience Store',"Destination location must be 'Convenience Store'"
if move.location_id.name == 'Convenience Store':
assert move.location_dest_id.name == 'Cold Storage',"Destination location must be 'Cold Storage' because the source location is 'Convenience Store'"
if move.location_id.name == 'Cold Storage':
assert move.location_dest_id.name == 'Customers',"Destination location must be 'Customers' because the source location is 'Cold Storage'"
-
I create a move and scrap some quantities from it.
-
!python {model: stock.move.scrap}: |
ids = self.pool.get('stock.move').search(cr, uid, [('product_id','=',ref('product.product_product_ice')),('location_dest_id','=',ref('stock_location_customers'))])
self.pool.get('stock.move').browse(cr, uid, ids)[0]
context = {'active_model':'stock.move', 'active_id':ids[0],'active_ids': ids}
values = self.default_get(cr, uid, ['location_id','product_id','product_uom','product_qty'], context)
scrap_ids = self.create(cr, uid, values)
self.move_scrap(cr, uid, [scrap_ids], context)
-
I check scraped move details.
-
!python {model: stock.move}: |
ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice')),('location_dest_id','=',ref('stock_location_customers'))])
for scrap_move in self.browse(cr, uid, ids):
if scrap_move.product_qty == 5.0 and scrap_move.location_dest_id == ref('stock_location_scrapped'):
assert scrap_move.state == 'done',"The scraped move should be in Done state"
-
I split a move in to different quantities.
-
!python {model: stock.move }: |
import time
ids = self.pool.get('stock.move').search(cr, uid, [('product_id','=',ref('product.product_product_ice')),('location_dest_id','=',ref('stock_location_customers'))])
old_move=self.browse(cr,uid,ids)[0]
context = {'active_model': 'stock.move','active_id':ids[0],'active_ids': ids}
tracking_id = self.pool.get('stock.tracking').create(cr, uid, {'name': '0000007', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
self.write(cr, uid, ids, {'tracking_id': tracking_id})
split_obj=self.pool.get('stock.split.into')
split_id = split_obj.create(cr, uid, {'quantity': 1 })
split_obj.split(cr, uid, [split_id], context)
all_ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice'))])
new_move=self.browse(cr,uid,all_ids)[-1]
assert not old_move.tracking_id == new_move.tracking_id,"After spliting the move, new move should be created with new pack"

View File

@ -6,7 +6,7 @@
!record {model: stock.inventory, id: stock_physical_inventory0}:
name: Physical inventory
-
I create record using create method.
I define and fill the inventory.
-
!python {model: stock.fill.inventory}: |
ids = self.create(cr, uid, {'location_id': ref('stock_location_components'),'set_stock_zero': True})
@ -18,14 +18,14 @@
!python {model: stock.inventory}: |
inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')])[0]
self.action_confirm(cr,uid,[inventory.id])
assert inventory.state == 'confirm',"Inventory should be in 'Confirm' state"
assert inventory.state == 'confirm',"Inventory should be in 'Confirmed' state."
if inventory.inventory_line_id:
for line in inventory.inventory_line_id:
assert line.product_qty == 0.0,"Product Quantity should be Zero"
assert line.product_qty == 0.0,"Product quantity should be Zero."
assert len(inventory.move_ids) >= 1,"Move should be created after confirmed inventory"
for move in inventory.move_ids:
assert move.location_id.id == ref('stock_location_components'),"Source location of move is not correspond."
assert move.location_dest_id.id == ref('location_inventory'),"Destination location of move should be 'Inventory loss'."
assert move.location_id.id == ref('stock_location_components'),"Source location of move is not corresponding."
assert move.location_dest_id.id == ref('location_inventory'),"Destination location of move is not corresponding."
-
I validate the inventory after confirmation.
-

View File

@ -0,0 +1,42 @@
-
In order to test the PDF reports defined on a stock, I print a Stock Overviewall(children) report.
-
!python {model: stock.location}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.lot.stock.overview_all').create(cr, uid, [ref('stock.stock_location_stock')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-overviewall'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on stock inventory, I print a Stock Inventory Move report.
-
!python {model: stock.inventory}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.stock.inventory.move').create(cr, uid, [ref('stock.stock_inventory_0')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-stock_inventory_move.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a stock, I print a stock overview report.
-
!python {model: stock.location}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.lot.stock.overview').create(cr, uid, [ref('stock.stock_location_14')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-overview'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a stock, I print a Delivery order List report.
-
!python {model: stock.picking}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.stock.picking.list').create(cr, uid, [ref('stock.stock_picking_1')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-picking_list'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a stock, I print product stock Report.
-
!python {model: product.product}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.stock.product.history').create(cr, uid, [ref('product.product_product_pc1')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-product_stock_report.'+format), 'wb+').write(data)

View File

@ -4,23 +4,23 @@
I assign the location.
-
!record {model: stock.warehouse, id: stock.warehouse0}:
lot_stock_id: stock_location_stock
lot_stock_id: cold_location_1
-
I create stock production lot for product.
-
!record {model: stock.production.lot, id: stock_production_lot0}:
product_id: product.product_product_cpu2
product_id: product.product_product_ice
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
name: 0000001
-
I take product and with the help of 'Change Product Quantity' wizard update the product stock.
I update product quantity and check the stock moves are properly done or not.
-
!python {model: product.product}: |
change_qty = self.pool.get('stock.change.product.qty')
product = self.browse(cr, uid, ref('product.product_product_cpu2'))
ids = change_qty.create(cr, uid, {'location_id' : ref('stock_location_stock'), 'new_quantity': 5, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot0')})
product = self.browse(cr, uid, ref('product.product_product_ice'))
ids = change_qty.create(cr, uid, {'location_id' : ref('cold_location_1'), 'new_quantity': 5, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot0')})
change_qty.change_product_qty(cr, uid, [ids], {'active_model':'product.product', 'active_id': product.id, 'active_ids':[product.id]})
assert product.qty_available == 5,'Product Quantity is not Updated'
assert product.qty_available == 5,"Product quantity is not updated."
-
I trace the stock production lot for product.
-
@ -30,55 +30,61 @@
I check that physical inventory created.
-
!python {model: stock.inventory.line}: |
ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_cpu2'))])
ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice'))])
inventory = self.browse(cr, uid, ids)[0]
assert inventory.product_qty == 5,'product Quantity is not correspond'
assert inventory.location_id.id == ref('stock_location_stock'), 'Location is not correspond'
assert inventory.state == 'done', 'State should be in Done state'
assert inventory.product_qty == 5,'Product quantity is not corresponding.'
assert inventory.location_id.id == ref('cold_location_1'), 'Location is not corresponding.'
assert inventory.state == 'done', "State should be in 'Done' state."
-
I check that stock moves created.
-
!python {model: stock.move}: |
ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_cpu2'))])
assert [x.state for x in self.browse(cr, uid, ids) if x.state == 'done'], 'stock moves should be done!'
ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice'))])
assert [x.state for x in self.browse(cr, uid, ids) if x.state == 'done'], 'Stock moves should be done!'
-
In order to test the PDF reports defined on a stock, I print a Stock Overviewall(children) report.
I check stock moves of product.
-
!python {model: stock.location}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.lot.stock.overview_all').create(cr, uid, [ref('stock.stock_location_stock')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-overviewall'+format), 'wb+').write(data)
!python {model: stock.move}: |
ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice'))])
for move in self.browse(cr, uid, ids):
assert move.product_qty >= 1,"Product is not corresponding."
if move.location_id.id == ref('stock_physical_inventory0'):
assert move.location_dest_id.id == ref('convenience_location_stock'),"Destination location must be 'Convenient Store'"
if move.location_id.id == ref('convenience_location_stock'):
assert move.location_dest_id.id == ref('cold_location_1'),"Destination location must be 'Cold Storage' because the source location is 'Convenient Store'"
if move.location_id.id == ref('cold_location_1'):
assert move.location_dest_id.id == ref('stock_location_customers'),"Destination location must be 'Customers' because the source location is 'Cold Storage'"
-
In order to test the PDF reports defined on stock inventory, I print a Stock Inventory Move report.
I create a move and scrap some quantities from it.
-
!python {model: stock.inventory}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.stock.inventory.move').create(cr, uid, [ref('stock.stock_inventory_0')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-stock_inventory_move.'+format), 'wb+').write(data)
!python {model: stock.move.scrap}: |
ids = self.pool.get('stock.move').search(cr, uid, [('product_id','=',ref('product.product_product_ice')),('location_dest_id','=',ref('stock_location_customers'))])
self.pool.get('stock.move').browse(cr, uid, ids)[0]
context = {'active_model':'stock.move', 'active_id':ids[0],'active_ids': ids}
values = self.default_get(cr, uid, ['location_id','product_id','product_uom','product_qty'], context)
scrap_ids = self.create(cr, uid, values)
self.move_scrap(cr, uid, [scrap_ids], context)
-
In order to test the PDF reports defined on a stock, I print a stock overview report.
I check scraped move details.
-
!python {model: stock.location}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.lot.stock.overview').create(cr, uid, [ref('stock.stock_location_14')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-overview'+format), 'wb+').write(data)
!python {model: stock.move}: |
ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice')),('location_dest_id','=',ref('stock_location_customers'))])
for scrap_move in self.browse(cr, uid, ids):
if scrap_move.product_qty == 5.0 and scrap_move.location_dest_id == ref('stock_location_scrapped'):
assert scrap_move.state == 'done',"The scraped move should be in 'Done' state."
-
In order to test the PDF reports defined on a stock, I print a Delivery order List report.
I split a move in to different quantities.
-
!python {model: stock.picking}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.stock.picking.list').create(cr, uid, [ref('stock.stock_picking_1')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-picking_list'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a stock, I print product stock Report.
-
!python {model: product.product}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.stock.product.history').create(cr, uid, [ref('product.product_product_pc1')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-product_stock_report.'+format), 'wb+').write(data)
!python {model: stock.move }: |
import time
ids = self.pool.get('stock.move').search(cr, uid, [('product_id','=',ref('product.product_product_ice')),('location_dest_id','=',ref('stock_location_customers'))])
old_move=self.browse(cr,uid,ids)[0]
context = {'active_model': 'stock.move','active_id':ids[0],'active_ids': ids}
tracking_id = self.pool.get('stock.tracking').create(cr, uid, {'name': '0000007', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
self.write(cr, uid, ids, {'tracking_id': tracking_id})
split_obj=self.pool.get('stock.split.into')
split_id = split_obj.create(cr, uid, {'quantity': 1 })
split_obj.split(cr, uid, [split_id], context)
all_ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice'))])
new_move=self.browse(cr,uid,all_ids)[-1]
assert not old_move.tracking_id == new_move.tracking_id,"After spliting the move, new move should be created with new pack."