[ADD] mrp: Added yaml for procurement orders.
bzr revid: uco@tinyerp.com-20100512130259-trfnrvswjwzq8j4q
This commit is contained in:
@@ -77,7 +77,11 @@
|
||||
'report/mrp_production_order_view.xml',
|
||||
],
|
||||
'demo_xml': ['mrp_demo.xml', 'mrp_order_point.xml'],
|
||||
# 'test': ['test/mrp_phantom_bom.yml','test/mrp_production_order.yml'],
|
||||
# 'test': [
|
||||
# 'test/mrp_phantom_bom.yml',
|
||||
# 'test/mrp_production_order.yml',
|
||||
# 'test/mrp_procurement.yml'
|
||||
# ],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'certificate': '0032052481373',
|
||||
|
||||
@@ -0,0 +1,336 @@
|
||||
-
|
||||
In order to test the flow of procurement orders. I will put some orders with
|
||||
different procurement methods. I have installed sale, mrp and purchase modules.
|
||||
-
|
||||
I am creating products.
|
||||
-
|
||||
Creating a product.product record
|
||||
-
|
||||
!record {model: product.product, id: product_product_shirt0}:
|
||||
categ_id: product.cat1
|
||||
cost_method: standard
|
||||
list_price: 350.0
|
||||
mes_type: fixed
|
||||
name: Shirt
|
||||
procure_method: make_to_stock
|
||||
property_stock_inventory: stock.location_inventory
|
||||
property_stock_procurement: stock.location_procurement
|
||||
property_stock_production: stock.location_production
|
||||
seller_delay: '1'
|
||||
standard_price: 300.0
|
||||
supply_method: produce
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
volume: 0.0
|
||||
warranty: 0.0
|
||||
weight: 0.0
|
||||
weight_net: 0.0
|
||||
-
|
||||
Creating a product.product record
|
||||
-
|
||||
!record {model: product.product, id: product_product_cloth0}:
|
||||
categ_id: product.cat1
|
||||
cost_method: standard
|
||||
mes_type: fixed
|
||||
name: Cloth
|
||||
procure_method: make_to_order
|
||||
property_stock_inventory: stock.location_inventory
|
||||
property_stock_procurement: stock.location_procurement
|
||||
property_stock_production: stock.location_production
|
||||
seller_delay: '1'
|
||||
seller_ids:
|
||||
- delay: 1
|
||||
name: base.res_partner_sednacom
|
||||
qty: 300.0
|
||||
standard_price: 1.0
|
||||
supply_method: buy
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
volume: 0.0
|
||||
warranty: 0.0
|
||||
weight: 0.0
|
||||
weight_net: 0.0
|
||||
-
|
||||
Creating a product.product record
|
||||
-
|
||||
!record {model: product.product, id: product_product_buttons0}:
|
||||
categ_id: product.cat1
|
||||
cost_method: standard
|
||||
mes_type: fixed
|
||||
name: Buttons
|
||||
procure_method: make_to_stock
|
||||
property_stock_inventory: stock.location_inventory
|
||||
property_stock_procurement: stock.location_procurement
|
||||
property_stock_production: stock.location_production
|
||||
seller_delay: '1'
|
||||
seller_ids:
|
||||
- delay: 1
|
||||
name: base.res_partner_asus
|
||||
qty: 100.0
|
||||
standard_price: 1.0
|
||||
supply_method: buy
|
||||
type: product
|
||||
uom_id: product.product_uom_kgm
|
||||
uom_po_id: product.product_uom_kgm
|
||||
volume: 0.0
|
||||
warranty: 0.0
|
||||
weight: 0.0
|
||||
weight_net: 0.0
|
||||
-
|
||||
I am creating bills of material for 'Shirt'.
|
||||
-
|
||||
Creating a mrp.bom record
|
||||
-
|
||||
!record {model: mrp.bom, id: mrp_bom_shirt0}:
|
||||
bom_lines:
|
||||
- company_id: base.main_company
|
||||
name: Cloth
|
||||
product_efficiency: 1.0
|
||||
product_id: product_product_cloth0
|
||||
product_qty: 1.0
|
||||
product_uom: product.product_uom_unit
|
||||
product_uos_qty: 0.0
|
||||
sequence: 0.0
|
||||
type: normal
|
||||
- company_id: base.main_company
|
||||
name: Buttons
|
||||
product_efficiency: 1.0
|
||||
product_id: product_product_buttons0
|
||||
product_qty: 8.0
|
||||
product_uom: product.product_uom_unit
|
||||
product_uos_qty: 0.0
|
||||
sequence: 0.0
|
||||
type: normal
|
||||
company_id: base.main_company
|
||||
name: Shirt
|
||||
product_efficiency: 1.0
|
||||
product_id: product_product_shirt0
|
||||
product_qty: 1.0
|
||||
product_uom: product.product_uom_unit
|
||||
product_uos_qty: 0.0
|
||||
sequence: 0.0
|
||||
type: normal
|
||||
-
|
||||
I create minimum stock rule for product Buttons
|
||||
-
|
||||
!record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}:
|
||||
company_id: base.main_company
|
||||
location_id: stock.stock_location_stock
|
||||
logic: max
|
||||
name: OP/00007
|
||||
product_id: mrp.product_product_buttons0
|
||||
product_max_qty: 50.0
|
||||
product_min_qty: 10.0
|
||||
product_uom: product.product_uom_unit
|
||||
qty_multiple: 1
|
||||
warehouse_id: stock.warehouse0
|
||||
-
|
||||
I create a procurement order for product Shirt.
|
||||
-
|
||||
!record {model: mrp.procurement, id: mrp_procurement_shirt0}:
|
||||
name: 'PROC: Shirt'
|
||||
product_id: product_product_shirt0
|
||||
product_qty: 5.00
|
||||
location_id: stock.stock_location_stock
|
||||
product_uom: product.product_uom_unit
|
||||
-
|
||||
I confirm the procurement order.
|
||||
-
|
||||
!workflow {model: mrp.procurement, action: button_confirm, ref: mrp_procurement_shirt0}
|
||||
-
|
||||
I run the procurement.
|
||||
-
|
||||
!workflow {model: mrp.procurement, action: button_check, ref: mrp_procurement_shirt0}
|
||||
-
|
||||
I see that there is a manufacturing order for Shirt.
|
||||
-
|
||||
!python {model: mrp.production}: |
|
||||
from tools.translate import _
|
||||
order_ids = self.search(cr, uid, [('product_id','=',ref('product_product_shirt0'))])
|
||||
assert order_ids, 'No Manufacturing Order.'
|
||||
-
|
||||
I also check that there are two more procurement orders for sub products Cloth and Buttons.
|
||||
-
|
||||
!python {model: mrp.procurement}: |
|
||||
from tools.translate import _
|
||||
proc_ids = self.search(cr, uid, [('product_id','in',[ref('product_product_cloth0'),ref('product_product_buttons0')])])
|
||||
assert proc_ids, 'No Procurements.'
|
||||
-
|
||||
The scheduler runs.
|
||||
-
|
||||
!function {model: mrp.procurement, name: run_scheduler}:
|
||||
- model: mrp.procurement
|
||||
search: "[]"
|
||||
-
|
||||
I check that there is one purchase order for Cloth.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purch_ids = self.search(cr, uid, [('partner_id.name','=','Syleam')])
|
||||
assert purch_ids, 'No Purchase Orders.'
|
||||
-
|
||||
I confirm purchase order for Cloth.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
import netsvc
|
||||
purch_ids = self.search(cr, uid, [('partner_id.name','=','Syleam')])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for p_id in purch_ids:
|
||||
wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_confirm', cr)
|
||||
-
|
||||
I get the approval from the supplier. So I approve my purchase orders.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
purch_ids = self.search(cr, uid, [('state','=','confirmed')])
|
||||
assert purch_ids, _('No Confirmed Purchase Orders found!')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for p_id in purch_ids:
|
||||
wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_approve', cr)
|
||||
-
|
||||
I confirm purchase order for Buttons.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
import netsvc
|
||||
purch_ids = self.search(cr, uid, [('partner_id.name','=','ASUStek')])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for p_id in purch_ids:
|
||||
wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_confirm', cr)
|
||||
-
|
||||
I get the approval from the supplier. So I approve my purchase orders.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
purch_ids = self.search(cr, uid, [('state','=','confirmed')])
|
||||
assert purch_ids, _('No Confirmed Purchase Orders found!')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for p_id in purch_ids:
|
||||
wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_approve', cr)
|
||||
-
|
||||
I Check incoming shipments for cloth. And receive products.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
from tools.translate import _
|
||||
pick_ids = self.search(cr, uid, [('address_id.name','=','Sebastien LANGE'),('state','=','assigned')])
|
||||
assert pick_ids, _('No Incoming Shipments found!')
|
||||
-
|
||||
!record {model: stock.partial.picking, id: stock_partial_picking0}:
|
||||
date: '2010-04-30 16:53:36'
|
||||
partner_id: base.res_partner_sednacom
|
||||
address_id: base.res_partner_address_11
|
||||
-
|
||||
!python {model: stock.partial.picking}: |
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
picking_ids = pick_obj.search(cr, uid, [('address_id.name','=','Sebastien LANGE'),('state','=','assigned')])
|
||||
partial = self.browse(cr, uid, 1, context)
|
||||
partial_datas = {
|
||||
'partner_id' : partial.partner_id and partial.partner_id.id or False,
|
||||
'address_id' : partial.address_id and partial.address_id.id or False,
|
||||
'delivery_date' : partial.date
|
||||
}
|
||||
for pick in pick_obj.browse(cr, uid, picking_ids):
|
||||
for m in pick.move_lines:
|
||||
partial_datas['move%s'%(m.id)] = {
|
||||
'product_id' : m.product_id.id,
|
||||
'product_qty' : m.product_qty,
|
||||
'product_uom' : m.product_uom.id
|
||||
}
|
||||
if (pick.type == 'in') and (m.product_id.cost_method == 'average'):
|
||||
partial_datas['move%s'%(m.id)].update({
|
||||
'product_price' : m.product_price,
|
||||
'product_currency': m.product_currency
|
||||
})
|
||||
pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
|
||||
-
|
||||
I Check incoming shipments for buttons. And receive products.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
from tools.translate import _
|
||||
pick_ids = self.search(cr, uid, [('address_id.name','=','Tang'),('state','=','assigned')])
|
||||
assert pick_ids, _('No Incoming Shipments found!')
|
||||
-
|
||||
!record {model: stock.partial.picking, id: stock_partial_picking0}:
|
||||
date: '2010-04-30 16:53:36'
|
||||
partner_id: base.res_partner_sednacom
|
||||
address_id: base.res_partner_address_11
|
||||
-
|
||||
!python {model: stock.partial.picking}: |
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
picking_ids = pick_obj.search(cr, uid, [('address_id.name','=','Tang'),('state','=','assigned')])
|
||||
partial = self.browse(cr, uid, 1, context)
|
||||
partial_datas = {
|
||||
'partner_id': partial.partner_id and partial.partner_id.id or False,
|
||||
'address_id': partial.address_id and partial.address_id.id or False,
|
||||
'delivery_date': partial.date
|
||||
}
|
||||
for pick in pick_obj.browse(cr, uid, picking_ids):
|
||||
for m in pick.move_lines:
|
||||
partial_datas['move%s'%(m.id)] = {
|
||||
'product_id': m.product_id.id,
|
||||
'product_qty': m.product_qty,
|
||||
'product_uom': m.product_uom.id
|
||||
}
|
||||
if (pick.type == 'in') and (m.product_id.cost_method == 'average'):
|
||||
partial_datas['move%s'%(m.id)].update({
|
||||
'product_price': m.product_price,
|
||||
'product_currency': m.product_currency
|
||||
})
|
||||
pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
|
||||
-
|
||||
Run scheduler again.
|
||||
-
|
||||
!function {model: mrp.procurement, name: run_scheduler}:
|
||||
- model: mrp.procurement
|
||||
search: "[]"
|
||||
-
|
||||
Check state of manufacturing order for Shirt.
|
||||
-
|
||||
!python {model: mrp.production}: |
|
||||
from tools.translate import _
|
||||
order_ids = self.search(cr, uid, [('product_id','=',ref('product_product_shirt0')),('state','=','ready')])
|
||||
assert order_ids, 'No Manufacturing Order in Ready state.'
|
||||
-
|
||||
I start production order for Shirt.
|
||||
-
|
||||
!python {model: mrp.production}: |
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
prod_ids = self.search(cr, uid, [('state','=','ready')])
|
||||
assert prod_ids, _('No Ready Manufacturing Orders found!')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for p_id in prod_ids:
|
||||
wf_service.trg_validate(uid, 'mrp.production', p_id, 'button_produce', cr)
|
||||
-
|
||||
!record {model: mrp.product.produce, id: mrp_product_produce0}:
|
||||
product_qty: 5.00
|
||||
mode: 'consume_produce'
|
||||
-
|
||||
!python {model: mrp.product.produce}: |
|
||||
from tools.translate import _
|
||||
prod_obj = self.pool.get('mrp.production')
|
||||
prod_ids = prod_obj.search(cr, uid, [('product_id.name','=','Shirt')])
|
||||
self.do_produce(cr, uid, [1], context={'active_ids': prod_ids})
|
||||
-
|
||||
!record {model: stock.move.consume, id: stock_move_consume0}:
|
||||
product_id: product_product_buttons0
|
||||
product_qty: 35.00
|
||||
product_uom: product.product_uom_unit
|
||||
location_id: stock.stock_location_stock
|
||||
-
|
||||
!python {model: stock.move.consume}: |
|
||||
from tools.translate import _
|
||||
stock_obj = self.pool.get('stock.move')
|
||||
stock_ids = stock_obj.search(cr, uid, [('product_id.name','=','Buttons')])
|
||||
self.do_move_consume(cr, uid, [1], context={'active_ids': stock_ids})
|
||||
-
|
||||
And finally production order is done.
|
||||
-
|
||||
!python {model: mrp.product.produce}: |
|
||||
from tools.translate import _
|
||||
prod_obj = self.pool.get('mrp.production')
|
||||
prod_ids = prod_obj.search(cr, uid, [('product_id.name','=','Shirt')])
|
||||
self.do_produce(cr, uid, [1], context={'active_ids': prod_ids})
|
||||
|
||||
Reference in New Issue
Block a user