2010-07-20 10:20:41 +00:00
|
|
|
-
|
|
|
|
In order to test the flow of stock planning module. I will create forecast periods,
|
|
|
|
stock forecast and then with master procurement schedule.
|
|
|
|
-
|
|
|
|
I create weekly stock periods for the month of July.
|
|
|
|
-
|
|
|
|
I create stock period for the first week of July.
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
!record {model: stock.period, id: stock_period_01}:
|
2011-01-05 05:03:29 +00:00
|
|
|
date_start: !eval "'%s-07-01 00:00:00' %(datetime.now().year)"
|
|
|
|
date_stop: !eval "'%s-07-06 23:59:00' %(datetime.now().year)"
|
|
|
|
name: !eval "'%s, week 27' %(datetime.now().year)"
|
2010-07-20 10:20:41 +00:00
|
|
|
-
|
|
|
|
I create stock period for the second week of July.
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
!record {model: stock.period, id: stock_period_02}:
|
2011-01-05 05:03:29 +00:00
|
|
|
date_start: !eval "'%s-07-07 00:00:00' %(datetime.now().year)"
|
|
|
|
date_stop: !eval "'%s-07-12 23:59:00' %(datetime.now().year)"
|
|
|
|
name: !eval "'%s, week 28' %(datetime.now().year)"
|
2010-07-20 10:20:41 +00:00
|
|
|
-
|
|
|
|
I create stock period for the third week of July.
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
!record {model: stock.period, id: stock_period_03}:
|
2011-01-05 05:03:29 +00:00
|
|
|
date_start: !eval "'%s-07-15 00:00:00' %(datetime.now().year)"
|
|
|
|
date_stop: !eval "'%s-07-20 23:59:00' %(datetime.now().year)"
|
|
|
|
name: !eval "'%s, week 29' %(datetime.now().year)"
|
2010-07-20 10:20:41 +00:00
|
|
|
-
|
|
|
|
I create stock period for the fourth week of July.
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
!record {model: stock.period, id: stock_period_04}:
|
2011-01-05 05:03:29 +00:00
|
|
|
date_start: !eval "'%s-07-22 00:00:00' %(datetime.now().year)"
|
|
|
|
date_stop: !eval "'%s-07-27 23:59:00' %(datetime.now().year)"
|
|
|
|
name: !eval "'%s, week 30' %(datetime.now().year)"
|
2010-07-20 10:20:41 +00:00
|
|
|
-
|
|
|
|
I create stock period for the fifth week of July.
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
!record {model: stock.period, id: stock_period_05}:
|
2011-01-05 05:03:29 +00:00
|
|
|
date_start: !eval "'%s-07-29 00:00:00' %(datetime.now().year)"
|
|
|
|
date_stop: !eval "'%s-07-31 23:59:00' %(datetime.now().year)"
|
|
|
|
name: !eval "'%s, week 31' %(datetime.now().year)"
|
2011-08-03 12:11:00 +00:00
|
|
|
-
|
|
|
|
I validate in open state module stock.period
|
|
|
|
-
|
|
|
|
!python {model: stock.period}: |
|
|
|
|
self.button_open(cr, uid, [ref("stock_period_01")], {"lang": 'en_GB', "tz": False, "active_model": 'ir.ui.menu', "active_id": ref("stock_planning.menu_stock_period_main"), "active_ids": [ref("stock_planning.menu_stock_period_main")], "department_id": False})
|
|
|
|
|
|
|
|
-
|
|
|
|
I validate in close state module stock.period
|
|
|
|
-
|
|
|
|
!python {model: stock.period}: |
|
|
|
|
self.button_close(cr, uid, [ref("stock_period_01")], {"lang": 'en_GB', "tz": False, "active_model": 'ir.ui.menu', "active_id": ref("stock_planning.menu_stock_period_main"), "active_ids": [ref("stock_planning.menu_stock_period_main")], "department_id": False})
|
|
|
|
|
2010-07-20 10:20:41 +00:00
|
|
|
-
|
|
|
|
Now I create the forecast for this period for all PCs.
|
|
|
|
-
|
|
|
|
!record {model: stock.sale.forecast.createlines, id: stock_sale_forecast_createlines_0}:
|
|
|
|
company_id: base.main_company
|
|
|
|
period_id: stock_period_03
|
2012-06-28 09:30:01 +00:00
|
|
|
product_categ_id: product.product_category_9
|
2010-07-20 10:20:41 +00:00
|
|
|
warehouse_id: stock.warehouse0
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
Performing an osv_memory action create_forecast on module stock.sale.forecast.createlines
|
|
|
|
-
|
|
|
|
!python {model: stock.sale.forecast.createlines}: |
|
|
|
|
self.create_forecast(cr, uid, [ref("stock_sale_forecast_createlines_0")], {"lang":
|
|
|
|
'en_US', "active_model": "ir.ui.menu", "active_ids": [ref("stock_planning.menu_stock_sale_forecast_createlines")],
|
|
|
|
"tz": False, "active_id": ref("stock_planning.menu_stock_sale_forecast_createlines"),
|
|
|
|
})
|
2011-08-03 12:11:00 +00:00
|
|
|
|
|
|
|
-
|
|
|
|
I create stock.period.createlines for the first week of august.
|
|
|
|
-
|
|
|
|
!record {model: stock.period.createlines, id: stock_period_createlines_week01}:
|
|
|
|
date_start: !eval "'%s-08-01' %(datetime.now().year)"
|
|
|
|
date_stop: !eval "'%s-08-06' %(datetime.now().year)"
|
|
|
|
name: !eval "'%s, week 31' %(datetime.now().year)"
|
|
|
|
|
|
|
|
-
|
|
|
|
Performing an osv_memory action create_stock_periods on module stock.period.createlines
|
|
|
|
-
|
|
|
|
!python {model: stock.period.createlines}: |
|
|
|
|
self.create_stock_periods(cr, uid, [ref("stock_period_createlines_week01")], {"lang":
|
|
|
|
'en_US', "name": 'Weekly', "interval": 6, "active_model": "ir.ui.menu", "active_ids": [ref("stock_planning.menu_stock_period_creatlines")],
|
|
|
|
"tz": False, "active_id": ref("stock_planning.menu_stock_period_creatlines"),
|
|
|
|
})
|
|
|
|
-
|
|
|
|
I create stock.period.createlines for the month of august - september
|
|
|
|
-
|
|
|
|
!record {model: stock.period.createlines, id: stock_period_createlines_month01}:
|
|
|
|
date_start: !eval "'%s-08-01' %(datetime.now().year)"
|
|
|
|
date_stop: !eval "'%s-09-01' %(datetime.now().year)"
|
|
|
|
name: !eval "'%s, month 8' %(datetime.now().year)"
|
|
|
|
|
|
|
|
-
|
|
|
|
Performing an osv_memory action create_stock_periods on module stock.period.createlines
|
|
|
|
-
|
|
|
|
!python {model: stock.period.createlines}: |
|
|
|
|
self.create_stock_periods(cr, uid, [ref("stock_period_createlines_month01")], {"lang":
|
|
|
|
'en_US', "name": 'Monthly', "interval": 6, "active_model": "ir.ui.menu", "active_ids": [ref("stock_planning.menu_stock_period_creatlines")],
|
|
|
|
"tz": False, "active_id": ref("stock_planning.menu_stock_period_creatlines"),
|
|
|
|
})
|
|
|
|
|
|
|
|
-
|
|
|
|
I create stock.period.createlines for the Day of august
|
|
|
|
-
|
|
|
|
!record {model: stock.period.createlines, id: stock_period_createlines_day01}:
|
|
|
|
date_start: !eval "'%s-08-01' %(datetime.now().year)"
|
|
|
|
date_stop: !eval "'%s-08-01' %(datetime.now().year)"
|
|
|
|
name: !eval "'%s, day 01' %(datetime.now().year)"
|
|
|
|
|
|
|
|
-
|
|
|
|
Performing an osv_memory action create_stock_periods on module stock.period.createlines
|
|
|
|
-
|
|
|
|
!python {model: stock.period.createlines}: |
|
|
|
|
self.create_stock_periods(cr, uid, [ref("stock_period_createlines_day01")], {"lang":
|
|
|
|
'en_US', "name": 'Daily', "interval": 6, "active_model": "ir.ui.menu", "active_ids": [ref("stock_planning.menu_stock_period_creatlines")],
|
|
|
|
"tz": False, "active_id": ref("stock_planning.menu_stock_period_creatlines"),
|
|
|
|
})
|
|
|
|
|
|
|
|
-
|
|
|
|
I Read date_start on module stock.period.createlines.
|
|
|
|
-
|
|
|
|
!python {model: stock.period.createlines }: |
|
|
|
|
self._get_new_period_start(cr, uid,{"lang":'en_US', "active_model": "ir.ui.menu",
|
|
|
|
"active_ids": [ref("stock_planning.menu_stock_period_creatlines")],
|
|
|
|
"tz": False, "active_id": ref("stock_planning.menu_stock_period_creatlines"),"department_id": False
|
|
|
|
})
|
|
|
|
|
2010-07-20 10:20:41 +00:00
|
|
|
-
|
|
|
|
I create a sale order for PC1-Basic PC and PC3-Medium PC.
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
!record {model: sale.order, id: sale_order_so0}:
|
2011-01-13 17:13:02 +00:00
|
|
|
date_order: !eval time.strftime('%Y-07-20')
|
2010-07-20 10:20:41 +00:00
|
|
|
invoice_quantity: order
|
2011-08-05 21:44:49 +00:00
|
|
|
name: TESTSO006
|
2010-07-20 10:20:41 +00:00
|
|
|
order_line:
|
|
|
|
- name: '[PC1] Basic PC'
|
|
|
|
price_unit: 450.0
|
|
|
|
product_uom: product.product_uom_unit
|
|
|
|
product_uom_qty: 13.0
|
|
|
|
state: draft
|
|
|
|
delay: 2.0
|
2012-06-29 11:04:24 +00:00
|
|
|
product_id: product.product_product_3
|
2010-07-20 10:20:41 +00:00
|
|
|
product_uos_qty: 13.0
|
|
|
|
th_weight: 0.0
|
|
|
|
type: make_to_stock
|
|
|
|
- name: '[PC3] Medium PC'
|
|
|
|
price_unit: 900.0
|
|
|
|
product_uom: product.product_uom_unit
|
|
|
|
product_uom_qty: 5.0
|
|
|
|
state: draft
|
|
|
|
delay: 3.0
|
2012-06-29 11:04:24 +00:00
|
|
|
product_id: product.product_product_5
|
2010-07-20 10:20:41 +00:00
|
|
|
product_uos_qty: 5.0
|
|
|
|
th_weight: 0.0
|
|
|
|
type: make_to_stock
|
|
|
|
order_policy: manual
|
2012-06-20 12:03:05 +00:00
|
|
|
partner_id: base.res_partner_12
|
2012-06-25 06:54:32 +00:00
|
|
|
partner_invoice_id: base.res_partner_address_22
|
|
|
|
partner_shipping_id: base.res_partner_address_22
|
2010-07-20 10:20:41 +00:00
|
|
|
picking_policy: direct
|
|
|
|
pricelist_id: product.list0
|
|
|
|
shop_id: sale.shop
|
|
|
|
-
|
|
|
|
Now I want to calculate sales history for both the products PC1-Basic PC and PC3-Medium PC and forecast the quantity.
|
|
|
|
-
|
|
|
|
!python {model: stock.sale.forecast}: |
|
2012-06-29 11:04:24 +00:00
|
|
|
forecast_ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_3'))])
|
2010-07-20 10:20:41 +00:00
|
|
|
write_dict = {'product_qty': 30.0,
|
|
|
|
'analyzed_period1_id': ref("stock_period_03"),
|
|
|
|
'analyzed_user_id': ref("base.user_root"),
|
|
|
|
'analyzed_warehouse_id': ref("stock.warehouse0")}
|
2011-08-03 12:11:00 +00:00
|
|
|
context = {"lang": "en_US", "tz":False, "search_default_create_uid": 1, "active_model": "ir.ui.menu",
|
|
|
|
"department_id": False, "active_ids": [ref("stock_planning.menu_stock_sale_forecast_all")],
|
|
|
|
"active_id": ref("stock_planning.menu_stock_sale_forecast_all"), }
|
2010-07-20 10:20:41 +00:00
|
|
|
self.write(cr, uid, forecast_ids, write_dict)
|
2011-08-03 12:11:00 +00:00
|
|
|
self.calculate_sales_history(cr, uid, forecast_ids, context)
|
|
|
|
self.action_validate(cr, uid, forecast_ids, context)
|
|
|
|
|
|
|
|
-
|
|
|
|
Now I applying onchange and unlink forecast record for the product PC3
|
|
|
|
-
|
|
|
|
!python {model: stock.sale.forecast}: |
|
2012-06-29 11:04:24 +00:00
|
|
|
forecast_ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_5'))])
|
2011-08-03 12:11:00 +00:00
|
|
|
self.unlink(cr, uid, forecast_ids, {"lang": "en_US", "tz":
|
2010-07-20 10:20:41 +00:00
|
|
|
False, "search_default_create_uid": 1, "active_model": "ir.ui.menu", "department_id":
|
|
|
|
False, "active_ids": [ref("stock_planning.menu_stock_sale_forecast_all")], "active_id":
|
|
|
|
ref("stock_planning.menu_stock_sale_forecast_all"), })
|
2011-08-03 12:11:00 +00:00
|
|
|
self.product_id_change(cr, uid, forecast_ids, ref('product.product_product_20'))
|
|
|
|
self.onchange_uom(cr, uid, forecast_ids, ref('product.product_uom_unit'), False, ref('product.product_uom_unit'), ref('product.product_product_20'))
|
|
|
|
self.product_amt_change(cr, uid, forecast_ids, 5.0, ref('product.product_uom_unit'), ref('product.product_product_20'))
|
|
|
|
self.product_amt_change(cr, uid, forecast_ids, 5.0, ref('product.product_uom_unit'), ref('product.product_product_20'))
|
|
|
|
self._to_default_uom_factor(cr, uid, ref('product.product_product_20'), ref('product.product_uom_unit'), {})
|
2012-06-19 07:16:24 +00:00
|
|
|
self.onchange_company(cr, uid, forecast_ids, ref('stock.res_partner_2'))
|
2011-08-03 12:11:00 +00:00
|
|
|
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
I create Master procurement schedule for the third week of July.
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
!record {model: stock.planning.createlines, id: stock_planning_createlines_0}:
|
|
|
|
company_id: base.main_company
|
|
|
|
period_id: stock_period_03
|
2012-06-28 09:30:01 +00:00
|
|
|
product_categ_id: product.product_category_9
|
2010-07-20 10:20:41 +00:00
|
|
|
warehouse_id: stock.warehouse0
|
2011-08-03 12:11:00 +00:00
|
|
|
|
|
|
|
-
|
|
|
|
I create source warehouse for supply from another warehouse.
|
|
|
|
-
|
|
|
|
!record {model: stock.warehouse, id: stock_warehouse_0}:
|
|
|
|
name: shop1
|
|
|
|
company_id: base.main_company
|
|
|
|
lot_input_id: stock.stock_location_stock
|
|
|
|
lot_stock_id: stock.stock_location_stock
|
|
|
|
lot_output_id: stock.stock_location_output
|
|
|
|
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
Performing an osv_memory action create_planning on module stock.planning.createlines
|
2011-01-05 05:03:29 +00:00
|
|
|
-
|
2010-07-20 10:20:41 +00:00
|
|
|
!python {model: stock.planning.createlines}: |
|
2012-06-19 07:16:24 +00:00
|
|
|
self.onchange_company(cr, uid, ref("stock_planning_createlines_0"), ref('stock.res_partner_2'))
|
2010-07-20 10:20:41 +00:00
|
|
|
self.create_planning(cr, uid, [ref("stock_planning_createlines_0")], {"lang":
|
|
|
|
"en_US", "tz": False, "active_model": "ir.ui.menu", "active_ids": [ref("stock_planning.menu_stock_planning_createlines")],
|
|
|
|
"active_id": ref("stock_planning.menu_stock_planning_createlines"), "department_id":
|
|
|
|
False, })
|
|
|
|
-
|
|
|
|
I calculate the planning in master procurement schedule.
|
|
|
|
-
|
|
|
|
!python {model: stock.planning}: |
|
2012-06-29 11:04:24 +00:00
|
|
|
planning_ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_3')),('period_id','=',ref('stock_period_03'))])
|
2011-08-03 12:11:00 +00:00
|
|
|
self.write(cr, uid, planning_ids, {'to_procure': 30.0,'planned_outgoing': 40.0,'supply_warehouse_id': ref("stock_warehouse_0")})
|
2012-06-19 07:16:24 +00:00
|
|
|
self.onchange_company(cr, uid, planning_ids, ref('stock.res_partner_2'))
|
2012-06-29 11:04:24 +00:00
|
|
|
self.onchange_uom(cr, uid, planning_ids, ref('product.product_uom_unit'), ref('product.product_product_3'),ref('product.product_uom_unit'), False, False)
|
2011-08-03 12:11:00 +00:00
|
|
|
self.product_id_change(cr, uid, planning_ids, ref('product.product_product_20'))
|
|
|
|
context = {"lang": "en_US", "tz": False, "active_model": "ir.ui.menu",
|
|
|
|
"active_ids": [ref("stock_planning.menu_stock_planning")],
|
2010-07-20 10:20:41 +00:00
|
|
|
"active_id": ref("stock_planning.menu_stock_planning"), "department_id": False,
|
2011-08-03 12:11:00 +00:00
|
|
|
}
|
|
|
|
self.calculate_planning(cr, uid, planning_ids, context)
|
|
|
|
self.internal_supply(cr, uid, planning_ids, context)
|
|
|
|
|
2010-07-20 10:20:41 +00:00
|
|
|
-
|
|
|
|
I create a procurement order for the incoming products left.
|
|
|
|
-
|
|
|
|
!python {model: stock.planning}: |
|
2012-06-29 11:04:24 +00:00
|
|
|
planning_ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_3')),('period_id','=',ref('stock_period_03'))])
|
2010-07-20 10:20:41 +00:00
|
|
|
plann = self.browse(cr, uid, planning_ids)
|
|
|
|
assert plann[0].incoming_left, 'Incoming Left must be greater than 0 !'
|
|
|
|
self.procure_incomming_left(cr, uid, planning_ids, {"lang": 'en_US', "tz":
|
|
|
|
False, "active_model": "ir.ui.menu", "active_ids": [ref("stock_planning.menu_stock_planning")],
|
|
|
|
"active_id": ref("stock_planning.menu_stock_planning"), "department_id": False,
|
|
|
|
})
|
|
|
|
-
|
|
|
|
I check whether the procurement orders are created or not.
|
|
|
|
-
|
|
|
|
!python {model: procurement.order}: |
|
2012-01-02 15:04:25 +00:00
|
|
|
import datetime
|
2012-06-29 11:04:24 +00:00
|
|
|
proc_ids = self.search(cr, uid, [('origin','=','MPS(admin) %s, week 29' % (datetime.datetime.now().year)),('product_id','=',ref("product.product_product_3"))])
|
2010-07-20 10:20:41 +00:00
|
|
|
assert proc_ids,'No Procurements!'
|