conv_bal
watcha.h 2014-10-03 13:09:10 +07:00
parent 6c3cb71d97
commit a68e0f5743
14 changed files with 207 additions and 4 deletions

View File

@ -0,0 +1,6 @@
<action>
<field name="string">Import Journal Entry</field>
<field name="view_cls">multi_view</field>
<field name="model">clinic.je</field>
<field name="menu">clinic_menu</field>
</action>

View File

@ -0,0 +1,44 @@
<form model="clinic.je">
<head>
<field name="state"/>
</head>
<group span="6" columns="1">
<field name="number"/>
<field name="name"/>
<!--<field name="type" required="1"/>-->
</group>
<group span="6" columns="1">
<field name="date_import"/>
<field name="file"/>
<field name="payment_id" readonly="1"/>
</group>
<tabs>
<tab string="File Information">
<group span="6" columns="1">
<separator string="Sheets"/>
<field name="sheets" count="5" nolabel="1">
<list>
<field name="name"/>
<field name="process_type"/>
</list>
</field>
</group>
<group span="6" columns="1">
<separator string="Options"/>
<button string="Load Sheet" type="primary" icon="download" method="load_sheet"/>
<newline/>
<button string="Process" type="success" icon="arrow-right" method="process"/>
</group>
</tab>
<tab string="Invoices">
<field name="lines" count="10" nolabel="1">
<list>
<field name="invoice_id"/>
<field name="amount"/>
</list>
</field>
</tab>
</tabs>
<foot>
</foot>
</form>

View File

@ -0,0 +1,6 @@
<list model="clinic.je" colors='{"#ccc":[["state","=","fail"]]}'>
<field name="number"/>
<field name="name"/>
<field name="date_import"/>
<field name="state"/>
</list>

View File

@ -11,8 +11,8 @@
<item string="Reports">
<item string="Report1" action="report1"/>
</item>
<item string="Config/Import">
<item string="Account (TB, Unpaid AP and AR)" action="report1"/>
<item string="Imports">
<item string="JE" action="clinic_je"/>
</item>
<item string="Settings">
<item string="Departments" action="clinic_department"/>

View File

@ -9,10 +9,11 @@
<!--<field name="type" onchange="onchange_type"/>-->
<field name="type"/>
<field name="name"/>
<field name="hn"/>
<field name="reg_date"/>
<field name="job"/>
<field name="salary"/>
<field name="gender"/>
<field name="salary"/>
<field name="marital_status"/>
<field name="partner_id"/>
<tabs>

View File

@ -1,5 +1,6 @@
<list model="clinic.patient">
<field name="number"/>
<field name="hn"/>
<field name="name"/>
<field name="reg_date"/>
<field name="type"/>

View File

@ -18,3 +18,7 @@ from . import graduation
from . import nation
from . import race
from . import cause_chronic
from . import je
from . import input_line
from . import file_sheet
from . import file_column

View File

@ -160,6 +160,10 @@ class Dialyzer(Model):
def renew(self,ids,context={}):
obj=self.browse(ids[0])
# XXX
if obj.use_time > obj.max_use_time:
raise Exception("No long to use it (use time > max use time")
obj.cancel()
obj.write({"state": "new"})
def drop(self,ids,context={}):

View File

@ -0,0 +1,13 @@
from netforce.model import Model, fields
class FileColumn(Model):
_name="clinic.file.column"
_string="File Column"
_fields={
'name': fields.Char("Name"),
'index': fields.Integer("Index"),
'je_id': fields.Many2One("clinic.je","Journal Entry"),
}
FileColumn.register()

View File

@ -0,0 +1,15 @@
from netforce.model import Model, fields
class FileSheet(Model):
_name="clinic.file.sheet"
_string="File Sheet"
_fields={
'name': fields.Char("Name"),
'index': fields.Integer("Index"),
#"select": fields.Selection([("yes","Yes"),("no","No")],"Select",required=True),
"process_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)")],"Import Type"),
'je_id': fields.Many2One("clinic.je","Journal Entry"),
}
FileSheet.register()

View File

@ -0,0 +1,14 @@
import time
from netforce.model import Model, fields
class InputLine(Model):
_name="clinic.input.line"
_string="Input Line"
_fields={
'je_id': fields.Many2One("clinic.je","Journal Entry"),
'invoice_id': fields.Many2One("account.invoice","Invoice"),
'amount': fields.Float("Amount"),
}
InputLine.register()

View File

@ -0,0 +1,94 @@
import time
import xlrd
from netforce.model import Model, fields, get_model
from netforce.access import get_active_user, set_active_user
from netforce.utils import get_file_path
class JE(Model):
_name="clinic.je"
_string="Import Journal Entry"
_fields={
"number": fields.Char("Number"),
"name": fields.Char("Description"),
"date_import": fields.DateTime("Date Import"),
#"type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)")],"Type"),
'file': fields.File("File"),
'payment_id': fields.Many2One("account.payment","Payment"),
'lines': fields.One2Many("clinic.input.line","je_id", "Input Line"),
'sheets': fields.One2Many("clinic.file.sheet","je_id", "Sheets"),
'columns': fields.One2Many("clinic.file.column","je_id", "Columns"),
"state": fields.Selection([("draft","Draft"),('sheet_loaded','Sheet Loaded'),("fail","Fail"),("done","Done")],"Status",required=True),
}
def _get_number(self,context={}):
while 1:
seq_id=get_model("sequence").find_sequence(name="Clinic Import JE")
num=get_model("sequence").get_next_number(seq_id,context=context)
if not num:
return None
user_id=get_active_user()
set_active_user(1)
res=self.search([["number","=",num]])
set_active_user(user_id)
if not res:
return num
get_model("sequence").increment_number(seq_id,context=context)
def _get_name(self,context={}):
timenow=time.strftime("%Y-%m-%d")
return 'Import Journal Entry - %s'%timenow
_defaults={
'date_import': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
'number': _get_number,
'name': _get_name,
'state': 'draft',
}
def load_sheet(self,ids,context={}):
obj=self.browse(ids[0])
fname=obj.file
if not fname:
raise Exception("Please select file!")
fpath=get_file_path(fname)
suffix=fpath.split(".")[-1]
if suffix not in ('xls', 'xlsx'):
raise Exception("ERROR : file support only xls, xlsx")
wb=xlrd.open_workbook(fpath)
sheets=wb.sheet_names()
index=0
# XXX clear old sheet
for sheet in obj.sheets:
sheet.delete()
vals={
'sheets': [],
}
for sheet in sheets:
line={
'index': index,
'name': sheet,
}
vals["sheets"].append(("create",line))
vals['state']='sheet_loaded'
obj.write(vals)
return {
'next': {
'name': "clinic_je",
'mode': 'form',
'active_id': obj.id,
},
'flash': "Load sheet successfully",
}
def process(self,ids,context={}):
obj=self.browse(ids[0])
if not obj.sheets:
raise Exception("No Sheet yet!")
JE.register()

View File

@ -31,6 +31,7 @@ class Patient(Model):
_fields={
"type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Patient Type",required=True),
"number": fields.Char("Patient No.",required=True,search=True),
"hn": fields.Char("HN",search=True),
"name": fields.Char("Name",required=True,search=True),
"reg_date": fields.Date("Register Date",required=False,search=True),
"birthday": fields.Date("Birthday",required=False,search=True),

View File

@ -147,7 +147,7 @@ class Visit(Model):
data['doctor_id']=visit.doctor_id.id
data['department_id']=visit.department_id.id
else:
data['patient_id']=None
data['doctor_id']=None
data['department_id']=None
return data