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