~iratzio-gutierrez/oemedical/oemedical-csm

« back to all changes in this revision

Viewing changes to oemedical/oemedical_prescription_order/oemedical_prescription_order.py

  • Committer: Nhomar - Vauxoo
  • Date: 2013-10-23 03:02:27 UTC
  • mfrom: (83.1.120 openobject-oemedical)
  • Revision ID: nhomar@gmail.com-20131023030227-dwgs8z939r2f5al7
[MERGE] Federicos branch, several change and finishing a lot of concepts, sorry for the delay. Thanks, Note: See the commit log for the origin of the merge for more details.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#/#############################################################################
22
22
from osv import osv
23
23
from osv import fields
 
24
from openerp import netsvc
 
25
from datetime import datetime, timedelta
 
26
from dateutil.relativedelta import relativedelta
 
27
import time
 
28
 
24
29
 
25
30
 
26
31
class OeMedicalPrescriptionOrder(osv.Model):
27
32
    _name='oemedical.prescription.order'
28
33
 
29
34
    _columns={
30
 
        'patient_id': fields.many2one('oemedical.patient', string='Patient',
31
 
                                   required=True),
32
 
        'pregnancy_warning': fields.boolean(string='Pregancy Warning',
33
 
                                            readonly=True),
 
35
        'patient_id': fields.many2one('oemedical.patient', string='Patient', required=True),
 
36
        'pregnancy_warning': fields.boolean(string='Pregancy Warning', readonly=True),
34
37
        'notes': fields.text(string='Prescription Notes'),
35
 
        'prescription_line': fields.one2many('oemedical.prescription.line',
36
 
                                             'prescription_order_id',
37
 
                                             string='Prescription line',),
 
38
        'prescription_line': fields.one2many('oemedical.prescription.line', 'name', string='Prescription line',),
38
39
        'pharmacy': fields.many2one('res.partner', string='Pharmacy',),
39
40
        'prescription_date': fields.datetime(string='Prescription Date'),
40
 
        'prescription_warning_ack': fields.boolean(
41
 
            string='Prescription verified'),
42
 
        'user_id': fields.many2one('res.users', string='Prescribing Doctor',
43
 
                                   required=True),
44
 
        'name': fields.char(size=256, string='Prescription ID', required=True,
45
 
                             help='Type in the ID of this prescription'),
 
41
        'prescription_warning_ack': fields.boolean( string='Prescription verified'),
 
42
        'physician_id': fields.many2one('oemedical.physician', string='Prescribing Doctor',  required=True),
 
43
        'name': fields.char(size=256, string='Prescription ID', required=True, help='Type in the ID of this prescription'),
46
44
    }
47
45
    
48
46
    _defaults={
49
47
         'name': lambda obj, cr, uid, context: 
50
48
            obj.pool.get('ir.sequence').get(cr, uid,
51
49
                                            'oemedical.prescription.order'),
 
50
            'prescription_date':lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
 
51
 
52
52
                 }
53
53
 
 
54
    def print_prescription(self, cr, uid, ids, context=None):
 
55
        '''
 
56
        '''
 
57
#        assert len(ids) == 1, 'This option should only be used for a single id at a time'
 
58
#        wf_service = netsvc.LocalService("workflow")
 
59
#        wf_service.trg_validate(uid, 'oemedical.prescription.order', ids[0], 'prescription_sent', cr)
 
60
        datas = {
 
61
                 'model': 'oemedical.prescription.order',
 
62
                 'ids': ids,
 
63
                 'form': self.read(cr, uid, ids[0], context=context),
 
64
        }
 
65
        return {'type': 'ir.actions.report.xml', 'report_name': 'prescription.order', 'datas': datas, 'nodestroy': True}
 
66
 
 
67
 
54
68
OeMedicalPrescriptionOrder()
55
69
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: