~tecvemar/openerp-tecvemar/trunk

« back to all changes in this revision

Viewing changes to openerp-modules/tcv_ctrl_mrp/model/mrp_hbto.py

  • Committer: Miguel Delgado
  • Date: 2012-01-16 16:01:47 UTC
  • Revision ID: miguel.delgado07@gmail.com-20120116160147-xh7svuwouf56xjjj

[ADD] Se añadieron todos los modulos desarrollados por Tecvemar para arrancar dicha compañia con la version  
6.0 de OpenErp.
[ADD] Se creo una estructura de 2 carpetas donde openerp-modules contendra los modulos que añaden 
funcionalidad a OpenErp segun el modelo de negocios de la compañia y init-data contendra modulos necesarios 
para cargar la data de la compañia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#    
 
4
#    OpenERP, Open Source Management Solution
 
5
#
 
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.
 
10
#
 
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.
 
15
#
 
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/>.     
 
18
#
 
19
##############################################################################
 
20
 
 
21
 
 
22
from datetime import datetime
 
23
from osv import fields,osv
 
24
import pooler
 
25
import decimal_precision as dp
 
26
import time
 
27
 
 
28
 
 
29
# ---------------------------------------------------  Base class
 
30
 
 
31
class hbto_base(osv.osv):
 
32
    '''
 
33
    OpenERP Model : mrp_ctrl_tcv_base
 
34
    '''
 
35
 
 
36
    _name = 'hbto.base'
 
37
    _description = __doc__
 
38
 
 
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)
 
42
        #~ print rc_brw
 
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
 
49
        return {}
 
50
 
 
51
 
 
52
    _columns = {
 
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
 
64
        }
 
65
 
 
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)}}
 
68
        return res
 
69
    
 
70
hbto_base()
 
71
 
 
72
 
 
73
# ---------------------------------------------------  Telares
 
74
 
 
75
class hbto_telar(osv.osv):
 
76
    '''
 
77
    OpenERP Model : mrp_ctrl_telar
 
78
    '''
 
79
    
 
80
    _name = 'hbto.telar'
 
81
    _description = __doc__
 
82
    _inherits = {'hbto.base':'base_id'}
 
83
    _rec_name = "base_id"
 
84
    _columns = {
 
85
        'base_id':fields.many2one('hbto.base', 'Base'),
 
86
        'lines_ids':fields.one2many('hbto.line','telar_id','Details'),
 
87
        }
 
88
hbto_telar()
 
89
 
 
90
 
 
91
# ---------------------------------------------------  Telares.line
 
92
 
 
93
class hbto_line(osv.osv):
 
94
    '''
 
95
    OpenERP Model : mrp_ctrl_telar_line
 
96
    '''
 
97
    
 
98
    _name = 'hbto.line'
 
99
    _description = __doc__
 
100
    _rec_name = 'telar_id'
 
101
    _columns = {
 
102
        'telar_id':fields.many2one('hbto.telar', 'Telar'),
 
103
        }
 
104
        
 
105
    def _rotate(self):
 
106
        ''' read lot info and swap heigth & width '''
 
107
        return 0
 
108
 
 
109
hbto_line()
 
110
 
 
111
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: