21
21
#/#############################################################################
22
22
from osv import osv
23
23
from osv import fields
26
27
class OeMedicalAppointment(osv.Model):
27
28
_name = 'oemedical.appointment'
30
'consultations': fields.many2one('product.product',
31
string='Consultation Services',
32
help='Consultation Services'),
33
31
'patient_id': fields.many2one('oemedical.patient', string='Patient',
34
32
required=True, select=True,
35
33
help='Patient Name'),
36
34
'name': fields.char(size=256, string='Appointment ID', readonly=True),
37
35
'appointment_date': fields.datetime(string='Date and Time'),
36
'appointment_day': fields.date(string='Date'),
37
'appointment_hour': fields.selection([
63
'appointment_minute': fields.selection([
38
78
'duration': fields.float('Duration'),
39
79
'doctor': fields.many2one('oemedical.physician',
40
80
string='Physician',select=True,
41
81
help='Physician\'s Name'),
82
'alias' : fields.char(size=256, string='Alias', ),
42
83
'comments': fields.text(string='Comments'),
43
84
'appointment_type': fields.selection([
44
85
('ambulatory', 'Ambulatory'),
56
102
'speciality': fields.many2one('oemedical.specialty',
57
103
string='Specialty',
58
104
help='Medical Specialty / Sector'),
105
'state': fields.selection([
107
('confirm', 'Confirm'),
108
('waiting', 'Wating'),
109
('in_consultation', 'In consultation'),
111
('canceled', 'Canceled'),
114
'history_ids' : fields.one2many('oemedical.appointment.history','appointment_id_history','History lines', states={'start':[('readonly',True)]}),
62
'name': lambda obj, cr, uid, context:
119
'name': lambda obj, cr, uid, context:
63
120
obj.pool.get('ir.sequence').get(cr, uid, 'oemedical.appointment'),
127
def create(self, cr, uid, vals, context=None):
129
ait_obj = self.pool.get('oemedical.appointment.history')
133
val_history['name'] = uid
134
val_history['date'] = time.strftime('%Y-%m-%d %H:%M:%S')
135
val_history['action'] = "-------------------------------- Changed to Comfirm ------------------------------------\n"
137
vals['history_ids'] = val_history
139
print "create", vals['history_ids'], val_history, ' ------ ', vals
141
return super(OeMedicalAppointment, self).create(cr, uid, vals, context=context)
143
def button_back(self, cr, uid, ids, context=None):
146
ait_obj = self.pool.get('oemedical.appointment.history')
148
for order in self.browse(cr, uid, ids, context=context):
149
if order.state == 'confirm':
150
self.write(cr, uid, ids, {'state':'draft'} ,context=context)
151
val_history['action'] = "-------------------------------- Changed to Draft ------------------------------------\n"
152
if order.state == 'waiting':
153
val_history['action'] = "-------------------------------- Changed to Confirm ------------------------------------\n"
154
self.write(cr, uid, ids, {'state':'confirm'} ,context=context)
155
if order.state == 'in_consultation':
156
val_history['action'] = "-------------------------------- Changed to Waiting ------------------------------------\n"
157
self.write(cr, uid, ids, {'state':'waiting'} ,context=context)
158
if order.state == 'done':
159
val_history['action'] = "-------------------------------- Changed to In Consultation ------------------------------------\n"
160
self.write(cr, uid, ids, {'state':'in_consultation'} ,context=context)
161
if order.state == 'canceled':
162
val_history['action'] = "-------------------------------- Changed to Draft ------------------------------------\n"
163
self.write(cr, uid, ids, {'state':'draft'} ,context=context)
165
val_history['appointment_id_history'] = ids[0]
166
val_history['name'] = uid
167
val_history['date'] = time.strftime('%Y-%m-%d %H:%M:%S')
169
ait_obj.create(cr, uid, val_history)
173
def button_confirm(self, cr, uid, ids, context=None):
176
ait_obj = self.pool.get('oemedical.appointment.history')
178
self.write(cr, uid, ids, {'state':'confirm'} ,context=context)
180
val_history['appointment_id_history'] = ids[0]
181
val_history['name'] = uid
182
val_history['date'] = time.strftime('%Y-%m-%d %H:%M:%S')
183
val_history['action'] = "-------------------------------- Changed to Comfirm ------------------------------------\n"
184
ait_obj.create(cr, uid, val_history)
188
def button_waiting(self, cr, uid, ids, context=None):
191
ait_obj = self.pool.get('oemedical.appointment.history')
193
self.write(cr, uid, ids, {'state':'waiting'} ,context=context)
195
val_history['appointment_id_history'] = ids[0]
196
val_history['name'] = uid
197
val_history['date'] = time.strftime('%Y-%m-%d %H:%M:%S')
198
val_history['action'] = "-------------------------------- Changed to Waiting ------------------------------------\n"
199
ait_obj.create(cr, uid, val_history)
203
def button_in_consultation(self, cr, uid, ids, context=None):
206
ait_obj = self.pool.get('oemedical.appointment.history')
208
self.write(cr, uid, ids, {'state':'in_consultation'} ,context=context)
210
val_history['appointment_id_history'] = ids[0]
211
val_history['name'] = uid
212
val_history['date'] = time.strftime('%Y-%m-%d %H:%M:%S')
213
val_history['action'] = "-------------------------------- Changed to In Consultation ------------------------------------\n"
214
ait_obj.create(cr, uid, val_history)
218
def button_done(self, cr, uid, ids, context=None):
221
ait_obj = self.pool.get('oemedical.appointment.history')
223
self.write(cr, uid, ids, {'state':'done'} ,context=context)
225
val_history['appointment_id_history'] = ids[0]
226
val_history['name'] = uid
227
val_history['date'] = time.strftime('%Y-%m-%d %H:%M:%S')
228
val_history['action'] = "-------------------------------- Changed to Done ------------------------------------\n"
229
ait_obj.create(cr, uid, val_history)
233
def button_cancel(self, cr, uid, ids, context=None):
236
ait_obj = self.pool.get('oemedical.appointment.history')
238
self.write(cr, uid, ids, {'state':'canceled'} ,context=context)
240
val_history['appointment_id_history'] = ids[0]
241
val_history['name'] = uid
242
val_history['date'] = time.strftime('%Y-%m-%d %H:%M:%S')
243
val_history['action'] = "-------------------------------- Changed to Canceled ------------------------------------\n"
244
ait_obj.create(cr, uid, val_history)
66
249
OeMedicalAppointment()
251
class OeMedicalAppointment_history(osv.Model):
252
_name = 'oemedical.appointment.history'
255
'appointment_id_history' : fields.many2one('oemedical.appointment','History', ondelete='cascade'),
256
'date': fields.datetime(string='Date and Time'),
257
'name': fields.many2one('res.users', string='User', help=''),
258
'action' : fields.text('Action'),
264
OeMedicalAppointment_history()
67
265
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: