Merge branch 'master' of https://github.com/odoo/odoo
[odoo/odoo.git] / addons / mrp_operations / test / workcenter_operations.yml
1 -
2    Create a user as 'MRP User'
3 -
4   !record {model: res.users, id: res_mrp_operation_user, view: False}:
5     company_id: base.main_company
6     name: MRP User
7     login: maou
8     password: maou
9     email: mrp_operation_user@yourcompany.com
10 -
11   I added groups for MRP User.
12 -
13   !record {model: res.users, id: res_mrp_operation_user}:
14     groups_id:
15       - mrp.group_mrp_user
16       - stock.group_stock_user
17 -
18   In order to test mrp_operations with OpenERP, I refer created production order of PC Assemble SC349
19   with routing - Manual Component's Assembly to test complete production process with respect of workcenter with giving access rights of MRP User.
20 -
21   !context
22     uid: 'res_mrp_operation_user'
23 -
24   I compute the production order.
25 -
26   !python {model: mrp.production}: |
27     order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
28     order.action_compute(context=context)
29 -
30   I check planned date in workcenter lines of production order.
31 -
32   !python {model: mrp.production}: |
33     order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
34     for line in order.workcenter_lines:
35         #TODO: to check start date of next line should be end of date of previous line.
36         assert line.date_planned, "Planned Start date is not computed: %s" %(line)
37         assert line.date_planned_end, "Planned End date is not computed: %s" %(line)
38 -
39   I confirm the Production Order.
40 -
41   !workflow {model: mrp.production, action: button_confirm, ref: mrp.mrp_production_1}
42 -  
43   I run scheduler.
44 -
45   !python {model: procurement.order}: |
46     self.run_scheduler(cr, uid)
47 -
48   I forcefully close internal shipment.
49 -
50   !python {model: mrp.production}: |
51     self.force_production(cr, uid, [ref("mrp.mrp_production_1")])
52 -
53   I start production.
54 -
55   !workflow {model: mrp.production, action: button_produce, ref: mrp.mrp_production_1}
56
57   Production start on first work center, so I start work operation on first work center.
58 -
59   !python {model: mrp.production}: |
60     order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
61     order.workcenter_lines[0].signal_workflow('button_start_working')
62 -
63   Now I pause first work operation due to technical fault of work center.
64 -
65   !python {model: mrp.production}: |
66     order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
67     order.workcenter_lines[0].signal_workflow('button_pause')
68 -
69   I resume first work operation.
70 -
71   !python {model: mrp.production}: |
72     order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
73     order.workcenter_lines[0].signal_workflow('button_resume')
74     
75 -
76   I cancel first work operation.
77 -
78   !python {model: mrp.production}: |
79     order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
80     order.workcenter_lines[0].signal_workflow('button_cancel')
81 -
82   I reset first work operation and start after resolving technical fault of work center.
83 -
84   !python {model: mrp.production}: |
85     order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
86     order.workcenter_lines[0].signal_workflow('button_draft')
87     order.workcenter_lines[0].signal_workflow('button_start_working')
88 -
89   I close first work operation as this work center completed its process.
90 -
91   !python {model: mrp.production}: |
92     order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
93     order.workcenter_lines[0].signal_workflow('button_done')
94 -
95   Now I close other operations one by one which are in start state.
96 -
97   !python {model: mrp.production}: |
98     order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
99     for work_line in order.workcenter_lines[1:]:
100       work_line.signal_workflow('button_start_working')
101       work_line.signal_workflow('button_done')
102
103 -
104   I check that the production order is now done.
105 -
106   !python {model: mrp.production}: |
107     order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context)
108     assert order.state == 'done', "Production should be closed after finished all operations."
109 -
110   I print a Barcode Report of Operation line.
111 -
112   !python {model: mrp_operations.operation.code}: |
113     from openerp import tools
114     from openerp.report import render_report
115     ids = [
116         ref('mrp_operations.mrp_op_1'),
117         ref('mrp_operations.mrp_op_2'),
118         ref('mrp_operations.mrp_op_3'),
119         ref('mrp_operations.mrp_op_4'),
120         ref('mrp_operations.mrp_op_5')
121     ]
122     data, format = render_report(cr, uid, ids, 'mrp.code.barcode', {})
123     if tools.config['test_report_directory']:
124         file(os.path.join(tools.config['test_report_directory'], 'mrp_operations-barcode_report.'+format), 'wb+').write(data)
125
126 -
127   I print Workcenter's Barcode Report.
128 -
129   !python {model: mrp.workcenter}: |
130     from openerp import tools
131     from openerp.report import render_report
132     ids = [ref('mrp.mrp_workcenter_0'), ref('mrp.mrp_workcenter_1')]
133     data, format = render_report(cr, uid, ids, 'mrp.wc.barcode', {})
134     if tools.config['test_report_directory']:
135         file(os.path.join(tools.config['test_report_directory'], 'mrp_operations-workcenter_barcode_report.'+format), 'wb+').write(data)