[FIX] mrp_repair: Fixed log error when End repair is performed.
[odoo/odoo.git] / addons / mrp_operations / mrp_operations.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 from osv import fields
23 from osv import osv
24 import ir
25 import datetime
26 import netsvc
27 import time
28 from mx import DateTime
29 from tools.translate import _
30
31 #----------------------------------------------------------
32 # Work Centers
33 #----------------------------------------------------------
34 # capacity_hour : capacity per hour. default: 1.0.
35 #          Eg: If 5 concurrent operations at one time: capacity = 5 (because 5 employees)
36 # unit_per_cycle : how many units are produced for one cycle
37
38 class stock_move(osv.osv):
39     _inherit = 'stock.move'
40     _columns = {
41         'move_dest_id_lines': fields.one2many('stock.move','move_dest_id', 'Children Moves')
42     }
43 stock_move()
44
45 class mrp_production_workcenter_line(osv.osv):
46     def _get_date_date(self, cr, uid, ids, field_name, arg, context):
47         """ Finds starting date.
48         @return: Dictionary of values.
49         """
50         res={}
51         for op in self.browse(cr, uid, ids, context=context):
52             if op.date_start:
53                 res[op.id] = op.date_start[:10]
54             else:
55                 res[op.id]=False
56         return res
57     
58     def _get_date_end(self, cr, uid, ids, field_name, arg, context):
59         """ Finds ending date.
60         @return: Dictionary of values.
61         """
62         res = {}
63         for op in self.browse(cr, uid, ids, context=context):
64             res[op.id] = False
65             if op.date_planned:
66                 d = DateTime.strptime(op.date_planned,'%Y-%m-%d %H:%M:%S')
67                 i = self.pool.get('resource.calendar').interval_get(cr, uid, op.workcenter_id.calendar_id.id or False, d, op.hour or 0.0)
68                 if i:
69                     res[op.id] = i[-1][1].strftime('%Y-%m-%d %H:%M:%S')
70                 else:
71                     res[op.id] = op.date_planned
72         return res
73     
74     _inherit = 'mrp.production.workcenter.line'
75     _order = "sequence, date_planned"
76     
77     _columns = {
78        'state': fields.selection([('draft','Draft'),('startworking', 'In Progress'),('pause','Pause'),('cancel','Canceled'),('done','Finished')],'State', readonly=True,
79                                  help="* When a work order is created it is set in 'Draft' state.\n" \
80                                        "* When user sets work order in start mode that time it will be set in 'In Progress' state.\n" \
81                                        "* When work order is in running mode, during that time if user wants to stop or to make changes in order then can set in 'Pause' state.\n" \
82                                        "* When the user cancels the work order it will be set in 'Canceled' state.\n" \
83                                        "* When order is completely processed that time it is set in 'Finished' state."),
84        'date_start_date': fields.function(_get_date_date, method=True, string='Start Date', type='date'),
85        'date_planned': fields.datetime('Scheduled Date'),
86        'date_planned_end': fields.function(_get_date_end, method=True, string='End Date', type='datetime'),
87        'date_start': fields.datetime('Start Date'),
88        'date_finnished': fields.datetime('End Date'),
89        'delay': fields.float('Working Hours',help="This is lead time between operation start and stop in this workcenter",readonly=True),
90        'production_state':fields.related('production_id','state',
91             type='selection',
92             selection=[('draft','Draft'),('picking_except', 'Picking Exception'),('confirmed','Waiting Goods'),('ready','Ready to Produce'),('in_production','In Production'),('cancel','Canceled'),('done','Done')],
93             string='Production State', readonly=True),
94        'product':fields.related('production_id','product_id',type='many2one',relation='product.product',string='Product',
95             readonly=True),
96        'qty':fields.related('production_id','product_qty',type='float',string='Qty',readonly=True),
97        'uom':fields.related('production_id','product_uom',type='many2one',relation='product.uom',string='UOM',readonly=True),
98     }
99     
100     _defaults = {
101         'state': lambda *a: 'draft',
102         'delay': lambda *a: 0.0
103     }
104
105     def modify_production_order_state(self, cr, uid, ids, action):
106         """ Modifies production order state if work order state is changed.
107         @param action: Action to perform.
108         @return: Nothing
109         """
110         wf_service = netsvc.LocalService("workflow")
111         oper_obj = self.browse(cr, uid, ids)[0]
112         prod_obj = oper_obj.production_id
113         if action == 'start':
114                if prod_obj.state =='confirmed':
115                    self.pool.get('mrp.production').force_production(cr, uid, [prod_obj.id])
116                    wf_service.trg_validate(uid, 'mrp.production', prod_obj.id, 'button_produce', cr)
117                elif prod_obj.state =='ready':
118                    wf_service.trg_validate(uid, 'mrp.production', prod_obj.id, 'button_produce', cr)
119                elif prod_obj.state =='in_production':
120                    return
121                else:
122                    raise osv.except_osv(_('Error!'),_('Production Order Cannot start in [%s] state') % (prod_obj.state,))
123         else:
124             oper_ids = self.search(cr,uid,[('production_id','=',prod_obj.id)])
125             obj = self.browse(cr,uid,oper_ids)
126             flag = True
127             for line in obj:
128                 if line.state != 'done':
129                      flag = False
130             if flag:
131                 wf_service.trg_validate(uid, 'mrp.production', oper_obj.production_id.id, 'button_produce_done', cr)
132         return
133
134     def write(self, cr, uid, ids, vals, context={}, update=True):
135         result = super(mrp_production_workcenter_line, self).write(cr, uid, ids, vals, context=context)
136         prod_obj = self.pool.get('mrp.production')
137         if vals.get('date_planned', False) and update:
138             pids = {}
139             pids2 = {}
140             for prod in self.browse(cr, uid, ids, context=context):
141                 if prod.production_id.workcenter_lines:
142                     dstart = min(vals['date_planned'], prod.production_id.workcenter_lines[0]['date_planned'])
143                     prod_obj.write(cr, uid, [prod.production_id.id], {'date_start':dstart}, context=context, mini=False)
144         return result
145
146     def action_draft(self, cr, uid, ids):
147         """ Sets state to draft.
148         @return: True
149         """
150         self.write(cr, uid, ids, {'state':'draft'})
151         return True
152
153     def action_start_working(self, cr, uid, ids):
154         """ Sets state to start working and writes starting date.
155         @return: True
156         """
157         self.modify_production_order_state(cr, uid, ids, 'start')
158         self.write(cr, uid, ids, {'state':'startworking', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')})
159         return True
160
161     def action_done(self, cr, uid, ids):
162         """ Sets state to done, writes finish date and calculates delay.
163         @return: True
164         """
165         delay = 0.0
166         date_now = time.strftime('%Y-%m-%d %H:%M:%S')
167         obj_line = self.browse(cr, uid, ids[0])
168         
169         date_start = datetime.datetime.strptime(obj_line.date_start,'%Y-%m-%d %H:%M:%S')
170         date_finished = datetime.datetime.strptime(date_now,'%Y-%m-%d %H:%M:%S')
171         delay += (date_finished-date_start).days * 24
172         delay += (date_finished-date_start).seconds / float(60*60)
173         
174         self.write(cr, uid, ids, {'state':'done', 'date_finnished': date_now,'delay':delay})
175         self.modify_production_order_state(cr,uid,ids,'done')
176         return True
177
178     def action_cancel(self, cr, uid, ids):
179         """ Sets state to cancel.
180         @return: True
181         """
182         self.write(cr, uid, ids, {'state':'cancel'})
183         return True
184
185     def action_pause(self, cr, uid, ids):
186         """ Sets state to pause.
187         @return: True
188         """
189         self.write(cr, uid, ids, {'state':'pause'})
190         return True
191
192     def action_resume(self, cr, uid, ids):
193         """ Sets state to startworking.
194         @return: True
195         """
196         self.write(cr, uid, ids, {'state':'startworking'})
197         return True
198
199 mrp_production_workcenter_line()
200
201 class mrp_production(osv.osv):
202     _inherit = 'mrp.production'
203     _columns = {
204         'allow_reorder': fields.boolean('Free Serialisation', help="Check this to be able to move independently all production orders, without moving dependent ones."),
205     }
206
207     def _production_date_end(self, cr, uid, ids, prop, unknow_none, context={}):
208         """ Calculates planned end date of production order.
209         @return: Dictionary of values
210         """
211         result = {}
212         for prod in self.browse(cr, uid, ids, context=context):
213             result[prod.id] = prod.date_planned
214             for line in prod.workcenter_lines:
215                 result[prod.id] = max(line.date_planned_end, result[prod.id])
216         return result
217
218     def action_production_end(self, cr, uid, ids):
219         """ Finishes work order if production order is done.
220         @return: Super method
221         """
222         obj = self.browse(cr, uid, ids)[0]
223         wf_service = netsvc.LocalService("workflow")
224         for workcenter_line in obj.workcenter_lines:
225             wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_done', cr)
226         return super(mrp_production,self).action_production_end(cr, uid, ids)
227     
228     def action_in_production(self, cr, uid, ids):
229         """ Changes state to In Production and writes starting date.
230         @return: True 
231         """        
232         obj = self.browse(cr, uid, ids)[0]
233         wf_service = netsvc.LocalService("workflow")
234         for workcenter_line in obj.workcenter_lines:
235             wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_start_working', cr)
236         return super(mrp_production,self).action_in_production(cr, uid, ids)
237     
238     def action_cancel(self, cr, uid, ids):
239         """ Cancels work order if production order is canceled.
240         @return: Super method
241         """
242         obj = self.browse(cr, uid, ids)[0]
243         wf_service = netsvc.LocalService("workflow")
244         for workcenter_line in obj.workcenter_lines:
245             wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_cancel', cr)
246         return super(mrp_production,self).action_cancel(cr,uid,ids)
247
248     def _compute_planned_workcenter(self, cr, uid, ids, context={}, mini=False):
249         """ Computes planned and finished dates for work order.
250         @return: Calculated date
251         """
252         dt_end = DateTime.now()
253         for po in self.browse(cr, uid, ids, context=context):
254             dt_end = DateTime.strptime(po.date_start or po.date_planned, '%Y-%m-%d %H:%M:%S')
255             if not po.date_start:
256                 self.write(cr, uid, [po.id], {
257                     'date_start': po.date_planned
258                 }, context=context, update=False)
259             old = None
260             for wci in range(len(po.workcenter_lines)):
261                 wc  = po.workcenter_lines[wci]
262                 if (old is None) or (wc.sequence>old):
263                     dt = dt_end
264                 if context.get('__last_update'):
265                     del context['__last_update']
266                 if (wc.date_planned<dt.strftime('%Y-%m-%d %H:%M:%S')) or mini:
267                     self.pool.get('mrp.production.workcenter.line').write(cr, uid, [wc.id],  {
268                         'date_planned':dt.strftime('%Y-%m-%d %H:%M:%S')
269                     }, context=context, update=False)
270                     i = self.pool.get('resource.calendar').interval_get(
271                         cr,
272                         uid,
273                         wc.workcenter_id.calendar_id and wc.workcenter_id.calendar_id.id or False,
274                         dt,
275                         wc.hour or 0.0
276                     )
277                     if i:
278                         dt_end = max(dt_end, i[-1][1])
279                 else:
280                     dt_end = DateTime.strptime(wc.date_planned_end, '%Y-%m-%d %H:%M:%S')
281                 old = wc.sequence or 0
282             super(mrp_production, self).write(cr, uid, [po.id], {
283                 'date_finnished': dt_end
284             })
285         return dt_end
286
287     def _move_pass(self, cr, uid, ids, context={}):
288         """ Calculates start date for stock moves finding interval from resource calendar.
289         @return: True 
290         """
291         for po in self.browse(cr, uid, ids, context):
292             if po.allow_reorder:
293                 continue
294             todo = po.move_lines
295             dt = DateTime.strptime(po.date_start,'%Y-%m-%d %H:%M:%S')
296             while todo:
297                 l = todo.pop(0)
298                 if l.state in ('done','cancel','draft'):
299                     continue
300                 todo += l.move_dest_id_lines
301                 if l.production_id and (l.production_id.date_finnished > dt):
302                     if l.production_id.state not in ('done','cancel'):
303                         for wc in l.production_id.workcenter_lines:
304                             i = self.pool.get('resource.calendar').interval_min_get(
305                                 cr,
306                                 uid,
307                                 wc.workcenter_id.calendar_id.id or False,
308                                 dt, wc.hour or 0.0
309                             )
310                             dt = i[0][0]
311                         if l.production_id.date_start > dt.strftime('%Y-%m-%d %H:%M:%S'):
312                             self.write(cr, uid, [l.production_id.id], {'date_start':dt.strftime('%Y-%m-%d %H:%M:%S')}, mini=True)
313         return True
314
315     def _move_futur(self, cr, uid, ids, context={}):
316         """ Calculates start date for stock moves.
317         @return: True 
318         """
319         for po in self.browse(cr, uid, ids, context):
320             if po.allow_reorder:
321                 continue
322             for line in po.move_created_ids:
323                 l = line
324                 while l.move_dest_id:
325                     l = l.move_dest_id
326                     if l.state in ('done','cancel','draft'):
327                         break
328                     if l.production_id.state in ('done','cancel'):
329                         break
330                     if l.production_id and (l.production_id.date_start < po.date_finnished):
331                         self.write(cr, uid, [l.production_id.id], {'date_start': po.date_finnished})
332                         break
333
334
335     def write(self, cr, uid, ids, vals, context={}, update=True, mini=True):
336         direction = {}
337         if vals.get('date_start', False):
338             for po in self.browse(cr, uid, ids, context=context):
339                 direction[po.id] = cmp(po.date_start, vals.get('date_start', False))
340         result = super(mrp_production, self).write(cr, uid, ids, vals, context=context)
341         if (vals.get('workcenter_lines', False) or vals.get('date_start', False)) and update:
342             self._compute_planned_workcenter(cr, uid, ids, context=context, mini=mini)
343         for d in direction:
344             if direction[d] == 1:
345                 # the production order has been moved to the passed
346                 self._move_pass(cr, uid, [d], context=context)
347                 pass
348             elif direction[d] == -1:
349                 self._move_futur(cr, uid, [d], context=context)
350                 # the production order has been moved to the future
351                 pass
352         return result
353
354     def action_compute(self, cr, uid, ids, properties=[]):
355         """ Computes bills of material of a product and planned date of work order.
356         @param properties: List containing dictionaries of properties.
357         @return: No. of products.
358         """
359         result = super(mrp_production, self).action_compute(cr, uid, ids, properties=properties)
360         self._compute_planned_workcenter(cr, uid, ids, context={})
361         return result
362
363 mrp_production()
364
365 class mrp_operations_operation_code(osv.osv):
366     _name="mrp_operations.operation.code"
367     _columns={
368         'name': fields.char('Operation Name',size=64, required=True),
369         'code': fields.char('Code', size=16, required=True),
370         'start_stop': fields.selection([('start','Start'),('pause','Pause'),('resume','Resume'),('cancel','Cancelled'),('done','Done')], 'Status', required=True),
371     }
372 mrp_operations_operation_code()
373
374 class mrp_operations_operation(osv.osv):
375     _name="mrp_operations.operation"
376
377     def _order_date_search_production(self, cr, uid, ids, context=None):
378         """ Finds operations for a production order.
379         @return: List of ids
380         """
381         operation_ids = self.pool.get('mrp_operations.operation').search(cr, uid, [('production_id','=',ids[0])], context=context)
382         return operation_ids
383
384     def _get_order_date(self, cr, uid, ids, field_name, arg, context):
385         """ Calculates planned date for an operation.
386         @return: Dictionary of values
387         """
388         res={}
389         operation_obj = self.browse(cr, uid, ids, context=context)
390         for operation in operation_obj:
391                 res[operation.id] = operation.production_id.date_planned
392         return res
393
394     def calc_delay(self, cr, uid, vals):
395         """ Calculates delay of work order.
396         @return: Delay
397         """
398         code_lst = []
399         time_lst = []
400
401         code_ids = self.pool.get('mrp_operations.operation.code').search(cr, uid, [('id','=',vals['code_id'])])
402         code = self.pool.get('mrp_operations.operation.code').browse(cr, uid, code_ids)[0]
403
404         oper_ids = self.search(cr,uid,[('production_id','=',vals['production_id']),('workcenter_id','=',vals['workcenter_id'])])
405         oper_objs = self.browse(cr,uid,oper_ids)
406
407         for oper in oper_objs:
408             code_lst.append(oper.code_id.start_stop)
409             time_lst.append(oper.date_start)
410
411         code_lst.append(code.start_stop)
412         time_lst.append(vals['date_start'])
413         diff = 0
414         for i in range(0,len(code_lst)):
415             if code_lst[i] == 'pause' or code_lst[i] == 'done' or code_lst[i] == 'cancel':
416                 if not i: continue
417                 if code_lst[i-1] not in ('resume','start'):
418                    continue
419                 a = datetime.datetime.strptime(time_lst[i-1],'%Y-%m-%d %H:%M:%S')
420                 b = datetime.datetime.strptime(time_lst[i],'%Y-%m-%d %H:%M:%S')
421                 diff += (b-a).days * 24
422                 diff += (b-a).seconds / float(60*60)
423         return diff
424
425     def check_operation(self, cr, uid, vals):
426         """ Finds which operation is called ie. start, pause, done, cancel.
427         @param vals: Dictionary of values.
428         @return: True or False
429         """
430         code_ids=self.pool.get('mrp_operations.operation.code').search(cr,uid,[('id','=',vals['code_id'])])
431         code=self.pool.get('mrp_operations.operation.code').browse(cr,uid,code_ids)[0]
432         code_lst = []
433         oper_ids=self.search(cr,uid,[('production_id','=',vals['production_id']),('workcenter_id','=',vals['workcenter_id'])])
434         oper_objs=self.browse(cr,uid,oper_ids)
435
436         if not oper_objs:
437             if code.start_stop!='start':
438                 raise osv.except_osv(_('Sorry!'),_('Operation is not started yet !'))
439                 return False
440         else:
441             for oper in oper_objs:
442                  code_lst.append(oper.code_id.start_stop)
443             if code.start_stop=='start':
444                     if 'start' in code_lst:
445                         raise osv.except_osv(_('Sorry!'),_('Operation has already started !' 'You  can either Pause /Finish/Cancel the operation'))
446                         return False
447             if code.start_stop=='pause':
448                     if  code_lst[len(code_lst)-1]!='resume' and code_lst[len(code_lst)-1]!='start':
449                         raise osv.except_osv(_('Error!'),_('You cannot Pause the Operation other then Start/Resume state !'))
450                         return False
451             if code.start_stop=='resume':
452                 if code_lst[len(code_lst)-1]!='pause':
453                    raise osv.except_osv(_('Error!'),_(' You cannot Resume the operation other then Pause state !'))
454                    return False
455
456             if code.start_stop=='done':
457                if code_lst[len(code_lst)-1]!='start' and code_lst[len(code_lst)-1]!='resume':
458                   raise osv.except_osv(_('Sorry!'),_('You cannot finish the operation without Starting/Resuming it !'))
459                   return False
460                if 'cancel' in code_lst:
461                   raise osv.except_osv(_('Sorry!'),_('Operation is Already Cancelled  !'))
462                   return False
463             if code.start_stop=='cancel':
464                if  not 'start' in code_lst :
465                    raise osv.except_osv(_('Error!'),_('There is no Operation to be cancelled !'))
466                    return False
467                if 'done' in code_lst:
468                   raise osv.except_osv(_('Error!'),_('Operation is already finished !'))
469                   return False
470         return True
471
472     def write(self, cr, uid, ids, vals, context=None):
473         oper_objs=self.browse(cr,uid,ids)[0]
474         vals['production_id']=oper_objs.production_id.id
475         vals['workcenter_id']=oper_objs.workcenter_id.id
476
477         if 'code_id' in vals:
478             self.check_operation(cr, uid, vals)
479
480         if 'date_start' in vals:
481             vals['date_start']=vals['date_start']
482             vals['code_id']=oper_objs.code_id.id
483             delay=self.calc_delay(cr, uid, vals)
484             wc_op_id=self.pool.get('mrp.production.workcenter.line').search(cr,uid,[('workcenter_id','=',vals['workcenter_id']),('production_id','=',vals['production_id'])])
485             self.pool.get('mrp.production.workcenter.line').write(cr,uid,wc_op_id,{'delay':delay})
486
487         return super(mrp_operations_operation, self).write(cr, uid, ids, vals, context=context)
488
489     def create(self, cr, uid, vals, context=None):
490         wf_service = netsvc.LocalService('workflow')
491         code_ids=self.pool.get('mrp_operations.operation.code').search(cr,uid,[('id','=',vals['code_id'])])
492         code=self.pool.get('mrp_operations.operation.code').browse(cr,uid,code_ids)[0]
493         wc_op_id=self.pool.get('mrp.production.workcenter.line').search(cr,uid,[('workcenter_id','=',vals['workcenter_id']),('production_id','=',vals['production_id'])])
494         if code.start_stop in ('start','done','pause','cancel','resume'):
495             if not wc_op_id:
496                 production_obj=self.pool.get('mrp.production').browse(cr,uid,vals['production_id'])
497                 wc_op_id.append(self.pool.get('mrp.production.workcenter.line').create(cr,uid,{'production_id':vals['production_id'],'name':production_obj.product_id.name,'workcenter_id':vals['workcenter_id']}))
498             if code.start_stop=='start':
499                 tmp=self.pool.get('mrp.production.workcenter.line').action_start_working(cr,uid,wc_op_id)
500                 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_start_working', cr)
501                 
502
503             if code.start_stop=='done':
504                 tmp=self.pool.get('mrp.production.workcenter.line').action_done(cr,uid,wc_op_id)
505                 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_done', cr)
506                 self.pool.get('mrp.production').write(cr,uid,vals['production_id'],{'date_finnished':DateTime.now().strftime('%Y-%m-%d %H:%M:%S')})
507
508             if code.start_stop=='pause':
509                 tmp=self.pool.get('mrp.production.workcenter.line').action_pause(cr,uid,wc_op_id)
510                 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_pause', cr)
511
512             if code.start_stop=='resume':
513                 tmp=self.pool.get('mrp.production.workcenter.line').action_resume(cr,uid,wc_op_id)
514                 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_resume', cr)
515
516             if code.start_stop=='cancel':
517                 tmp=self.pool.get('mrp.production.workcenter.line').action_cancel(cr,uid,wc_op_id)
518                 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_cancel', cr)
519
520         if not self.check_operation(cr, uid, vals):
521             return
522         delay=self.calc_delay(cr, uid, vals)
523         line_vals = {}
524         line_vals['delay'] = delay
525         if vals.get('date_start',False):
526             if code.start_stop == 'done':
527                 line_vals['date_finnished'] = vals['date_start']
528             elif code.start_stop == 'start':    
529                 line_vals['date_start'] = vals['date_start']
530
531         self.pool.get('mrp.production.workcenter.line').write(cr, uid, wc_op_id, line_vals, context=context)
532
533         return super(mrp_operations_operation, self).create(cr, uid, vals, context=context)
534
535     _columns={
536         'production_id':fields.many2one('mrp.production','Production',required=True),
537         'workcenter_id':fields.many2one('mrp.workcenter','Work Center',required=True),
538         'code_id':fields.many2one('mrp_operations.operation.code','Code',required=True),
539         'date_start': fields.datetime('Start Date'),
540         'date_finished': fields.datetime('End Date'),
541         'order_date': fields.function(_get_order_date,method=True,string='Order Date',type='date',store={'mrp.production':(_order_date_search_production,['date_planned'], 10)}),
542         }
543     _defaults={
544         'date_start': lambda *a:DateTime.now().strftime('%Y-%m-%d %H:%M:%S')
545     }
546
547 mrp_operations_operation()
548 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
549