1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
import pooler
import time
class fleet_service_items(osv.osv):
_name = "fleet.service.items"
_description="Different types of service tasks"
_columns={
'name':fields.char('Service Item',size=30,required=True),
'itemtype':fields.selection([
('normal','Normal'),
('fluids','Fluids'),
('inspection','Inspection'),
('replace','Replace'),
('others','Others')],'Type of Service'),
'freqn':fields.integer('Frequency'),
'freqz':fields.selection([('days','Days'),
('weeks','Weeks'),
('months','Months'),
('years','Years')
]),
'freqd':fields.float('Mileage', digits=(10,3)),
'freqdz':fields.selection([
('miles','Miles'),
('km','Kilometers'),
('hours','Hours')
]),
'sparesreq':fields.one2many('fleet.service.items.spares','serviceitem','Spares Required')
}
_defaults = {
'freqdz':lambda *a:'km',
'freqz':lambda *a:'days',
'itemtype':lambda *a:'inspection'
}
fleet_service_items()
class fleet_service_items_spares(osv.osv):
_name="fleet.service.items.spares"
_description="Service items to spare relation"
def fetchunit(self,cr,uid,ids,productid):
#print "Control is txed & Product id"
#print productid
if productid:
product_obj = self.pool.get('product.product')
product_obj = product_obj.browse(cr, uid, productid,False)
#print product_obj
default_uom = product_obj.uom_id and product_obj.uom_id.id
#print default_uom
res={}
res['unit']=default_uom
#print res
return {'value':res}
else:
return False
_columns={
'product':fields.many2one('product.product','Spare Part',domain="[('spare_ok','=','True')]",required=True),
'qtyreqd':fields.float('Quantity',digits=(10,3),required=True),
#'unit':fields.function(defaultuom,method=True,store=True,string="Unit of Use(Default)"),
'unit':fields.many2one('product.uom','Unit Of Use'),
'serviceitem':fields.many2one('fleet.service.items','Service Item')
}
fleet_service_items_spares()
class fleet_service_templ(osv.osv):
_name = 'fleet.service.templ'
_description='The Template is a collection of service items.'
_columns={
'name':fields.char('Template Name',size=50,required=True,select=1,help="Service Templates are a collection of Service Tasks for a specific category of vehicles."),
'description':fields.char('Description',size=50,required=True,select=1),
'items':fields.many2many('fleet.service.items','fleet_template_tasks_rel','template_id','item_id','Service Items'),
}
fleet_service_templ()
|