[MERGE] merged branch of dbr

bzr revid: hmo@tinyerp.com-20111219104512-spg1z8lqzw56cvio
This commit is contained in:
Harry (OpenERP) 2011-12-19 16:15:12 +05:30
commit 02414791f7
12 changed files with 294 additions and 540 deletions

View File

@ -321,6 +321,19 @@
<field name="type">product</field>
<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="supply_method">buy</field>
<field name="list_price">100.0</field>
<field name="standard_price">70.0</field>
<field name="uom_id" ref="product_uom_kgm"/>
<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="type">product</field>
<field name="categ_id" ref="product_category_marketableproduct0"/>
</record>
<record id="product_product_tow1" model="product.product">
<field name="default_code">TOW1</field>
<field name="list_price">37.5</field>

View File

@ -82,10 +82,11 @@ Thanks to the double entry management, the inventory controlling is powerful and
"board_warehouse_view.xml",
],
'test': [
'test/stock_test.yml',
'test/stock_physical_inventory.yml',
'test/stock_update.yml',
'test/stock_demo_backorder.yml',
'test/cancel_stock.yml',
'test/stock_report.yml',
'test/stock_test_wizard.yml',
'test/stock_demo_backorder.yml'
],
'installable': True,
'application': True,

View File

@ -9,6 +9,14 @@
<!--
Resource: stock.location
-->
<record id="cold_location_1" model="stock.location">
<field name="name">Cold Storage</field>
<field name="location_id" ref="stock_location_suppliers"/>
<field name="chained_location_type">fixed</field>
<field name="chained_location_id" ref="stock_location_customers"/>
<field name="chained_auto_packing">auto</field>
<field name="usage">internal</field>
</record>
<record id="stock_location_3" model="stock.location">
<field name="name">IT Suppliers</field>
<field name="location_id" ref="stock_location_suppliers"/>
@ -42,6 +50,14 @@
<field name="name">Shelf 1</field>
<field name="location_id" ref="stock_location_stock"/>
</record>
<record id="convenience_location_stock" model="stock.location">
<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>
<field name="usage">internal</field>
<field name="chained_location_id" ref="cold_location_1"/>
</record>
<!--
Resource: stock.inventory
@ -49,8 +65,6 @@
<record id="stock_inventory_0" model="stock.inventory">
<field name="name">Starting Inventory</field>
<field name="date_done">2005-08-02 13:42:43</field>
<field name="state">done</field>
</record>
<!--

View File

@ -0,0 +1,48 @@
-
In order to test the cancel process in stock, I test by cancelling the delivery order.
-
I create two delivery orders to check cancel process with two different ways.
-
!python {model: stock.picking}: |
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)
id3 = self.copy(cr, uid, ref('stock.stock_picking_1'), context)
context.update({'id1': id1,'id2': id2, 'id3': id3})
-
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')
self.cancel_assign(cr, uid, [pick_id])
picking = self.browse(cr, uid, pick_id, context=context)
self.allow_cancel(cr, uid, [pick_id], context= None)
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 another delivery order so automatically delivery order goes to cancelled state.
-
!python {model: stock.picking}: |
import netsvc
wf_service = netsvc.LocalService("workflow")
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."
-
Now I delete the stock move.
-
!python {model: stock.move}: |
picking = self.pool.get('stock.picking').browse(cr, uid, context.get('id3'))
move_id = self.search(cr, uid, [('picking_id','=',picking.id)])[0]
self.unlink(cr, uid, [move_id])
-
Now I delete the picking.
-
!python {model: stock.picking}: |
self.unlink(cr, uid, [context.get('id3')])

View File

@ -1,45 +1,48 @@
-
In order to test partial delivery and back orders, I will use a delivery order with 5 CPU1 and 5 CPU3
-
I confirm and force the availability of all products on the picking OUT001
-
In order to test partial delivery and back orders, I select delivery order and check process on it.
-
!record {model: stock.picking, id: stock_picking_1}:
invoice_state: '2binvoiced'
-
I confirm the Delivery order and make it available .
-
!python {model: stock.picking}: |
self.draft_force_assign(cr, uid, [ref('stock.stock_picking_1')], {})
self.draft_validate(cr, uid, [ref('stock.stock_picking_1')], {})
try:
self.action_assign(cr, uid, [ref('stock.stock_picking_1')], {})
except:
pass
self.force_assign(cr, uid, [ref('stock.stock_picking_1')], {})
-
After having confirmed the picking and its two lines, I add a new move line in draft state with 7 FAN2
I add a new move line in the delivery order.
-
!record {model: stock.move, id: stock_move_3}:
product_id: product.product_product_fan2
product_uom: product.product_uom_unit
product_uos_qty: 7.0
product_qty: 7.0
location_dest_id: stock.stock_location_customers
location_id: stock.stock_location_stock
name: CPU3, Processor AMD Athlon XP 1800
picking_id: stock_picking_1
- |
I click on 'Process Now' to process the delivery order and I change quantities to:
7 CPU1, 0 CPU3, 3 FAN2 and a new product of 4 PC1
-
Now, check the product availability for newly created move.
-
!python {model: stock.move}: |
self.action_assign(cr, uid, [ref('stock_move_3')])
-
I make partial delivery for the delivery order.
-
!python {model: stock.picking}: |
result = self.action_process(cr, uid, [ref('stock.stock_picking_1')], {})['res_id']
pick = self.pool.get('stock.partial.picking').browse(cr, uid, result, {})
lobj = self.pool.get('stock.partial.picking.line')
pick_line = self.pool.get('stock.partial.picking.line')
for line in pick.move_ids:
if line.product_id.id == ref('product.product_product_cpu3'):
lobj.write(cr, uid, [line.id], {
'quantity': 0.0
}, {})
pick_line.write(cr, uid, [line.id], {'quantity': 0.0}, {})
elif line.product_id.id == ref('product.product_product_cpu1'):
lobj.write(cr, uid, [line.id], {
'quantity': 7.0
}, {})
pick_line.write(cr, uid, [line.id], {'quantity': 7.0}, {})
elif line.product_id.id == ref('product.product_product_fan2'):
lobj.write(cr, uid, [line.id], {
'quantity': 3.0
}, {})
lobj.create(cr, uid, {
pick_line.write(cr, uid, [line.id], {'quantity': 3.0}, {})
pick_line.create(cr, uid, {
'product_id': ref('product.product_product_pc1'),
'quantity': 2.0,
'product_uom': ref('product.product_uom_unit'),
@ -48,18 +51,56 @@
'wizard_id': result
}, {})
self.pool.get('stock.partial.picking').do_partial(cr, uid, [result], {})
-
I test that the back order contains 5 CPU3, 4 FAN2 and nothing else
I Create Invoice for this picking.
-
!python {model: stock.invoice.onshipping}: |
ctx = {"active_model":"stock.picking", "active_ids": [ref("stock.stock_picking_1")], "active_id":ref("stock.stock_picking_1"), "search_default_available": 1, "inv_type": "in_invoice" , "contact_display": "partner_address", }
context = ctx
invoice_line_id = self.create(cr, uid,{}, context)
self.open_invoice(cr, uid, [invoice_line_id], context)
self._get_journal_id(cr, uid, context)
-
I check the backorder and its moves.
-
!python {model: stock.picking}: |
pick = self.browse(cr, uid, ref('stock.stock_picking_1'), {})
for line in pick.move_lines:
if line.product_id.id == ref('product.product_product_cpu3'):
assert line.product_qty == 5.0, "Wrong quantity %.2f for CPU3 back order" % (line.product_qty,)
assert line.product_qty == 5.0, "Wrong quantity %s for CPU3 back order" % (line.product_qty,)
elif line.product_id.id == ref('product.product_product_fan2'):
assert line.product_qty == 4.0, "Wrong quantity %.2f for FAN2 back order" % (line.product_qty,)
assert line.product_qty == 4.0, "Wrong quantity %s for FAN2 back order" % (line.product_qty,)
elif line.product_id.id == ref('product.product_product_pc1'):
assert line.product_qty == 0.0, "Wrong quantity for PC1 back order"
else:
assert line.product_qty == 0.0, "Wrong quantity for %s back order" % (line.product_id.code,)
-
I check the backorder.
-
!python {model: stock.picking}: |
pick = self.browse(cr, uid, ref('stock.stock_picking_1'))
stock = self.pool.get('stock.move')
assert pick.state == 'assigned',"After partial picking the remaining product's delivery order must be in 'Ready to process' state"
assert pick.backorder_id.state == 'done',"The backorder state should be 'Done'"
done_move = stock.search(cr, uid, [('picking_id','=',pick.backorder_id.id)])
assign_move = stock.search(cr, uid, [('picking_id','=',pick.id)])
for move in stock.browse(cr, uid, done_move):
assert move.state == 'done',"Stock move of %s picking should be in 'Done' state"%(move.picking_id.name)
for move in stock.browse(cr, uid, assign_move):
assert move.state == 'assigned' or 'draft',"Stock move of %s picking should be in 'Available' state"%(move.picking_id.name)
-
After the partial picking of delivery order, I check the stock moves.
-
!python {model: stock.picking}: |
pick = self.browse(cr, uid, ref('stock.stock_picking_1'))
stock = self.pool.get('stock.move')
assert pick.state == 'assigned',"After partial picking the remaining product's delivery order must be in 'Ready to process' state"
assert pick.backorder_id.state == 'done',"The backorder state should be 'Done'"
done_move = stock.search(cr, uid, [('picking_id','=',pick.backorder_id.id)])
assign_move = stock.search(cr, uid, [('picking_id','=',pick.id)])
for move in stock.browse(cr, uid, done_move):
assert move.state == 'done',"Stock move of %s picking should be in 'Done' state"%(move.picking_id.name)
for move in stock.browse(cr, uid, assign_move):
assert move.state == 'assigned' or 'draft',"Stock move of %s picking should be in 'Available' state"%(move.picking_id.name)

View File

@ -0,0 +1,45 @@
-
In order to test the stock module, I need to create initial physical inventory.
-
I create a physical inventory and change the product quantity zero by making a physical inventory.
-
!record {model: stock.inventory, id: stock_physical_inventory0}:
name: Physical inventory
-
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})
self.view_init(cr, uid, ["set_stock_zero", "location_id", "recursive"])
self.fill_inventory(cr, uid, [ids],{"full": "1", "active_model": "stock.inventory","active_id": ids,"active_ids":[ref('stock_physical_inventory0')]})
-
I confirm the inventory.
-
!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 '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 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 corresponding."
assert move.location_dest_id.id == ref('location_inventory'),"Destination location of move is not corresponding."
-
I validate the inventory after confirmation.
-
!python {model: stock.inventory}: |
inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')])[0]
self.action_done(cr,uid,[inventory.id])
assert inventory.state == 'done',"Inventory should be in 'Done' state"
-
I cancel the Inventory.
-
!python {model: stock.inventory}: |
self.action_cancel_inventary(cr,uid,[ref('stock_physical_inventory0')])
-
I change inventory state to Draft.
-
!python {model: stock.inventory}: |
self.action_cancel_draft(cr,uid,[ref('stock_physical_inventory0')])

View File

@ -1,5 +1,6 @@
-
In order to test the PDF reports defined on a stock, we will print a Stock Overviewall(children) report
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
@ -7,7 +8,7 @@
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, we will print a Stock Inventory Move report
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
@ -15,7 +16,7 @@
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, we will print a Stock Overview report
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
@ -23,18 +24,19 @@
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, we will print a Stock Picking List report
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_0')], {}, {})
(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, we will print Product Stock Report
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

@ -1,424 +0,0 @@
-
In order to test the stock module, I will create product,
create physical inventory ,fill inventory lines from location,split inventory line into production lot
-
I create Stock Production Lot for product PC3
-
!record {model: stock.production.lot, id: stock_production_lot0}:
product_id: product.product_product_pc3
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
name: 0000001
-
I trace the Stock Production Lot for product PC3.
-
!python {model: stock.production.lot }: |
self.action_traceability(cr,uid,[ref('stock_production_lot0')], {'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''})
-
I create change product quantity for product PC3.
-
!record {model: stock.change.product.qty, id: stock_change_product_qty0}:
product_id: product.product_product_pc3
new_quantity: 100
location_id: stock.stock_location_stock
prodlot_id: stock.stock_production_lot0
-
I apply the new quantity on product PC3.
-
!python {model: stock.change.product.qty }: |
context = {"lang": 'en_US', "active_model":
"product.product", "active_ids": [ref("product.product_product_pc3")], "tz": False, "active_id":ref('product.product_product_pc3')}
self.default_get(cr, uid, ["prodlot_id", "location_id", "new_quantity", "product_id"], context)
self.fields_view_get(cr, uid, ref("stock.view_change_product_quantity"),"form", context)
self.change_product_qty(cr, uid, [ref("stock_change_product_qty0")], {"lang": 'en_US', "active_model":
"stock.change.product.qty", "active_ids": ref("product.product_product_pc3"), "tz": False, "active_id":ref('product.product_product_pc3')})
-
I check that the quantity on product PC3 is updated.
-
!python {model: product.product }: |
pro_obj = self.browse(cr, uid, ref("product.product_product_pc3"))
assert (pro_obj.qty_available >= 100) , "The quantity of PC3 is not updated!"
-
I Read quantity on product PC3.
-
!python {model: stock.location }: |
self.read(cr, uid, [ref("stock.stock_location_stock")],['stock_real_value','stock_virtual'], {'lang': 'en_GB', 'tz': False, 'active_model': 'product.product', 'bin_size': True, 'active_ids': [ref("product.product_product_pc3")], 'product_id':ref("product.product_product_pc3"), 'active_id': ref("product.product_product_pc3")})
-
I Creating a chained stock.location record
-
!record {model: stock.location, id: stock_location_loc0}:
chained_auto_packing: auto
chained_delay: 0.0
chained_location_id: stock.stock_location_customers
chained_location_type: fixed
location_id: stock.stock_location_company
name: chain location
parent_left: 2
parent_right: 3
usage: internal
-
I create Product By location chart for stock.location.product Object.
-
!record {model: stock.location.product, id: stock_location_product0}:
from_date: '2011-07-01 00:00:00'
to_date: '2011-07-31 23:59:00'
-
I open product chart.
-
!python {model: stock.location.product }: |
self.action_open_window(cr, uid, [ref("stock_location_product0")], {'lang': 'en_US', 'full': 1, 'tz': False, 'active_model': 'stock.location', 'search_default_in_location': 1, 'active_ids': [ref("stock.stock_location_stock")], 'active_id': ref("stock.stock_location_stock")})
-
I open product form from stock.location object .
-
!python {model: product.product }: |
self.fields_view_get(cr, uid, False, "tree", {'lang': 'en_US', 'full': 1, 'tz': False, 'active_model': 'stock.location', 'location': ref('stock.stock_location_stock'), 'search_default_in_location': 1, 'active_ids': [ref("stock.stock_location_stock")], 'active_id': ref("stock.stock_location_stock")})
-
I create change product standard price for product PC3.
-
!record {model: stock.change.standard.price, id: stock_change_standard_price0}:
new_price: 1515
stock_account_input: account.a_recv
stock_account_output: account.a_pay
stock_journal: account.expenses_journal
enable_stock_in_out_acc: True
-
I apply the new product standard price on product PC3.
-
!python {model: stock.change.standard.price }: |
context = {"lang": 'en_US', "active_model":
"product.product", "active_ids": [ref("product.product_product_pc3")], "tz": False, "active_id":ref('product.product_product_pc3')}
self.default_get(cr, uid, ["new_price"], context)
self.change_price(cr, uid, [ref("stock_change_product_qty0")], context)
-
I create Physical Inventory for the products.
-
!record {model: stock.inventory, id: stock_inventory_physicalinventoy0}:
company_id: base.main_company
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
inventory_line_id:
- company_id: base.main_company
location_id: stock.stock_location_stock
product_id: product.product_product_pc3
product_qty: 10.0
product_uom: product.product_uom_unit
- company_id: base.main_company
location_id: stock.stock_location_stock
product_id: product.product_product_pc1
product_qty: 10.0
product_uom: product.product_uom_unit
name: Physical inventory
state: draft
-
I create merge Inventory for the products.
-
!record {model: stock.inventory, id: stock_inventory_mergeinventoy0}:
company_id: base.main_company
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
inventory_line_id:
- company_id: base.main_company
location_id: stock.stock_location_stock
product_id: product.product_product_pc3
product_qty: 20.0
product_uom: product.product_uom_unit
- company_id: base.main_company
location_id: stock.stock_location_stock
product_id: product.product_product_pc1
product_qty: 20.0
product_uom: product.product_uom_unit
name: Physical inventory
state: draft
-
I merge inventory .
-
!python {model: stock.inventory.merge}: |
context = {"lang": 'en_US',
"full": "1", "tz": False, "active_model": "stock.inventory", "active_ids":
[ref("stock_inventory_physicalinventoy0"), ref("stock_inventory_mergeinventoy0")], "active_id": ref("stock_inventory_physicalinventoy0"), }
self.fields_view_get(cr, uid, False, "form", context)
self.do_merge(cr, uid, [ref("stock_inventory_mergeinventoy0")], context)
-
I create stock.inventory.line record.
-
!record {model: stock.inventory.line, id: stock_inventory_line}:
product_id: product.product_product_pc1
product_uom: product.product_uom_unit
product_qty: 10
inventory_id: stock_inventory_mergeinventoy0
location_id: stock.stock_location_stock
-
I Change a Product oF stock.inventory.line record.
-
!python {model: stock.inventory.line}: |
self.on_change_product_id(cr, uid, [ref("stock_inventory_line")], ref('stock.stock_location_stock'), ref('product.product_product_pc3'), False, False)
-
I create stock.fill.inventory .
-
!record {model: stock.fill.inventory, id: stock_fill_inventory_0}:
location_id: stock.stock_location_stock
recursive: False
set_stock_zero: False
-
I fill inventory for PC3.
-
!python {model: stock.fill.inventory}: |
context = {"lang": 'en_US',"full": "1", "tz": False, "active_model": "stock.inventory", "active_ids":
[ref("stock_inventory_physicalinventoy0")], "active_id": ref("stock_inventory_physicalinventoy0")}
self.view_init(cr, uid, ["set_stock_zero", "location_id", "recursive"], context)
self.fill_inventory(cr, uid, [ref("stock_fill_inventory_0")], context)
-
I split the PC3 inventory line to create 5 PC3 with production lot 00002-stock-test
-
!record {model: stock.inventory.line.split, id: stock_inventory_line_0}:
line_ids:
- name: '00002-stock-test'
quantity: 5
product_id: product.product_product_pc1
product_uom: product.product_uom_unit
use_exist: False
qty: 10
-
I confirm the split operation
-
!python {model: stock.inventory.line}: |
line_ids = self.search(cr, uid, [('inventory_id','=',ref('stock_inventory_physicalinventoy0')),
('product_id','=',ref('product.product_product_pc1'))])
assert line_ids, 'Inventory lines are missing'
self.pool.get('stock.inventory.line.split').split_lot(cr, uid, [ref("stock_inventory_line_0")],
{'active_model': 'stock.inventory.line',
'active_ids': [line_ids[0]]})
-
I confirm the Inventory for PC3.
-
!python {model: stock.inventory}: |
self.action_confirm(cr,uid,[ref('stock_inventory_physicalinventoy0')])
self.action_done(cr,uid,[ref('stock_inventory_physicalinventoy0')])
-
I cancel the Inventory for PC3.
-
!python {model: stock.inventory}: |
self.action_cancel_inventary(cr,uid,[ref('stock_inventory_physicalinventoy0')])
-
I change inventory state to draft for PC3.
-
!python {model: stock.inventory}: |
self.action_cancel_draft(cr,uid,[ref('stock_inventory_physicalinventoy0')])
-
In Order to test the picking I create picking with move lines.
-
!record {model: stock.picking, id: stock_picking_0}:
name: test_picking
address_id: base.res_partner_address_4
company_id: base.main_company
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
invoice_state: 2binvoiced
move_lines:
- company_id: base.main_company
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
location_dest_id: stock.stock_location_loc0
location_id: stock.stock_location_stock
name: PC3
product_id: product.product_product_pc3
product_qty: 100.0
product_uom: product.product_uom_unit
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
product_uos_qty: 100.0
move_type: direct
type: out
-
I split the picking with a first batch of 20 PCs
-
!python {model: stock.picking }: |
pick=self.browse(cr,uid,ref('stock_picking_0'))
split_obj=self.pool.get('stock.split.into')
partial_datas={}
move=pick.move_lines[0]
partial_datas= {
'quantity': 20,
}
split_id = self.pool.get('stock.split.into').create(cr, uid, partial_datas)
split_obj.split(cr, uid, [split_id], {"lang": "en_US", "tz":
False, "active_model": "stock.move", "active_ids": [move.id],
"active_id": move.id, })
-
I click on draft_force_assign on picking.
-
!python {model: stock.picking}: |
self.draft_force_assign(cr, uid, [ref("stock_picking_0")], {"lang": "en_US", "active_model":
"ir.ui.menu", "tz": False, "search_default_confirmed": 1, "contact_display":
"partner", "active_ids": [ref("stock.menu_action_picking_tree6")], "active_id":
ref("stock.menu_action_picking_tree6"), })
-
I click on action_assign on picking.
-
!python {model: stock.picking}: |
self.action_assign(cr, uid, [ref("stock_picking_0")], {"lang": "en_US", "active_model":
"ir.ui.menu", "tz": False, "search_default_confirmed": 1, "contact_display":
"partner", "active_ids": [ref("stock.menu_action_picking_tree6")], "active_id":
ref("stock.menu_action_picking_tree6"), })
-
I process the partial picking with 20 PCE
-
!python {model: stock.picking }: |
pick = self.browse(cr,uid,ref('stock_picking_0'))
stock_partial_move = self.pool.get('stock.partial.move')
partial_id = stock_partial_move.create(cr, uid, {},
context={'active_model': 'stock.move',
'active_ids': [x.id for x in pick.move_lines]})
stock_partial_move.do_partial(cr, uid, [partial_id])
-
I Performing an osv_memory action split_lot on module stock.move.split
-
!python {model: stock.picking }: |
split_obj=self.pool.get('stock.move.split')
split_move_lines=self.pool.get('stock.move.split.lines')
pick=self.browse(cr,uid,ref('stock_picking_0'))
partial_datas={}
move=pick.move_lines[0]
partial_datas= {
'product_id': move.product_id.id,
'qty': 80,
'product_uom': move.product_uom.id,
'use_exist': move.picking_id and move.picking_id.type=='out' and True or False
}
split_id = self.pool.get('stock.move.split').create(cr, uid, partial_datas, context={})
split_move_data= {
'quantity': 10,
'name': 'lot',
}
split_move_id = split_move_lines.create(cr, uid, split_move_data, context={})
split_obj.default_get(cr, uid, ["product_id", "product_uom", "line_exist_ids", "qty",
"line_ids", "use_exist"], {'lang': 'en_US', 'default_location_dest_id': ref('stock.stock_location_stock'), 'tz': False, 'active_model': 'stock.move', 'search_default_receive': 1, 'product_receive': True, 'active_ids': [move.id], 'default_location_id': ref('stock.stock_location_locations'), 'active_id': move.id})
split_obj.split_lot(cr, uid, [split_id], context={"lang": "en_US", "tz":
False, "active_model": "stock.move", "scrap": True, "active_ids": [move.id],
"active_id": move.id, })
-
I Performed an osv_memory action move_scrap on module stock.move.scrap
-
!python {model: stock.picking }: |
location_obj = self.pool.get('stock.location')
scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)])
pick=self.browse(cr,uid,ref('stock_picking_0'))
scrap_obj=self.pool.get('stock.move.scrap')
partial_datas={}
move=pick.move_lines[0]
partial_datas= {
'product_id': move.product_id.id,
'location_id': scrpaed_location_ids[0],
'product_qty': 1,
'product_uom': move.product_uom.id,
}
scrap_id = scrap_obj.create(cr, uid, partial_datas)
context = {"lang": "en_US", "tz": False, "active_model": "stock.move",
"scrap": True, "active_ids": [move.id], "active_id": move.id, }
scrap_obj.default_get(cr, uid, ["location_id", "product_id", "product_uom", "product_qty"], context)
scrap_obj.move_scrap(cr, uid, [scrap_id], context)
-
I Performed an osv_memory do move consume on module stock.move.consume
-
!python {model: stock.picking }: |
location_obj = self.pool.get('stock.location')
scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)])
pick=self.browse(cr,uid,ref('stock_picking_0'))
consume_obj=self.pool.get('stock.move.consume')
partial_datas={}
move=pick.move_lines[0]
partial_datas= {
'product_id': move.product_id.id,
'location_id': scrpaed_location_ids[0],
'product_qty': 1,
'product_uom': move.product_uom.id,
}
context = {"lang": "en_US", "tz": False, "active_model": "stock.move",
"scrap": True, "active_ids": [move.id], "active_id": move.id, }
consume_id = consume_obj.create(cr, uid, partial_datas)
consume_obj.default_get(cr, uid, ["location_id", "product_id", "product_uom", "product_qty"], context)
consume_obj.do_move_consume(cr, uid, [consume_id], context)
-
I process the picking with the 80 remaining PCs
-
!python {model: stock.picking}: |
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [ref('stock_picking_0')]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I Performing an osv_memory action create_invoice on module stock.invoice.onshipping
-
!python {model: stock.invoice.onshipping}: |
invoice_line_id = self.create(cr, uid,{}, {"lang": 'en_US', "active_model":
"stock.picking", "active_ids": [ref("stock_picking_0")], "tz": False, "active_id":ref("stock_picking_0")})
self.open_invoice(cr, uid, [invoice_line_id], {"lang": "en_US",
"search_default_available": 1, "inv_type": "in_invoice" , "tz": False, "active_model": "stock.picking",
"contact_display": "partner_address", "active_ids": [ref("stock_picking_0")],
"active_id": ref("stock_picking_0")})
self._get_journal_id(cr, uid, {"lang": "en_US", "search_default_available": 1, "tz": False, "active_model": "stock.picking",
"contact_display": "partner_address", "active_ids": [ref("stock_picking_0")],
"active_id": ref("stock_picking_0"), })
-
I create a record of stock.picking and unlink a record
-
!python {model: stock.picking}: |
copy_id = self.copy(cr, uid, (ref("stock_picking_0")))
ctx = {"lang": "en_US", "active_model":
"ir.ui.menu", "tz": False, "search_default_confirmed": 1, "contact_display":
"partner", "active_ids": [ref("stock.menu_action_picking_tree6")], "active_id":
ref("stock.menu_action_picking_tree6"), }
self.draft_force_assign(cr, uid, [copy_id], ctx)
self.unlink(cr, uid, [copy_id], ctx)
-
I create a record of stock.picking and cancel a record
-
!python {model: stock.picking}: |
copy_id = self.copy(cr, uid, (ref("stock_picking_0")))
self.draft_validate(cr, uid, [copy_id], {"lang": "en_US", "search_default_available":
1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner_address",
"active_ids": [ref("stock.menu_action_picking_tree4")], "active_id": ref("stock.menu_action_picking_tree4"),
})
self.allow_cancel(cr, uid, [copy_id], context= None)
-
I process a copy of the picking and I return it
-
!python {model: stock.picking}: |
copy_id = self.copy(cr, uid, (ref("stock_picking_0")))
self.draft_force_assign(cr, uid, [copy_id])
self.force_assign(cr, uid, [copy_id])
stock_partial_picking = self.pool.get('stock.partial.picking')
context = {'active_model': 'stock.picking',
'active_ids': [copy_id],
'active_id': copy_id}
partial_id = stock_partial_picking.create(cr, uid, {}, context=context)
stock_partial_picking.do_partial(cr, uid, [partial_id], context)
return_pick_id = self.pool.get('stock.return.picking').create(cr, uid,{}, context)
self.pool.get('stock.return.picking').create_returns(cr, uid, [return_pick_id], context)

View File

@ -1,78 +0,0 @@
-
I create stock.tracking record.
-
!record {model: stock.tracking, id: stock_tracking_0}:
move_ids:
- product_id: product.product_product_pc1
product_qty: 5.0
product_uom: product.product_uom_unit
location_id : stock.stock_location_suppliers
location_dest_id: stock.stock_location_shop0
name : '[PC1] Basic PC'
date_expected : !eval time.strftime('%Y-%m-%d %H:%M:%S')
name: 0000007
active: True
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
-
I trace the information of a product.
-
!python {model: stock.tracking}: |
self.name_get(cr, uid, [ref('stock_tracking_0')],{'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''})
self.action_traceability(cr,uid,[ref('stock_tracking_0')], {'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''})
-
I creat stock.move Record
-
!record {model: stock.move, id: stock_move_test0}:
location_dest_id: stock.stock_location_shop0
product_id: product.product_product_pc1
product_qty: 5.0
product_uom: product.product_uom_unit
date_expected : !eval time.strftime('%Y-%m-%d %H:%M:%S')
location_id : stock.stock_location_suppliers
name : '[PC1] Basic PC'
company_id: base.main_company
product_uos_qty : 5.0
name: IN/00010
state: assigned
-
I Check onchange function of stock.move object
-
!python {model: stock.move }: |
self.onchange_lot_id(cr, uid, [ref("stock_move_test0")], ref("stock.stock_production_lot0"), 5, ref("stock.stock_location_suppliers"), ref("product.product_product_pc1"), ref("product.product_uom_unit"), None)
self.onchange_quantity(cr, uid, [ref("stock_move_test0")], ref("product.product_product_pc1"), 10, ref("product.product_uom_unit"), ref("product.product_uom_unit"))
self.onchange_uos_quantity(cr, uid, [ref("stock_move_test0")], ref("product.product_product_pc1"), 10, ref("product.product_uom_unit"), ref("product.product_uom_unit"))
self.onchange_product_id(cr, uid, [ref("stock_move_test0")], ref("product.product_product_pc1"), ref("stock.stock_location_suppliers"), ref("stock.stock_location_shop0"), False)
-
I Check _getSSCC and action_partial_move function of stock.move object
-
!python {model: stock.move }: |
context = {"lang": 'en_US', "default_location_dest_id": ref("stock.stock_location_shop0"), "active_model":
"stock.move", "search_default_receive": 1, 'product_receive': True, "default_location_id": ref("stock.stock_location_suppliers"),"active_ids":[ref("stock_move_test0")], "tz": False, "active_id":ref("stock_move_test0")}
self._getSSCC(cr, uid , context)
self.action_partial_move(cr, uid , [ref("stock_move_test0")], context)
-
I check write function
-
!python {model: stock.move }: |
vals = {"product_qty" : 2, "product_uos_qty": 2}
self.write(cr, uid, [ref("stock_move_test0")], vals, {"lang": 'en_US', "default_location_dest_id": ref("stock.stock_location_shop0"), "active_model":
"ir.ui.menu", "search_default_receive": 1, 'product_receive': True, "default_location_id": ref("stock.stock_location_suppliers"),"active_ids":[ref("stock_move_tree")], "tz": False, "active_id":ref("stock_move_tree")})
-
I check default function
-
!python {model: stock.move }: |
self.name_get(cr, uid, [ref("stock_move_test0")], {"lang": 'en_US', "default_location_dest_id": ref("stock.stock_location_shop0"), "active_model":
"stock.move", "search_default_receive": 1, 'product_receive': True, "default_location_id": ref("stock.stock_location_suppliers"),"active_ids":[ref("stock_move_test0")], "tz": False, "active_id":ref("stock_move_test0")})
ctx = {"lang": 'en_US', "default_location_dest_id": ref("stock.stock_location_shop0"), "active_model":
"ir.ui.menu", "search_default_receive": 1, 'product_receive': True, "default_location_id": ref("stock.stock_location_suppliers"),"active_ids":[ref("view_move_form_reception_picking")], "tz": False, "active_id":ref("view_move_form_reception_picking")}
self._default_location_destination(cr, uid, ctx)
self._default_location_source(cr, uid, ctx)

View File

@ -0,0 +1,92 @@
-
I update the current stock of the product.
-
I assign the location.
-
!record {model: stock.warehouse, id: stock.warehouse0}:
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_ice
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
name: 0000001
-
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('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."
-
I trace the stock production lot for product.
-
!python {model: stock.production.lot }: |
self.action_traceability(cr,uid,[ref('stock_production_lot0')], {'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''})
-
I check that physical inventory created.
-
!python {model: stock.inventory.line}: |
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 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_ice'))])
assert [x.state for x in self.browse(cr, uid, ids) if x.state == 'done'], 'Stock moves should be done!'
context = {"default_location_dest_id": ref("stock.stock_location_shop0"), "active_model":"stock.move", "search_default_receive": 1, 'product_receive': True, "default_location_id": ref("stock.stock_location_suppliers"),"active_ids":ids, "active_id":ids[0]}
self.action_partial_move(cr, uid , ids, context)
-
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 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'"
-
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

@ -81,7 +81,7 @@ class stock_fill_inventory(osv.osv_memory):
if fill_inventory.recursive:
location_ids = location_obj.search(cr, uid, [('location_id',
'child_of', [fill_inventory.location_id.id])], order="id",
'child_of', [fill_inventory.location_id.id])], order="id",
context=context)
else:
location_ids = [fill_inventory.location_id.id]

View File

@ -19,7 +19,7 @@
location_dest_id: stock.stock_location_customers
name: '[PC1] Basic PC'
move_type: direct
name: OUT/00006
name: OUT-00006
type: out
-
I need to check the availability of the product so I make my picking order for processing later.