1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
25
from tools.translate import _
27
pos_form = """<?xml version="1.0"?>
28
<form string="Create POS">
29
<separator colspan="4" string="Select Doctor" />
30
<field name="doctor_id"/>
38
'relation': 'medical.physician',
43
def _create_pos(obj, cr, uid, data, context):
45
pool = pooler.get_pool(cr.dbname)
46
pos_obj = pool.get('pos.order')
47
patient_obj = pool.get('medical.patient')
48
lab_test_obj = pool.get('medical.patient.lab.test')#lab_test_ids
52
patient = patient_obj.browse( cr, uid, data['ids'])[0]
53
if patient.name.insurance:
54
pos_data['partner_id'] = patient.name.insurance[0].company.id
55
pos_data['note']="Patient name :"+patient.name.name+" with insurance No. : "+patient.name.insurance[0].name
57
pos_data['partner_id'] = patient.name.id
59
lab_test_ids = lab_test_obj.search(cr, uid, [('doctor_id','=',data['form']['doctor_id']),('state','=','draft'),('patient_id','=',patient.id)])
61
for test in lab_test_obj.browse(cr, uid, lab_test_ids):
62
test_line.append((0,0,{'product_id':test.name.product_id.id,
64
'price_unit':test.name.product_id.lst_price}))
66
pos_data['lines'] = test_line
67
pos_id = pos_obj.create(cr, uid, pos_data)
70
'domain': "[('id','=', "+str(pos_id)+")]",
73
'view_mode': 'tree,form',
74
'res_model': 'pos.order',
75
'type': 'ir.actions.act_window'
77
raise wizard.except_wizard(_('UserError'),_('No Lab test exist for selected Dr.'))
79
class make_lab_pos(wizard.interface):
89
('create_pos', 'Create POS')
97
'action': _create_pos,
103
make_lab_pos("patient.create_lab_pos")
106
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: