odoo/addons/mrp_operations/test/workcenter_operations.yml

136 lines
5.4 KiB
YAML

-
Create a user as 'MRP User'
-
!record {model: res.users, id: res_mrp_operation_user}:
company_id: base.main_company
name: MRP User
login: maou
password: maou
email: mrp_operation_user@yourcompany.com
-
I added groups for MRP User.
-
!record {model: res.users, id: res_mrp_operation_user}:
groups_id:
- mrp.group_mrp_user
-
In order to test mrp_operations with OpenERP, I refer created production order of PC Assemble SC349
with routing - Manual Component's Assembly to test complete production process with respect of workcenter with giving access rights of MRP User.
-
!context
uid: 'res_mrp_operation_user'
-
I compute the production order.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
order.action_compute(context=context)
-
I check planned date in workcenter lines of production order.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
for line in order.workcenter_lines:
#TODO: to check start date of next line should be end of date of previous line.
assert line.date_planned, "Planned Start date is not computed: %s" %(line)
assert line.date_planned_end, "Planned End date is not computed: %s" %(line)
-
I confirm the Production Order.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp.mrp_production_1}
-
I run scheduler.
-
!python {model: procurement.order}: |
self.run_scheduler(cr, uid)
-
I forcefully close internal shipment.
-
!python {model: mrp.production}: |
self.force_production(cr, uid, [ref("mrp.mrp_production_1")])
-
I start production.
-
!workflow {model: mrp.production, action: button_produce, ref: mrp.mrp_production_1}
-
Production start on first work center, so I start work operation on first work center.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
self.pool.get('mrp.production.workcenter.line').signal_button_start_working(cr, uid, [order.workcenter_lines[0].id])
-
Now I pause first work operation due to technical fault of work center.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
self.pool.get('mrp.production.workcenter.line').signal_button_pause(cr, uid, [order.workcenter_lines[0].id])
-
I resume first work operation.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
self.pool.get('mrp.production.workcenter.line').signal_button_resume(cr, uid, [order.workcenter_lines[0].id])
-
I cancel first work operation.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
self.pool.get('mrp.production.workcenter.line').signal_button_cancel(cr, uid, [order.workcenter_lines[0].id])
-
I reset first work operation and start after resolving techninal fault of work center.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
self.pool.get('mrp.production.workcenter.line').signal_button_draft(cr, uid, [order.workcenter_lines[0].id])
self.pool.get('mrp.production.workcenter.line').signal_button_start_working(cr, uid, [order.workcenter_lines[0].id])
-
I close first work operation as this work center completed its process.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
self.pool.get('mrp.production.workcenter.line').signal_button_done(cr, uid, [order.workcenter_lines[0].id])
-
Now I close other operations one by one which are in start state.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
for work_line in order.workcenter_lines[1:]:
self.pool.get('mrp.production.workcenter.line').signal_button_start_working(cr, uid, [work_line.id])
self.pool.get('mrp.production.workcenter.line').signal_button_done(cr, uid, [work_line.id])
-
I check that the production order is now done.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
assert order.state == 'done', "Production should be closed after finished all operations."
-
I print a Barcode Report of Operation line.
-
!python {model: mrp_operations.operation.code}: |
from openerp import tools
from openerp.report import render_report
ids = [
ref('mrp_operations.mrp_op_1'),
ref('mrp_operations.mrp_op_2'),
ref('mrp_operations.mrp_op_3'),
ref('mrp_operations.mrp_op_4'),
ref('mrp_operations.mrp_op_5')
]
data, format = render_report(cr, uid, ids, 'mrp.code.barcode', {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'mrp_operations-barcode_report.'+format), 'wb+').write(data)
-
I print Workcenter's Barcode Report.
-
!python {model: mrp.workcenter}: |
from openerp import tools
from openerp.report import render_report
ids = [ref('mrp.mrp_workcenter_0'), ref('mrp.mrp_workcenter_1')]
data, format = render_report(cr, uid, ids, 'mrp.wc.barcode', {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'mrp_operations-workcenter_barcode_report.'+format), 'wb+').write(data)