1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as
8
# published by the Free Software Foundation, either version 3 of the
9
# License, or (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
##############################################################################
22
from datetime import datetime
23
from osv import fields,osv
25
import decimal_precision as dp
29
# --------------------------------------------------- Base class
31
class hbto_base(osv.osv):
33
OpenERP Model : mrp_ctrl_tcv_base
37
_description = __doc__
39
def _compute_run_time(self, cr, uid, ids, date_start, date_end, context=None):
40
''' must return date_end - date_start in hours'''
41
rc_brw = self.browse(cr, uid, ids,context=context)
43
#~ start = rc_brw.date_start
44
#~ end =rc_brw.date_end
45
#~ time = self.read(cr, uid, ids, ['date_start'],context=context)
46
#~ print date_start, date_end
47
#~ if date_start and date_end:
48
#~ return date_end-date_start
53
'name':fields.char('Reference', size=64, required=False, readonly=False),
54
'mrp_production_id': fields.many2one('mrp.production', 'Manufacturing Order'),
55
'date_start':fields.datetime('Start date', Select=True),
56
'date_end':fields.datetime('Finish date', Select=True),
57
'run_time':fields.function(_compute_run_time, method=True, type='time', string='Production run time'),
58
'author_id': fields.many2one('res.users', 'Author'),
59
'note':fields.text('Description'),
60
#'prior_mrp_production_id':fields.many2one('mrp.ctrl.tcv.base', 'Prior'),
61
#'next_mrp_production_id':fields.many2one('mrp.ctrl.tcv.base', 'Next'),
62
'company_id':fields.many2one('res.company','Company',required=True),
63
# crear campo reference
66
def on_change_run_time(self, cr, uid, ids, date_start, date_end):
67
res = {'value':{'run_time':self._compute_run_time(cr,uid,ids,date_start, date_end)}}
73
# --------------------------------------------------- Telares
75
class hbto_telar(osv.osv):
77
OpenERP Model : mrp_ctrl_telar
81
_description = __doc__
82
_inherits = {'hbto.base':'base_id'}
85
'base_id':fields.many2one('hbto.base', 'Base'),
86
'lines_ids':fields.one2many('hbto.line','telar_id','Details'),
91
# --------------------------------------------------- Telares.line
93
class hbto_line(osv.osv):
95
OpenERP Model : mrp_ctrl_telar_line
99
_description = __doc__
100
_rec_name = 'telar_id'
102
'telar_id':fields.many2one('hbto.telar', 'Telar'),
106
''' read lot info and swap heigth & width '''
111
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: