import data
parent
c4fda2bb58
commit
484676dcbb
|
@ -5,7 +5,7 @@
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<!--<field name="type" required="1"/>-->
|
<field name="type" required="1"/>
|
||||||
</group>
|
</group>
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
<field name="date_import"/>
|
<field name="date_import"/>
|
||||||
|
@ -19,16 +19,34 @@
|
||||||
<field name="sheets" count="5" nolabel="1">
|
<field name="sheets" count="5" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="process_type"/>
|
<field name="select" onchange="onchange_sheet"/>
|
||||||
|
<!--<field name="process_type"/>-->
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
<separator string="Options"/>
|
<separator string="Options"/>
|
||||||
|
<group span="3" columns="1">
|
||||||
<button string="Load Sheet" type="primary" icon="download" method="load_sheet"/>
|
<button string="Load Sheet" type="primary" icon="download" method="load_sheet"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<button string="Process" type="success" icon="arrow-right" method="process"/>
|
<button string="Load DATA" type="warning" icon="download" method="load_data"/>
|
||||||
|
<newline/>
|
||||||
|
<button string="Find Invoice" type="success" icon="search" method="find_invoice"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group span="3" columns="1">
|
||||||
|
<field name="description" width="300" height="250" nolabel="1"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</tab>
|
||||||
|
<tab string="Priview">
|
||||||
|
<field name="input_data" count="10" nolabel="1">
|
||||||
|
<list>
|
||||||
|
<field name="doc_date"/>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="hn"/>
|
||||||
|
<field name="amount"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Invoices">
|
<tab string="Invoices">
|
||||||
<field name="lines" count="10" nolabel="1">
|
<field name="lines" count="10" nolabel="1">
|
||||||
|
@ -38,7 +56,11 @@
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</tab>
|
</tab>
|
||||||
|
<tab string="History">
|
||||||
|
<separator string="TODO"/>
|
||||||
|
</tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
<foot>
|
<foot>
|
||||||
|
<button string="Import" type="success" icon="arrow-right" method="import2journal"/>
|
||||||
</foot>
|
</foot>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -19,6 +19,6 @@ from . import nation
|
||||||
from . import race
|
from . import race
|
||||||
from . import cause_chronic
|
from . import cause_chronic
|
||||||
from . import je
|
from . import je
|
||||||
|
from . import input_data
|
||||||
from . import input_line
|
from . import input_line
|
||||||
from . import file_sheet
|
from . import file_sheet
|
||||||
from . import file_column
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
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()
|
|
|
@ -7,8 +7,7 @@ class FileSheet(Model):
|
||||||
_fields={
|
_fields={
|
||||||
'name': fields.Char("Name"),
|
'name': fields.Char("Name"),
|
||||||
'index': fields.Integer("Index"),
|
'index': fields.Integer("Index"),
|
||||||
#"select": fields.Selection([("yes","Yes"),("no","No")],"Select",required=True),
|
"select": fields.Selection([("yes","Yes"),("no","No")],"Select"),
|
||||||
"process_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)")],"Import Type"),
|
|
||||||
'je_id': fields.Many2One("clinic.je","Journal Entry"),
|
'je_id': fields.Many2One("clinic.je","Journal Entry"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
from netforce.model import Model, fields
|
||||||
|
|
||||||
|
class InputData(Model):
|
||||||
|
_name="clinic.input.data"
|
||||||
|
_string="Input Data"
|
||||||
|
_fields={
|
||||||
|
'doc_date': fields.Char("Doc Date"),
|
||||||
|
'name': fields.Char("Name"),
|
||||||
|
'hn': fields.Char("HN"),
|
||||||
|
'amount': fields.Float("Amount"),
|
||||||
|
'je_id': fields.Many2One("clinic.je","Journal Entry"),
|
||||||
|
}
|
||||||
|
|
||||||
|
InputData.register()
|
|
@ -4,6 +4,7 @@ import xlrd
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.access import get_active_user, set_active_user
|
from netforce.access import get_active_user, set_active_user
|
||||||
from netforce.utils import get_file_path
|
from netforce.utils import get_file_path
|
||||||
|
from netforce.utils import get_data_path
|
||||||
|
|
||||||
class JE(Model):
|
class JE(Model):
|
||||||
_name="clinic.je"
|
_name="clinic.je"
|
||||||
|
@ -13,13 +14,15 @@ class JE(Model):
|
||||||
"number": fields.Char("Number"),
|
"number": fields.Char("Number"),
|
||||||
"name": fields.Char("Description"),
|
"name": fields.Char("Description"),
|
||||||
"date_import": fields.DateTime("Date Import"),
|
"date_import": fields.DateTime("Date Import"),
|
||||||
#"type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)")],"Type"),
|
"type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)")],"Type"),
|
||||||
'file': fields.File("File"),
|
'file': fields.File("File"),
|
||||||
'payment_id': fields.Many2One("account.payment","Payment"),
|
'payment_id': fields.Many2One("account.payment","Payment"),
|
||||||
'lines': fields.One2Many("clinic.input.line","je_id", "Input Line"),
|
'lines': fields.One2Many("clinic.input.line","je_id", "Input Line"),
|
||||||
|
'input_data': fields.One2Many("clinic.input.data","je_id", "Input Data"),
|
||||||
'sheets': fields.One2Many("clinic.file.sheet","je_id", "Sheets"),
|
'sheets': fields.One2Many("clinic.file.sheet","je_id", "Sheets"),
|
||||||
'columns': fields.One2Many("clinic.file.column","je_id", "Columns"),
|
'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),
|
"state": fields.Selection([("draft","Draft"),('sheet_loaded','Sheet Loaded'),("fail","Fail"),("done","Done")],"Status",required=True),
|
||||||
|
'description': fields.Text("Description")
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
|
@ -85,10 +88,53 @@ class JE(Model):
|
||||||
'flash': "Load sheet successfully",
|
'flash': "Load sheet successfully",
|
||||||
}
|
}
|
||||||
|
|
||||||
def process(self,ids,context={}):
|
def load_data(self,ids,context={}):
|
||||||
obj=self.browse(ids[0])
|
obj=self.browse(ids[0])
|
||||||
if not obj.sheets:
|
if not obj.file:
|
||||||
raise Exception("No Sheet yet!")
|
raise Exception("Please select some file!")
|
||||||
|
|
||||||
|
if not obj.sheets:
|
||||||
|
raise Exception("Please load sheet!")
|
||||||
|
indexes=[]
|
||||||
|
for sheet in obj.sheets:
|
||||||
|
if sheet.select=='yes':
|
||||||
|
indexes.append((sheet.index,sheet.name))
|
||||||
|
if not indexes:
|
||||||
|
raise Exception("Please select some sheet!")
|
||||||
|
if len(indexes) > 1:
|
||||||
|
raise Exception("Only one sheet can select!")
|
||||||
|
sheet_name=indexes[0][1]
|
||||||
|
fname=obj.file
|
||||||
|
fpath=get_file_path(fname)
|
||||||
|
wb=xlrd.open_workbook(fpath)
|
||||||
|
ws=wb.sheet_by_name(sheet_name)
|
||||||
|
num_rows = ws.nrows - 1
|
||||||
|
curr_row = -1
|
||||||
|
records=[]
|
||||||
|
import pprint
|
||||||
|
while curr_row < num_rows:
|
||||||
|
curr_row += 1
|
||||||
|
#row=ws.row(curr_row)
|
||||||
|
record={}
|
||||||
|
# XXX
|
||||||
|
for col in (1,2,3,4):
|
||||||
|
record[col]=ws.cell_value(curr_row, col)
|
||||||
|
records.append(record)
|
||||||
|
pprint.pprint(records)
|
||||||
|
|
||||||
|
def find_invoice(self,ids,context={}):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def import2journal(self,ids,context={}):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def onchange_sheet(self,context={}):
|
||||||
|
data=context["data"]
|
||||||
|
path=context["path"]
|
||||||
|
line=get_data_path(data,path,parent=True)
|
||||||
|
for sheet in data['sheets']:
|
||||||
|
if sheet['name']!=line['name']:
|
||||||
|
sheet['select']=None
|
||||||
|
return data
|
||||||
|
|
||||||
JE.register()
|
JE.register()
|
||||||
|
|
Loading…
Reference in New Issue