xxx
parent
e7de1c88a5
commit
9555384428
|
@ -1,4 +1,6 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_file_path
|
||||
from . import utils
|
||||
|
||||
class ImportUC(Model):
|
||||
_name="clinic.import.uc"
|
||||
|
@ -27,6 +29,51 @@ class ImportUC(Model):
|
|||
|
||||
def do_import(self,ids,context):
|
||||
obj=self.browse(ids)[0]
|
||||
partner=obj.type_id.contact_id
|
||||
if not partner:
|
||||
raise Exception("No partner")
|
||||
account_id=partner.account_income_id.id
|
||||
if not account_id:
|
||||
raise Exception("No account income")
|
||||
|
||||
vals={
|
||||
'direct_lines':[],
|
||||
}
|
||||
patients={}
|
||||
for p in get_model("clinic.patient").search_browse([]):
|
||||
patients[p.hn_num]=p.name
|
||||
|
||||
if obj.type_id.code=='U':
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
node='EPOBills'
|
||||
lines=utils.read_xml(fpath,node=node)
|
||||
#hcode_impt=fname.split("_")[0]
|
||||
epoadm=0
|
||||
for line in lines:
|
||||
hn=line.get('hn')
|
||||
hn_num=''.join(x for x in hn if x.isdigit()) #XXX
|
||||
epoadm=line.get("epoadm")
|
||||
lines2=line.get("epos").get('EPO',[])
|
||||
name='%s %s'%(hn,patients.get(hn_num,""))
|
||||
for l2 in lines2:
|
||||
if type(l2)==type(''):
|
||||
continue
|
||||
desc=l2.get('@desc')
|
||||
if '-' in desc:
|
||||
continue
|
||||
name+=desc
|
||||
vals['direct_lines'].append(('create',{
|
||||
'description': name,
|
||||
'qty': 1,
|
||||
'unit_price': epoadm,
|
||||
'amount': epoadm,
|
||||
'account_id': account_id,
|
||||
}))
|
||||
|
||||
for dline in obj.payment_id.direct_lines:
|
||||
dline.delete()
|
||||
obj.payment_id.write(vals)
|
||||
|
||||
return {
|
||||
'next': {
|
||||
|
|
Loading…
Reference in New Issue