merge production
commit
a67f7aacda
|
@ -1,9 +1,7 @@
|
||||||
<record model="action">
|
<record model="action">
|
||||||
<field name="name">clinic_print_labor_cost</field>
|
<field name="string">Print Labor Cost</field>
|
||||||
<field name="view_cls">form_view</field>
|
<field name="view_cls">multi_view</field>
|
||||||
<field name="model">clinic.print.labor.cost</field>
|
<field name="model">clinic.print.labor.cost</field>
|
||||||
<field name="view_xml">clinic_print_labor_cost</field>
|
|
||||||
<field name="active_id">1</field>
|
|
||||||
<field name="menu">account_menu</field>
|
<field name="menu">account_menu</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<head>
|
<head>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
<item string="Copy" method="copy" states="active"/>
|
<item string="Copy" method="copy"/>
|
||||||
<item string="To Draft" method="to_draft" states="drop,active,expire"/>
|
<item string="To Draft" method="to_draft" states="active"/>
|
||||||
</button>
|
</button>
|
||||||
</head>
|
</head>
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
|
@ -24,6 +24,8 @@
|
||||||
<field name="company_id" invisible="1"/>
|
<field name="company_id" invisible="1"/>
|
||||||
</group>
|
</group>
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
|
<field name="create_user_id"/>
|
||||||
|
<field name="write_user_id"/>
|
||||||
</group>
|
</group>
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<field name="membrane_type" required="1" span="6"/>
|
<field name="membrane_type" required="1" span="6"/>
|
||||||
<field name="exp_date" span="6"/>
|
<field name="exp_date" span="6"/>
|
||||||
<field name="note" span="6"/>
|
<field name="note" span="6"/>
|
||||||
|
<field name="drop_old" span="6"/>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Validate" type="success" method="new_dlz"/>
|
<button string="Validate" type="success" method="new_dlz"/>
|
||||||
</foot>
|
</foot>
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
<field name="use_time"/>
|
<field name="use_time"/>
|
||||||
<field name="max_use_time"/>
|
<field name="max_use_time"/>
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
|
<field name="state"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
<field name="note"/>
|
<field name="note"/>
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
<form model="clinic.print.labor.cost" title="Print Labor Cost">
|
|
||||||
<group form_layout="stacked">
|
|
||||||
<field name="period_id" domain='[["state","=","open"]]' onchange="onchange_period" span="2"/>
|
|
||||||
<field name="date_from" span="2"/>
|
|
||||||
<field name="date_to" span="2"/>
|
|
||||||
<field name="branch_id" onchange='onchange_branch' span="2"/>
|
|
||||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
|
||||||
<field name="cycle_id" span="2"/>
|
|
||||||
<field name="staff_type" required="1" span="2"/>
|
|
||||||
<button string="Generate Report" method="do_generate" icon="arrow-right" type="default"/>
|
|
||||||
<field name="report_labor_cost" span="3" readonly="1"/>
|
|
||||||
<field name="report_summary" span="3" readonly="1"/>
|
|
||||||
<field name="lines" nolabel="1" readonly="1">
|
|
||||||
<list>
|
|
||||||
<field name="staff_name" readonly="1"/>
|
|
||||||
<field name="report_detail" readonly="1"/>
|
|
||||||
<field name="report_sub_detail" readonly="1"/>
|
|
||||||
<!--<field name="report_daily" readonly="1"/>-->
|
|
||||||
<!--<field name="report_ot" readonly="1"/>-->
|
|
||||||
</list>
|
|
||||||
</field>
|
|
||||||
</group>
|
|
||||||
<foot replace="1">
|
|
||||||
</foot>
|
|
||||||
</form>
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<form model="clinic.print.labor.cost" title="Print Labor Cost" show_company="1">
|
||||||
|
<head>
|
||||||
|
<field name="state"/>
|
||||||
|
</head>
|
||||||
|
<group form_layout="stacked">
|
||||||
|
<field name="period_id" domain='[["state","=","open"]]' onchange="onchange_period" span="2"/>
|
||||||
|
<field name="date_from" span="2"/>
|
||||||
|
<field name="date_to" span="2"/>
|
||||||
|
<field name="branch_id" onchange='onchange_branch' span="2"/>
|
||||||
|
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||||
|
<field name="cycle_id" span="2"/>
|
||||||
|
<field name="staff_type" required="1" span="2"/>
|
||||||
|
<field name="zip_file" span="2"/>
|
||||||
|
</group>
|
||||||
|
<foot>
|
||||||
|
<button string="Generate Report" method="do_generate" icon="arrow-right" type="default"/>
|
||||||
|
</foot>
|
||||||
|
</form>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<list model="clinic.print.labor.cost">
|
||||||
|
<field name="period_id"/>
|
||||||
|
<field name="zip_file"/>
|
||||||
|
<field name="state"/>
|
||||||
|
</list>
|
|
@ -6,6 +6,7 @@
|
||||||
<field name="ptype_id" span="2"/>
|
<field name="ptype_id" span="2"/>
|
||||||
<field name="branch_id" onchange="onchange_type" span="2"/>
|
<field name="branch_id" onchange="onchange_type" span="2"/>
|
||||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||||
|
<field name="sort_by" span="2"/>
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
</head>
|
</head>
|
||||||
<separator string="Visit"/>
|
<separator string="Visit"/>
|
||||||
<group form_layout="stacked">
|
<group form_layout="stacked">
|
||||||
<field name="find_dlz"/>
|
<field name="find_dlz" span="3"/>
|
||||||
|
<field name="hdcase_picking_auto" span="3"/>
|
||||||
|
<field name="dlz_picking_auto" span="3"/>
|
||||||
</group>
|
</group>
|
||||||
<separator string="HD Case"/>
|
<separator string="HD Case"/>
|
||||||
<group form_layout="stacked">
|
<group form_layout="stacked">
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
from . import clinic_setting
|
from . import clinic_setting
|
||||||
#from . import conv_bal
|
#from . import conv_bal
|
||||||
|
#from . import clinic_setting
|
||||||
#from . import repost_invoice
|
#from . import repost_invoice
|
||||||
|
#from . import conv_bal
|
||||||
|
#from . import tb_ap_import
|
||||||
|
#from . import check_seq
|
||||||
|
#from . import del_gi
|
||||||
|
#from . import restore_picking
|
||||||
|
from . import rename_dbl_hdcase_number
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
from netforce.model import get_model
|
||||||
|
from netforce import migration
|
||||||
|
from netforce.access import set_active_user, set_active_company
|
||||||
|
|
||||||
|
class Migration(migration.Migration):
|
||||||
|
_name="clinic.check.seq"
|
||||||
|
_version="2.11.0"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
set_active_user(1)
|
||||||
|
set_active_company(1)
|
||||||
|
fnames=['branch_id','prefix']
|
||||||
|
seqs=dict([(x['branch_id'][0],x['prefix']) for x in get_model("sequence").search_read([['type','=','clinic_hdcase']],fnames)])
|
||||||
|
print('seqs ',seqs)
|
||||||
|
count=0
|
||||||
|
for hdcase in get_model('clinic.hd.case').search_browse([]):
|
||||||
|
seq=seqs[hdcase.branch_id.id]
|
||||||
|
rp=seq.split("/")[-1].replace("-","")
|
||||||
|
if '/' in hdcase.number and hdcase.number!='/':
|
||||||
|
if seq not in hdcase.number:
|
||||||
|
pf=hdcase.number.split('-')[0].split("/")[-1]
|
||||||
|
new_hdcase_number=hdcase.number.replace(pf,rp)
|
||||||
|
new_visit_number=hdcase.visit_id.number.replace(pf,rp)
|
||||||
|
print(hdcase.number, new_hdcase_number,hdcase.department_id.name)
|
||||||
|
print(hdcase.visit_id.number, new_visit_number, hdcase.visit_id.department_id.name)
|
||||||
|
hdcase.write({
|
||||||
|
'number': new_hdcase_number,
|
||||||
|
})
|
||||||
|
hdcase.visit_id.write({
|
||||||
|
'number': new_visit_number,
|
||||||
|
})
|
||||||
|
print('-'*100)
|
||||||
|
#print(seq, ' : ', hdcase.number, hdcase.visit_id.number, hdcase.date, hdcase.patient_id.name)
|
||||||
|
count+=1
|
||||||
|
print('total unmatch', count)
|
||||||
|
|
||||||
|
Migration.register()
|
|
@ -9,14 +9,43 @@ class Migration(migration.Migration):
|
||||||
def migrate(self):
|
def migrate(self):
|
||||||
set_active_user(1)
|
set_active_user(1)
|
||||||
set_active_company(1)
|
set_active_company(1)
|
||||||
#for mv in get_model("account.move").search_browse([['number','ilike', 'OPEN']]):
|
|
||||||
#mv.to_draft()
|
# delete old account payable
|
||||||
#mv.delete()
|
dom=[
|
||||||
|
['memo','=','Conversion balance 2015-06-30'],
|
||||||
|
['type','=','in'],
|
||||||
|
['state','=','waiting_payment'],
|
||||||
|
]
|
||||||
|
for inv in get_model('account.invoice').search_browse(dom):
|
||||||
|
print('delete invoice... ', inv.number)
|
||||||
|
inv.to_draft()
|
||||||
|
inv.delete()
|
||||||
|
|
||||||
|
# delete old account rereivable
|
||||||
|
dom=[
|
||||||
|
['memo','=','Conversion balance 2015-06-30'],
|
||||||
|
['type','=','out'],
|
||||||
|
['state','=','waiting_payment'],
|
||||||
|
]
|
||||||
|
for inv in get_model('account.invoice').search_browse(dom):
|
||||||
|
print('delete invoice... ', inv.number)
|
||||||
|
inv.to_draft()
|
||||||
|
inv.delete()
|
||||||
|
# remove journal entry
|
||||||
|
dom=[
|
||||||
|
['number','=','OPENING ENTRY'],
|
||||||
|
]
|
||||||
|
for move in get_model('account.move').search_browse(dom):
|
||||||
|
print('delete accout.move... ', move.number)
|
||||||
|
move.to_draft()
|
||||||
|
move.delete()
|
||||||
|
|
||||||
cbv_id=24
|
cbv_id=24
|
||||||
cbv=get_model("conv.bal").browse(cbv_id)
|
cbv=get_model("conv.bal").browse(cbv_id)
|
||||||
cbv.write({
|
cbv.write({
|
||||||
'date_fmt': '%Y-%m-%d',
|
'date_fmt': '%Y-%m-%d',
|
||||||
'file': 'tb.csv',
|
'file': 'tb.csv',
|
||||||
|
'date': '2015-06-30',
|
||||||
})
|
})
|
||||||
print("import acc file (step 1) running ...")
|
print("import acc file (step 1) running ...")
|
||||||
get_model("conv.bal").import_acc_file([cbv.id],context={})
|
get_model("conv.bal").import_acc_file([cbv.id],context={})
|
||||||
|
@ -39,7 +68,8 @@ class Migration(migration.Migration):
|
||||||
print("import purch file (step 3) running ...")
|
print("import purch file (step 3) running ...")
|
||||||
cbv.write({
|
cbv.write({
|
||||||
'file': 'ap.csv',
|
'file': 'ap.csv',
|
||||||
'date_fmt': '%d/%m/%Y',
|
#'date_fmt': '%d/%m/%Y',
|
||||||
|
'date_fmt': '%Y-%m-%d',
|
||||||
})
|
})
|
||||||
get_model("conv.bal").import_purch_file([cbv.id],context={})
|
get_model("conv.bal").import_purch_file([cbv.id],context={})
|
||||||
get_model("conv.bal").import_purch([cbv.id],context={})
|
get_model("conv.bal").import_purch([cbv.id],context={})
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
import time
|
||||||
|
|
||||||
|
from netforce.model import get_model
|
||||||
|
from netforce import migration
|
||||||
|
from netforce.access import set_active_user, set_active_company
|
||||||
|
|
||||||
|
class Migration(migration.Migration):
|
||||||
|
_name="clinic.del.gi"
|
||||||
|
_version="2.12.0"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
set_active_user(1)
|
||||||
|
set_active_company(1)
|
||||||
|
#fmt='%Y-%m-%d %H:%M:%S'
|
||||||
|
#datenow=time.strftime(fmt)
|
||||||
|
dom=[
|
||||||
|
['date','>=','2015-01-01 00:00:00'],
|
||||||
|
['date','<=','2015-06-30 23:59:59'],
|
||||||
|
['type','=','out'],
|
||||||
|
]
|
||||||
|
count=0
|
||||||
|
for pick in get_model('stock.picking').search_browse(dom):
|
||||||
|
print('del ', pick.date, pick.id, pick.number)
|
||||||
|
pick.delete()
|
||||||
|
count+=1
|
||||||
|
|
||||||
|
print("Delete From 2015-01-01 to 2015-06-30 Total is: ", count)
|
||||||
|
|
||||||
|
rows=open("/tmp/del_gi.csv","r").read()
|
||||||
|
ids=[]
|
||||||
|
for row in rows.split("\n"):
|
||||||
|
try:
|
||||||
|
r=row.split(",")
|
||||||
|
idtxt=r[1]
|
||||||
|
if idtxt.isnumeric():
|
||||||
|
ids.append(int(idtxt))
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR ", e)
|
||||||
|
count=0
|
||||||
|
for id in ids:
|
||||||
|
pick=get_model('stock.picking').browse(id)
|
||||||
|
try:
|
||||||
|
print('del ', pick.date, pick.id, pick.number)
|
||||||
|
pick.delete()
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR ",e)
|
||||||
|
count+=1
|
||||||
|
print("Delete from file Total: ",count)
|
||||||
|
|
||||||
|
Migration.register()
|
|
@ -0,0 +1,28 @@
|
||||||
|
import time
|
||||||
|
|
||||||
|
from netforce.model import get_model
|
||||||
|
from netforce import migration
|
||||||
|
from netforce.access import set_active_user, set_active_company
|
||||||
|
from netforce.database import get_connection
|
||||||
|
|
||||||
|
class Migration(migration.Migration):
|
||||||
|
_name="clinic.rename.dbl.hdcase.number"
|
||||||
|
_version="2.12.2"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
db=get_connection()
|
||||||
|
res=db.query("""
|
||||||
|
select c, number from (select count(number) as c,number from clinic_hd_case group by number order by number) as r1 where c > 1;
|
||||||
|
""")
|
||||||
|
for r in res:
|
||||||
|
number=r['number']
|
||||||
|
if number!='/':
|
||||||
|
count=1
|
||||||
|
for hdcase in get_model('clinic.hd.case').search_browse([['number','=',number]]):
|
||||||
|
hdcase.write({
|
||||||
|
'number': number+"."+str(count),
|
||||||
|
})
|
||||||
|
count+=1
|
||||||
|
print(r)
|
||||||
|
|
||||||
|
Migration.register()
|
|
@ -39,7 +39,6 @@ class Migration(migration.Migration):
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
})
|
})
|
||||||
ids=list(hdcase_ids)
|
ids=list(hdcase_ids)
|
||||||
|
|
||||||
for seq in get_model("sequence").search_browse([['type','in',['cust_invoice','clinic_invoice_noclaim']]]):
|
for seq in get_model("sequence").search_browse([['type','in',['cust_invoice','clinic_invoice_noclaim']]]):
|
||||||
for run in seq.running:
|
for run in seq.running:
|
||||||
run.delete()
|
run.delete()
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
import time
|
||||||
|
|
||||||
|
from netforce.model import get_model
|
||||||
|
from netforce import migration
|
||||||
|
from netforce.access import set_active_user, set_active_company
|
||||||
|
|
||||||
|
class Migration(migration.Migration):
|
||||||
|
_name="clinic.restore.picking"
|
||||||
|
_version="2.12.1"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
set_active_user(1)
|
||||||
|
set_active_company(1)
|
||||||
|
#remove all good issued from dlz
|
||||||
|
total_del=0
|
||||||
|
for dlz in get_model('clinic.dialyzer').search_browse([]):
|
||||||
|
for pick in dlz.pickings:
|
||||||
|
print('del pick ',pick.number)
|
||||||
|
pick.delete()
|
||||||
|
total_del+=1
|
||||||
|
print('total delete ', total_del)
|
||||||
|
fmt='%Y-%m-%d %H:%M:%S'
|
||||||
|
datenow=time.strftime(fmt)
|
||||||
|
dom=[
|
||||||
|
['date','>=','2015-01-01'],
|
||||||
|
['date','<=',datenow],
|
||||||
|
]
|
||||||
|
for hdcase in get_model("clinic.hd.case").search_browse(dom):
|
||||||
|
if not hdcase.pickings:
|
||||||
|
print('gen picking for %s in %s'%(hdcase.number, hdcase.date))
|
||||||
|
ctx={
|
||||||
|
'migrate':True,
|
||||||
|
}
|
||||||
|
hdcase.make_pickings(context=ctx)
|
||||||
|
|
||||||
|
Migration.register()
|
|
@ -0,0 +1,75 @@
|
||||||
|
from netforce.model import get_model
|
||||||
|
from netforce import migration
|
||||||
|
from netforce.access import set_active_user, set_active_company
|
||||||
|
|
||||||
|
class Migration(migration.Migration):
|
||||||
|
_name="clinic.tb.ap.import"
|
||||||
|
_version="2.10.0"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
set_active_user(1)
|
||||||
|
set_active_company(1)
|
||||||
|
#for mv in get_model("account.move").search_browse([['number','ilike', 'OPEN']]):
|
||||||
|
#mv.to_draft()
|
||||||
|
#mv.delete()
|
||||||
|
cbv_id=24
|
||||||
|
cbv=get_model("conv.bal").browse(cbv_id)
|
||||||
|
cbv.write({
|
||||||
|
'date_fmt': '%Y-%m-%d',
|
||||||
|
'file': 'tb.csv',
|
||||||
|
'date': '2015-06-30',
|
||||||
|
})
|
||||||
|
print("import acc file (step 1) running ...")
|
||||||
|
get_model("conv.bal").import_acc_file([cbv.id],context={})
|
||||||
|
get_model("conv.bal").import_acc([cbv.id],context={})
|
||||||
|
|
||||||
|
#print("import sale file (step 2)running ...")
|
||||||
|
#del_ids=get_model("conv.sale.invoice").search([["conv_id","=",cbv.id]])
|
||||||
|
#get_model('conv.sale.invoice').delete(del_ids)
|
||||||
|
#for ar_file in ['ar_fee','ar_epo','ar_srv','ar_other']:
|
||||||
|
#cbv.write({
|
||||||
|
#'date_fmt': '%d/%m/%Y',
|
||||||
|
#'file': '%s.csv'%(ar_file),
|
||||||
|
#})
|
||||||
|
#ctx={
|
||||||
|
#'is_append': True,
|
||||||
|
#}
|
||||||
|
#get_model("conv.bal").import_sale_file([cbv.id],context=ctx)
|
||||||
|
#get_model("conv.bal").import_sale([cbv.id],context={})
|
||||||
|
|
||||||
|
print("import purch file (step 3) running ...")
|
||||||
|
cbv.write({
|
||||||
|
'file': 'ap.csv',
|
||||||
|
#'date_fmt': '%d/%m/%Y',
|
||||||
|
'date_fmt': '%Y-%m-%d',
|
||||||
|
})
|
||||||
|
get_model("conv.bal").import_purch_file([cbv.id],context={})
|
||||||
|
get_model("conv.bal").import_purch([cbv.id],context={})
|
||||||
|
|
||||||
|
cbv.write({
|
||||||
|
'date_fmt': '%Y-%m-%d',
|
||||||
|
})
|
||||||
|
# delete old account payable
|
||||||
|
dom=[
|
||||||
|
['memo','=','Conversion balance 2015-06-30'],
|
||||||
|
['type','=','in'],
|
||||||
|
['state','=','waiting_payment'],
|
||||||
|
]
|
||||||
|
for inv in get_model('account.invoice').search_browse(dom):
|
||||||
|
print('delete invoice... ', inv.number)
|
||||||
|
inv.to_draft()
|
||||||
|
inv.delete()
|
||||||
|
print(">> next 3")
|
||||||
|
print("create_open_entry...")
|
||||||
|
ctx={
|
||||||
|
'tb_ap_only': True,
|
||||||
|
}
|
||||||
|
cbv.create_open_entry(context=ctx)
|
||||||
|
#print("create_sale_invoices...")
|
||||||
|
#cbv.create_sale_invoices()
|
||||||
|
print("create_purch_invoices...")
|
||||||
|
cbv.create_purch_invoices()
|
||||||
|
print("Done!")
|
||||||
|
return True
|
||||||
|
|
||||||
|
Migration.register()
|
|
@ -14,4 +14,5 @@ class User(Model):
|
||||||
_defaults={
|
_defaults={
|
||||||
'auto_load_dpt': True,
|
'auto_load_dpt': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
User.register()
|
User.register()
|
||||||
|
|
|
@ -41,6 +41,7 @@ class ChangeVisit(Model):
|
||||||
|
|
||||||
def do_change(self,ids,context):
|
def do_change(self,ids,context):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
context['branch_id']=obj.department_id.branch_id.id
|
||||||
dom=[
|
dom=[
|
||||||
['visit_date','=',obj.visit_date],
|
['visit_date','=',obj.visit_date],
|
||||||
['patient_id','=',obj.patient_id.id],
|
['patient_id','=',obj.patient_id.id],
|
||||||
|
@ -60,7 +61,7 @@ class ChangeVisit(Model):
|
||||||
'time_stop': obj.time_stop,
|
'time_stop': obj.time_stop,
|
||||||
'visit_date': obj.visit_date,
|
'visit_date': obj.visit_date,
|
||||||
'state': 'pending',
|
'state': 'pending',
|
||||||
})
|
},context=context)
|
||||||
obj.visit_id.to_draft()
|
obj.visit_id.to_draft()
|
||||||
obj.visit_id.cancel()
|
obj.visit_id.cancel()
|
||||||
visit=get_model("clinic.visit").browse(new_id)
|
visit=get_model("clinic.visit").browse(new_id)
|
||||||
|
|
|
@ -7,6 +7,10 @@ from netforce.utils import get_file_path
|
||||||
|
|
||||||
class ConvBal(Model):
|
class ConvBal(Model):
|
||||||
_inherit="conv.bal"
|
_inherit="conv.bal"
|
||||||
|
_fields={
|
||||||
|
'track_id': fields.Many2One("account.track.categ","Track-1"),
|
||||||
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
|
}
|
||||||
|
|
||||||
def create_sale_invoices(self,ids,context={}):
|
def create_sale_invoices(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
@ -54,40 +58,25 @@ class ConvBal(Model):
|
||||||
else:
|
else:
|
||||||
get_model("account.invoice").create(vals)
|
get_model("account.invoice").create(vals)
|
||||||
|
|
||||||
def _import_sale_file(self,ids,context):
|
def import_sale_file(self,ids,context):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
path=get_file_path(obj.file)
|
path=get_file_path(obj.file)
|
||||||
data=open(path).read()
|
data=open(path).read()
|
||||||
rd=csv.reader(StringIO(data))
|
rd=csv.reader(StringIO(data))
|
||||||
headers=next(rd)
|
headers=next(rd)
|
||||||
headers=[h.strip() for h in headers]
|
headers=[h.strip() for h in headers]
|
||||||
del_ids=get_model("conv.sale.invoice").search([["conv_id","=",obj.id]])
|
if not context.get('is_append'):
|
||||||
get_model("conv.sale.invoice").delete(del_ids)
|
del_ids=get_model("conv.sale.invoice").search([["conv_id","=",obj.id]])
|
||||||
|
get_model("conv.sale.invoice").delete(del_ids)
|
||||||
for row in rd:
|
for row in rd:
|
||||||
#print("row",row)
|
print("row",row)
|
||||||
row+="," #XXX append blank column for Amount Cur
|
|
||||||
line=dict(zip(headers,row))
|
line=dict(zip(headers,row))
|
||||||
#print("line",line)
|
print("line",line)
|
||||||
track_id=None
|
|
||||||
department_id=None
|
|
||||||
department_name=line.get("Department")
|
|
||||||
if department_name:
|
|
||||||
for dpt in get_model("clinic.department").search_browse([['name','=',department_name]]):
|
|
||||||
department_id=dpt.id
|
|
||||||
track_id=dpt.branch_id.track_id.id
|
|
||||||
if not line.get("Number"):
|
if not line.get("Number"):
|
||||||
continue
|
continue
|
||||||
number=line["Number"].strip()
|
number=line["Number"].strip()
|
||||||
if not number:
|
if not number:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
##XXX remove invoice
|
|
||||||
#for inv in get_model('account.invoice').search_browse([['number','=', number]]):
|
|
||||||
#print('number --> ', number)
|
|
||||||
#inv.to_draft()
|
|
||||||
#inv.delete()
|
|
||||||
#continue
|
|
||||||
|
|
||||||
ref=line["Reference"].strip()
|
ref=line["Reference"].strip()
|
||||||
contact_name=line["Contact"].strip()
|
contact_name=line["Contact"].strip()
|
||||||
res=get_model("partner").search([["name","=",contact_name]])
|
res=get_model("partner").search([["name","=",contact_name]])
|
||||||
|
@ -98,81 +87,34 @@ class ConvBal(Model):
|
||||||
due_date=datetime.datetime.strptime(line["Due Date"].strip(),obj.date_fmt).strftime("%Y-%m-%d")
|
due_date=datetime.datetime.strptime(line["Due Date"].strip(),obj.date_fmt).strftime("%Y-%m-%d")
|
||||||
amount_due=float(line["Amount Due"].strip().replace(",","") or 0)
|
amount_due=float(line["Amount Due"].strip().replace(",","") or 0)
|
||||||
acc_code=line["Account"].strip()
|
acc_code=line["Account"].strip()
|
||||||
|
res=get_model("account.account").search([["code","=",acc_code]])
|
||||||
|
if not res:
|
||||||
|
raise Exception("Account code not found: %s"%acc_code)
|
||||||
|
acc_id=res[0]
|
||||||
amount_cur=float(line["Amount Cur"].strip().replace(",","") or 0)
|
amount_cur=float(line["Amount Cur"].strip().replace(",","") or 0)
|
||||||
acc_codes=acc_code.split(",")
|
vals={
|
||||||
amts=[] #XXX
|
"conv_id": obj.id,
|
||||||
for m in line['Memo'].split(","):
|
"number": number,
|
||||||
amt=m.split(":")[1]
|
"ref": ref,
|
||||||
amt=amt.strip()
|
"contact_id": contact_id,
|
||||||
if amt:
|
"date": date,
|
||||||
amt=float(amt)
|
"due_date": due_date,
|
||||||
amts.append(amt)
|
"amount_due": amount_due,
|
||||||
if len(acc_codes) > 1:
|
"account_id": acc_id,
|
||||||
count=0
|
"amount_cur": amount_cur,
|
||||||
print("*"*80)
|
}
|
||||||
for acc_code in acc_codes:
|
department_name=line['Department']
|
||||||
acc_code=acc_code.strip()
|
track_name=line['Track-1']
|
||||||
res=get_model("account.account").search([["code","=",acc_code]])
|
if department_name:
|
||||||
if not res:
|
for department in get_model("clinic.department").search_browse([['name','=',department_name]]):
|
||||||
raise Exception("Account code not found: %s"%acc_code)
|
vals['department_id']=department.id
|
||||||
acc_id=res[0]
|
branch=department.branch_id
|
||||||
amount_due=amts[count]
|
track=branch.track_id
|
||||||
vals={
|
vals['track_id']=track.id
|
||||||
"conv_id": obj.id,
|
elif track_name:
|
||||||
"number": number,
|
for track_id in get_model("account.track.categ").search([['name','=',track_name]]):
|
||||||
"ref": ref,
|
vals['track_id']=track_id
|
||||||
"contact_id": contact_id,
|
get_model("conv.sale.invoice").create(vals)
|
||||||
"date": date,
|
|
||||||
"due_date": due_date,
|
|
||||||
"amount_due": amount_due,
|
|
||||||
"account_id": acc_id,
|
|
||||||
"amount_cur": amount_due, #XXX
|
|
||||||
'track_id': track_id,
|
|
||||||
'department_id': department_id,
|
|
||||||
}
|
|
||||||
get_model("conv.sale.invoice").create(vals)
|
|
||||||
count+=1
|
|
||||||
elif len(amts) >= 1 and len(acc_codes)<=1:
|
|
||||||
acc_code=acc_codes[0].strip()
|
|
||||||
res=get_model("account.account").search([["code","=",acc_code]])
|
|
||||||
if not res:
|
|
||||||
raise Exception("Account code not found: %s"%acc_code)
|
|
||||||
acc_id=res[0]
|
|
||||||
for amt in amts:
|
|
||||||
amount_due=amt
|
|
||||||
vals={
|
|
||||||
"conv_id": obj.id,
|
|
||||||
"number": number,
|
|
||||||
"ref": ref,
|
|
||||||
"contact_id": contact_id,
|
|
||||||
"date": date,
|
|
||||||
"due_date": due_date,
|
|
||||||
"amount_due": amount_due,
|
|
||||||
"account_id": acc_id,
|
|
||||||
"amount_cur": amount_due, #XXX
|
|
||||||
'track_id': track_id,
|
|
||||||
'department_id': department_id,
|
|
||||||
}
|
|
||||||
get_model("conv.sale.invoice").create(vals)
|
|
||||||
else:
|
|
||||||
res=get_model("account.account").search([["code","=",acc_code]])
|
|
||||||
if not res:
|
|
||||||
raise Exception("Account code not found: %s"%acc_code)
|
|
||||||
acc_id=res[0]
|
|
||||||
vals={
|
|
||||||
"conv_id": obj.id,
|
|
||||||
"number": number,
|
|
||||||
"ref": ref,
|
|
||||||
"contact_id": contact_id,
|
|
||||||
"date": date,
|
|
||||||
"due_date": due_date,
|
|
||||||
"amount_due": amount_due,
|
|
||||||
"account_id": acc_id,
|
|
||||||
"amount_cur": amount_cur,
|
|
||||||
'track_id': track_id,
|
|
||||||
'department_id': department_id,
|
|
||||||
}
|
|
||||||
get_model("conv.sale.invoice").create(vals)
|
|
||||||
return {
|
return {
|
||||||
"next": {
|
"next": {
|
||||||
"name": "conv_bal",
|
"name": "conv_bal",
|
||||||
|
|
|
@ -91,7 +91,7 @@ class Department(Model):
|
||||||
['clinic.sickbed','department_id.code','='],
|
['clinic.sickbed','department_id.code','='],
|
||||||
['clinic.shop','department_id.code','='],
|
['clinic.shop','department_id.code','='],
|
||||||
['clinic.department','code','='], #XXX
|
['clinic.department','code','='], #XXX
|
||||||
['clinic.dialyzer','department_id.code','='],
|
#['clinic.dialyzer','department_id.code','='], # support to use different location
|
||||||
['clinic.schedule','department_id.code','='],
|
['clinic.schedule','department_id.code','='],
|
||||||
]
|
]
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
|
|
|
@ -2,6 +2,7 @@ import time
|
||||||
|
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.access import get_active_company, get_active_user, set_active_user
|
from netforce.access import get_active_company, get_active_user, set_active_user
|
||||||
|
from netforce.database import get_connection
|
||||||
|
|
||||||
class Dialyzer(Model):
|
class Dialyzer(Model):
|
||||||
_name="clinic.dialyzer"
|
_name="clinic.dialyzer"
|
||||||
|
@ -10,6 +11,16 @@ class Dialyzer(Model):
|
||||||
_name_field="number"
|
_name_field="number"
|
||||||
_multi_company=True
|
_multi_company=True
|
||||||
|
|
||||||
|
def _get_user(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
db=get_connection()
|
||||||
|
for r in db.query("""select id,create_uid, write_uid from clinic_dialyzer where id in %s""",tuple(ids)):
|
||||||
|
res[r['id']]={
|
||||||
|
'create_user_id': r['create_uid'],
|
||||||
|
'write_user_id': r['write_uid'],
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"name": fields.Char("Name",search=True),
|
"name": fields.Char("Name",search=True),
|
||||||
"number": fields.Char("Number",required=True,search=True),
|
"number": fields.Char("Number",required=True,search=True),
|
||||||
|
@ -32,6 +43,8 @@ class Dialyzer(Model):
|
||||||
"hd_cases_dlz": fields.One2Many("clinic.hd.case.dialyzer","dialyzer_id","Dialyzer History",domain=[['hd_case_id.state','in','waiting_payment','paid']]),
|
"hd_cases_dlz": fields.One2Many("clinic.hd.case.dialyzer","dialyzer_id","Dialyzer History",domain=[['hd_case_id.state','in','waiting_payment','paid']]),
|
||||||
'department_id': fields.Many2One("clinic.department","Department",search=True),
|
'department_id': fields.Many2One("clinic.department","Department",search=True),
|
||||||
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
|
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
|
||||||
|
'write_user_id': fields.Many2One("base.user","Updated By",function="_get_user",function_multi=True),
|
||||||
|
'create_user_id': fields.Many2One("base.user","Create By",function="_get_user",function_multi=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
|
@ -117,63 +130,64 @@ class Dialyzer(Model):
|
||||||
st=get_model("clinic.setting").browse(1)
|
st=get_model("clinic.setting").browse(1)
|
||||||
stock_journal=st.stock_journal_id
|
stock_journal=st.stock_journal_id
|
||||||
|
|
||||||
wh_loc_id=None
|
if st.dlz_picking_auto:
|
||||||
cust_loc_id=None
|
wh_loc_id=None
|
||||||
department=obj.department_id
|
cust_loc_id=None
|
||||||
if department:
|
department=obj.department_id
|
||||||
stock_journal=department.pick_out_journal_id
|
if department:
|
||||||
if stock_journal:
|
stock_journal=department.pick_out_journal_id
|
||||||
wh_loc_id=stock_journal.location_from_id.id
|
if stock_journal:
|
||||||
cust_loc_id=stock_journal.location_to_id.id
|
wh_loc_id=stock_journal.location_from_id.id
|
||||||
print("get location from stock journal %s "%(stock_journal.name))
|
cust_loc_id=stock_journal.location_to_id.id
|
||||||
|
print("get location from stock journal %s "%(stock_journal.name))
|
||||||
|
|
||||||
if not stock_journal:
|
if not stock_journal:
|
||||||
raise Exception("Not found stock journal")
|
raise Exception("Not found stock journal")
|
||||||
|
pick_vals={
|
||||||
|
"type": "out",
|
||||||
|
'journal_id': stock_journal.id,
|
||||||
|
'date': obj.date,
|
||||||
|
"ref": obj.number,
|
||||||
|
"related_id": "clinic.dialyzer,%s"%obj.id,
|
||||||
|
"partner_id": obj.patient_id.partner_id.id,
|
||||||
|
"ship_address_id": ship_address_id,
|
||||||
|
"lines": [],
|
||||||
|
"state": "draft",
|
||||||
|
}
|
||||||
|
|
||||||
pick_vals={
|
if not cust_loc_id:
|
||||||
"type": "out",
|
res=get_model("stock.location").search([["type","=","customer"]])
|
||||||
'journal_id': stock_journal.id,
|
|
||||||
'date': obj.date,
|
|
||||||
"ref": obj.number,
|
|
||||||
"related_id": "clinic.dialyzer,%s"%obj.id,
|
|
||||||
"partner_id": obj.patient_id.partner_id.id,
|
|
||||||
"ship_address_id": ship_address_id,
|
|
||||||
"lines": [],
|
|
||||||
"state": "draft",
|
|
||||||
}
|
|
||||||
|
|
||||||
if not cust_loc_id:
|
|
||||||
res=get_model("stock.location").search([["type","=","customer"]])
|
|
||||||
if not res:
|
|
||||||
raise Exception("Customer location not found")
|
|
||||||
cust_loc_id=res[0]
|
|
||||||
|
|
||||||
prod=obj.product_id
|
|
||||||
if not wh_loc_id:
|
|
||||||
wh_loc_id=prod.location_id.id # product -> tab inventory -> warehouse filed
|
|
||||||
if not wh_loc_id:
|
|
||||||
res=get_model("stock.location").search([["type","=","internal"]])
|
|
||||||
if not res:
|
if not res:
|
||||||
raise Exception("Warehouse not found")
|
raise Exception("Customer location not found")
|
||||||
wh_loc_id=res[0]
|
cust_loc_id=res[0]
|
||||||
|
|
||||||
|
prod=obj.product_id
|
||||||
|
if not wh_loc_id:
|
||||||
|
wh_loc_id=prod.location_id.id # product -> tab inventory -> warehouse filed
|
||||||
|
if not wh_loc_id:
|
||||||
|
res=get_model("stock.location").search([["type","=","internal"]])
|
||||||
|
if not res:
|
||||||
|
raise Exception("Warehouse not found")
|
||||||
|
wh_loc_id=res[0]
|
||||||
|
|
||||||
|
if prod.type=='stock':
|
||||||
|
line_vals={
|
||||||
|
"product_id": prod.id,
|
||||||
|
"qty": 1,
|
||||||
|
"uom_id": prod.uom_id.id,
|
||||||
|
"location_from_id": wh_loc_id,
|
||||||
|
"location_to_id": cust_loc_id,
|
||||||
|
}
|
||||||
|
pick_vals["lines"].append(("create",line_vals))
|
||||||
|
picking_obj=get_model("stock.picking")
|
||||||
|
context={
|
||||||
|
'pick_type': 'out',
|
||||||
|
'journal_id': pick_vals['journal_id'],
|
||||||
|
}
|
||||||
|
pick_id=picking_obj.create(pick_vals,context=context)
|
||||||
|
pick=picking_obj.browse(pick_id)
|
||||||
|
pick.set_done([pick_id])
|
||||||
|
|
||||||
if prod.type=='stock':
|
|
||||||
line_vals={
|
|
||||||
"product_id": prod.id,
|
|
||||||
"qty": 1,
|
|
||||||
"uom_id": prod.uom_id.id,
|
|
||||||
"location_from_id": wh_loc_id,
|
|
||||||
"location_to_id": cust_loc_id,
|
|
||||||
}
|
|
||||||
pick_vals["lines"].append(("create",line_vals))
|
|
||||||
picking_obj=get_model("stock.picking")
|
|
||||||
context={
|
|
||||||
'pick_type': 'out',
|
|
||||||
'journal_id': pick_vals['journal_id'],
|
|
||||||
}
|
|
||||||
pick_id=picking_obj.create(pick_vals,context=context)
|
|
||||||
pick=picking_obj.browse(pick_id)
|
|
||||||
pick.set_done([pick_id])
|
|
||||||
number=obj.number.replace("/","")
|
number=obj.number.replace("/","")
|
||||||
if not number:
|
if not number:
|
||||||
department=obj.department_id
|
department=obj.department_id
|
||||||
|
|
|
@ -288,7 +288,7 @@ class HDCase(Model):
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
while 1:
|
while 1:
|
||||||
seq_id=get_model("sequence").find_sequence(type="clinic_hdcase")
|
seq_id=get_model("sequence").find_sequence(type="clinic_hdcase",context=context)
|
||||||
num=get_model("sequence").get_next_number(seq_id,context=context)
|
num=get_model("sequence").get_next_number(seq_id,context=context)
|
||||||
if not num:
|
if not num:
|
||||||
return None
|
return None
|
||||||
|
@ -319,7 +319,8 @@ class HDCase(Model):
|
||||||
"date": lambda *a: time.strftime("%Y-%m-%d"),
|
"date": lambda *a: time.strftime("%Y-%m-%d"),
|
||||||
"time_start": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
"time_start": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
"time_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
"time_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
'number': '/',
|
#'number': '/',
|
||||||
|
'number': _get_number,
|
||||||
"company_id": lambda *a: get_active_company(),
|
"company_id": lambda *a: get_active_company(),
|
||||||
'hd_acc': 'o',
|
'hd_acc': 'o',
|
||||||
'hd_mode': 'chronic',
|
'hd_mode': 'chronic',
|
||||||
|
@ -757,11 +758,12 @@ class HDCase(Model):
|
||||||
})
|
})
|
||||||
|
|
||||||
def make_pickings(self,ids,context={}):
|
def make_pickings(self,ids,context={}):
|
||||||
|
st=get_model('clinic.setting').browse(1)
|
||||||
|
if not st.hdcase_picking_auto:
|
||||||
|
return
|
||||||
obj=self.browse(ids[0])
|
obj=self.browse(ids[0])
|
||||||
# no picking
|
|
||||||
if not obj.lines:
|
if not obj.lines:
|
||||||
return
|
return
|
||||||
|
|
||||||
patient=obj.patient_id
|
patient=obj.patient_id
|
||||||
partner=patient.partner_id
|
partner=patient.partner_id
|
||||||
if not partner:
|
if not partner:
|
||||||
|
@ -773,7 +775,6 @@ class HDCase(Model):
|
||||||
break
|
break
|
||||||
if not ship_address_id:
|
if not ship_address_id:
|
||||||
patient.simple_address()
|
patient.simple_address()
|
||||||
#raise Exception("contact %s dont'have address with type shipping"%partner.name)
|
|
||||||
# default journal
|
# default journal
|
||||||
cust_loc_id=None
|
cust_loc_id=None
|
||||||
wh_loc_id=None
|
wh_loc_id=None
|
||||||
|
@ -785,7 +786,6 @@ class HDCase(Model):
|
||||||
if stock_journal:
|
if stock_journal:
|
||||||
wh_loc_id=stock_journal.location_from_id.id
|
wh_loc_id=stock_journal.location_from_id.id
|
||||||
cust_loc_id=stock_journal.location_to_id.id
|
cust_loc_id=stock_journal.location_to_id.id
|
||||||
print("get location from stock journal %s "%(stock_journal.name))
|
|
||||||
pick_vals={
|
pick_vals={
|
||||||
"type": "out",
|
"type": "out",
|
||||||
'journal_id': stock_journal.id,
|
'journal_id': stock_journal.id,
|
||||||
|
@ -802,8 +802,6 @@ class HDCase(Model):
|
||||||
if not res:
|
if not res:
|
||||||
raise Exception("Customer location not found")
|
raise Exception("Customer location not found")
|
||||||
cust_loc_id=res[0]
|
cust_loc_id=res[0]
|
||||||
|
|
||||||
#XXX
|
|
||||||
no_lines=context.get('no_line') or False
|
no_lines=context.get('no_line') or False
|
||||||
if no_lines:
|
if no_lines:
|
||||||
return
|
return
|
||||||
|
@ -817,24 +815,26 @@ class HDCase(Model):
|
||||||
prod=line.product_id
|
prod=line.product_id
|
||||||
if prod.type != 'stock':
|
if prod.type != 'stock':
|
||||||
continue
|
continue
|
||||||
|
if not st.dlz_picking_auto and prod.categ_id.code=='DLZ':
|
||||||
|
continue
|
||||||
# check orginal product
|
# check orginal product
|
||||||
prod_code=prod.code.split("-")[0]
|
prod_code=prod.code.split("-")[0]
|
||||||
if patient.type_id.main_product:
|
if patient.type_id.main_product:
|
||||||
if len(prod_code)>1:
|
if len(prod_code)>1:
|
||||||
prods=get_model('product').search_browse(['code','=',prod_code])
|
prods=get_model('product').search_browse(['code','=',prod_code])
|
||||||
if not prods:
|
if not context.get('migrate'):
|
||||||
raise Exception("Can not create good issue: product code %s is not found!"%prod_code)
|
if not prods:
|
||||||
prod=prods[0]
|
raise Exception("Can not create goods issue: product code %s is not found!"%prod_code)
|
||||||
|
prod=prods[0]
|
||||||
|
else:
|
||||||
|
continue
|
||||||
if prod_ids and prod.id not in prod_ids or prod.id in prod_exist_ids:
|
if prod_ids and prod.id not in prod_ids or prod.id in prod_exist_ids:
|
||||||
continue
|
continue
|
||||||
prod_exist_ids.append(prod.id)
|
prod_exist_ids.append(prod.id)
|
||||||
#XXX
|
|
||||||
dpt_prods=get_model('clinic.department.product').get_location(obj.department_id.id,prod.id)
|
dpt_prods=get_model('clinic.department.product').get_location(obj.department_id.id,prod.id)
|
||||||
if dpt_prods:
|
if dpt_prods:
|
||||||
print("get location from menu department products")
|
|
||||||
wh_loc_id=dpt_prods.get('wh_loc_id')
|
wh_loc_id=dpt_prods.get('wh_loc_id')
|
||||||
cust_loc_id=dpt_prods.get('cust_loc_id')
|
cust_loc_id=dpt_prods.get('cust_loc_id')
|
||||||
#pick_vals['journal_id']=dpt_prods.get('journal_id')
|
|
||||||
if not wh_loc_id:
|
if not wh_loc_id:
|
||||||
wh_loc_id=prod.location_id.id
|
wh_loc_id=prod.location_id.id
|
||||||
if wh_loc_id:
|
if wh_loc_id:
|
||||||
|
@ -915,9 +915,6 @@ class HDCase(Model):
|
||||||
use_time=dlz_line.use_time or 0
|
use_time=dlz_line.use_time or 0
|
||||||
max_use_time=dlz_line.max_use_time or 0
|
max_use_time=dlz_line.max_use_time or 0
|
||||||
desc=dlz_line.description or ''
|
desc=dlz_line.description or ''
|
||||||
#TODO when we to draft after approve hdcase it will update the wrong use time
|
|
||||||
#if use_time > (dlz.use_time or 0):
|
|
||||||
#continue
|
|
||||||
if is_decrease:
|
if is_decrease:
|
||||||
use_time-=1
|
use_time-=1
|
||||||
vals={
|
vals={
|
||||||
|
@ -958,7 +955,7 @@ class HDCase(Model):
|
||||||
cycle_item_ids=cycle_item.search(dom)
|
cycle_item_ids=cycle_item.search(dom)
|
||||||
cycle_item_id=None
|
cycle_item_id=None
|
||||||
if cycle_item_ids:
|
if cycle_item_ids:
|
||||||
cycle_item_id=cycle_item_ids[0]
|
cycle_item_id=cycle_item_ids[-1]
|
||||||
else:
|
else:
|
||||||
cycle_item_id=cycle_item.create({
|
cycle_item_id=cycle_item.create({
|
||||||
'date': obj.date,
|
'date': obj.date,
|
||||||
|
@ -1014,7 +1011,6 @@ class HDCase(Model):
|
||||||
obj.make_invoices(context=context)
|
obj.make_invoices(context=context)
|
||||||
obj.post_invoices(context=context)
|
obj.post_invoices(context=context)
|
||||||
obj.create_cycle_item()
|
obj.create_cycle_item()
|
||||||
#obj.do_expense(context=context)
|
|
||||||
vals={
|
vals={
|
||||||
"state":"waiting_payment", # for government
|
"state":"waiting_payment", # for government
|
||||||
}
|
}
|
||||||
|
@ -1024,6 +1020,7 @@ class HDCase(Model):
|
||||||
date=obj.date
|
date=obj.date
|
||||||
vals['time_stop']='%s %s'%(date,timenow)
|
vals['time_stop']='%s %s'%(date,timenow)
|
||||||
obj.write(vals)
|
obj.write(vals)
|
||||||
|
obj.recompute_labor_cost()
|
||||||
if context.get("called"):
|
if context.get("called"):
|
||||||
return obj.id
|
return obj.id
|
||||||
return {
|
return {
|
||||||
|
@ -1060,8 +1057,10 @@ class HDCase(Model):
|
||||||
def undo(self,ids,context={}):
|
def undo(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
context['is_decrease']=True
|
context['is_decrease']=True
|
||||||
# in case to draft
|
# should not reset use time if not the day of treatment is not today
|
||||||
obj.update_usetime(context=context)
|
datenow=time.strftime("%Y-%m-%d")
|
||||||
|
if obj.date==datenow:
|
||||||
|
obj.update_usetime(context=context)
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
line.write({
|
line.write({
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
|
@ -1084,7 +1083,7 @@ class HDCase(Model):
|
||||||
payment.delete()
|
payment.delete()
|
||||||
for pm_line in obj.payment_lines:
|
for pm_line in obj.payment_lines:
|
||||||
pm_line.delete()
|
pm_line.delete()
|
||||||
|
#XXX remove
|
||||||
for exp in obj.expenes:
|
for exp in obj.expenes:
|
||||||
exp.delete()
|
exp.delete()
|
||||||
|
|
||||||
|
@ -1097,7 +1096,7 @@ class HDCase(Model):
|
||||||
obj.sickbed_id.write({
|
obj.sickbed_id.write({
|
||||||
'available': False,
|
'available': False,
|
||||||
})
|
})
|
||||||
|
obj.recompute_labor_cost()
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
'name': 'clinic_hd_case',
|
'name': 'clinic_hd_case',
|
||||||
|
@ -1107,6 +1106,15 @@ class HDCase(Model):
|
||||||
'flash': '%s has been undo'%obj.number,
|
'flash': '%s has been undo'%obj.number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def recompute_labor_cost(self,ids,context={}):
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
cit=obj.cycle_item_id
|
||||||
|
# recompute labor cost
|
||||||
|
if cit.state=='validated':
|
||||||
|
for lc in get_model("clinic.labor.cost").search_browse([['cycle_item_id','=',cit.id]]):
|
||||||
|
lc.compute()
|
||||||
|
|
||||||
|
|
||||||
def view_payment(self,ids,context={}):
|
def view_payment(self,ids,context={}):
|
||||||
print("clinic_view_payment")
|
print("clinic_view_payment")
|
||||||
return {
|
return {
|
||||||
|
@ -1306,7 +1314,20 @@ class HDCase(Model):
|
||||||
}
|
}
|
||||||
|
|
||||||
def new_dialyzer(self,ids,context={}):
|
def new_dialyzer(self,ids,context={}):
|
||||||
|
'''
|
||||||
|
drop old one and create new dlz
|
||||||
|
'''
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
if context.get('drop_old'):
|
||||||
|
for dlz_line in obj.dialyzers:
|
||||||
|
dlz=dlz_line.dialyzer_id
|
||||||
|
dlz_line.write({
|
||||||
|
'use_time': dlz.use_time,
|
||||||
|
})
|
||||||
|
dlz.write({
|
||||||
|
'state': 'drop',
|
||||||
|
})
|
||||||
|
|
||||||
is_wiz=context.get("is_wiz")
|
is_wiz=context.get("is_wiz")
|
||||||
dlz_vals={}
|
dlz_vals={}
|
||||||
if is_wiz:
|
if is_wiz:
|
||||||
|
@ -1500,7 +1521,7 @@ class HDCase(Model):
|
||||||
#break
|
#break
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
def create(self,vals,**kw):
|
def create(self,vals,context):
|
||||||
patient_id=vals['patient_id']
|
patient_id=vals['patient_id']
|
||||||
if 'vascular_acc' in vals.keys():
|
if 'vascular_acc' in vals.keys():
|
||||||
patient=get_model("clinic.patient").browse(patient_id)
|
patient=get_model("clinic.patient").browse(patient_id)
|
||||||
|
@ -1509,7 +1530,7 @@ class HDCase(Model):
|
||||||
})
|
})
|
||||||
vals=self.get_staff_line(vals,patient_id)
|
vals=self.get_staff_line(vals,patient_id)
|
||||||
vals=self.get_hct(vals,patient_id)
|
vals=self.get_hct(vals,patient_id)
|
||||||
new_id=super().create(vals,**kw)
|
new_id=super().create(vals,context=context)
|
||||||
self.function_store([new_id])
|
self.function_store([new_id])
|
||||||
return new_id
|
return new_id
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,13 @@ class HDCaseDialyzerLine(Model):
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _get_dlz_state(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
dlz=obj.dialyzer_id
|
||||||
|
res[obj.id]=dlz.state
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"hd_case_id": fields.Many2One("clinic.hd.case","HDCase",on_delete="cascade"),
|
"hd_case_id": fields.Many2One("clinic.hd.case","HDCase",on_delete="cascade"),
|
||||||
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
|
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
|
||||||
|
@ -24,7 +31,8 @@ class HDCaseDialyzerLine(Model):
|
||||||
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
|
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
|
||||||
'hdcase_date': fields.Date('Date', function="_get_all",function_multi=True),
|
'hdcase_date': fields.Date('Date', function="_get_all",function_multi=True),
|
||||||
"hdcase_state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),("completed","Finish Treatment"),('paid','Paid'),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True,function="_get_all",function_multi=True),
|
"hdcase_state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),("completed","Finish Treatment"),('paid','Paid'),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True,function="_get_all",function_multi=True),
|
||||||
'nurse_id': fields.Many2One('clinic.staff', 'Nurse',function="_get_all",function_multi=True),
|
'nurse_id': fields.Many2One('clinic.staff', 'Use by',function="_get_all",function_multi=True),
|
||||||
|
"state": fields.Selection([("new","New"),("active","Active"),("drop","Drop"),("expire","Expire"),('cancelled','Cancelled')],"Status",function="_get_dlz_state"),
|
||||||
}
|
}
|
||||||
|
|
||||||
_order="hd_case_id.date desc"
|
_order="hd_case_id.date desc"
|
||||||
|
|
|
@ -65,6 +65,7 @@ class HDCasePayment(Model):
|
||||||
obj.write({
|
obj.write({
|
||||||
'pay_amount': hd_case.amount,
|
'pay_amount': hd_case.amount,
|
||||||
})
|
})
|
||||||
|
hd_case.recompute_labor_cost()
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
'name': 'clinic_hd_case',
|
'name': 'clinic_hd_case',
|
||||||
|
@ -85,6 +86,7 @@ class HDCasePayment(Model):
|
||||||
'state': 'waiting_payment',
|
'state': 'waiting_payment',
|
||||||
'req_fee': 0, # force to hide button pay!
|
'req_fee': 0, # force to hide button pay!
|
||||||
})
|
})
|
||||||
|
hd_case.recompute_labor_cost()
|
||||||
inv_number=[]
|
inv_number=[]
|
||||||
for inv in hd_case.invoices:
|
for inv in hd_case.invoices:
|
||||||
inv_number.append(inv.number or "")
|
inv_number.append(inv.number or "")
|
||||||
|
|
|
@ -12,6 +12,7 @@ class HDCasePopupDlz(Model):
|
||||||
"exp_date": fields.Date("Expiry Date"),
|
"exp_date": fields.Date("Expiry Date"),
|
||||||
"note": fields.Text("Note"),
|
"note": fields.Text("Note"),
|
||||||
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
|
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
|
||||||
|
'drop_old': fields.Boolean("Drop Old Dialyzer"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __get_hd_case_id(self,context={}):
|
def __get_hd_case_id(self,context={}):
|
||||||
|
@ -45,6 +46,7 @@ class HDCasePopupDlz(Model):
|
||||||
'membrane_type': membrane_type,
|
'membrane_type': membrane_type,
|
||||||
'max_use_time': max_use_time,
|
'max_use_time': max_use_time,
|
||||||
'product_id': product_id,
|
'product_id': product_id,
|
||||||
|
'drop_old': True,
|
||||||
}
|
}
|
||||||
print('res', res)
|
print('res', res)
|
||||||
return res
|
return res
|
||||||
|
@ -56,6 +58,7 @@ class HDCasePopupDlz(Model):
|
||||||
if hd_case:
|
if hd_case:
|
||||||
context['is_wiz']=True
|
context['is_wiz']=True
|
||||||
context['pop_id']=obj.id
|
context['pop_id']=obj.id
|
||||||
|
context['drop_old']=obj.drop_old
|
||||||
res=hd_case.new_dialyzer(context=context)
|
res=hd_case.new_dialyzer(context=context)
|
||||||
print('res ', res)
|
print('res ', res)
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -140,7 +140,8 @@ class LaborCost(Model):
|
||||||
|
|
||||||
for line in item.lines:
|
for line in item.lines:
|
||||||
nurse=line.nurse_id
|
nurse=line.nurse_id
|
||||||
level=line.level_id or nurse.level_id
|
#level=line.level_id or nurse.level_id
|
||||||
|
level=nurse.level_id
|
||||||
if not level:
|
if not level:
|
||||||
raise Exception("Please specify level %s for %s"%(nurse.name,item.name))
|
raise Exception("Please specify level %s for %s"%(nurse.name,item.name))
|
||||||
levels[level.id]['total']+=1
|
levels[level.id]['total']+=1
|
||||||
|
@ -281,7 +282,10 @@ class LaborCost(Model):
|
||||||
# cost's nurses
|
# cost's nurses
|
||||||
for line in item.lines:
|
for line in item.lines:
|
||||||
nurse=line.nurse_id
|
nurse=line.nurse_id
|
||||||
level=line.level_id or nurse.level_id
|
#level=line.level_id or nurse.level_id
|
||||||
|
level=nurse.level_id
|
||||||
|
if not level:
|
||||||
|
raise Exception("Please specify level for %s"%nurse.name)
|
||||||
vals=levels.get(level.id)
|
vals=levels.get(level.id)
|
||||||
rate,amt,qty=0.0,0.0,0
|
rate,amt,qty=0.0,0.0,0
|
||||||
level_id=level.id
|
level_id=level.id
|
||||||
|
|
|
@ -175,7 +175,6 @@ class Patient(Model):
|
||||||
"vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."),
|
"vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."),
|
||||||
'state': fields.Selection([['admit','Admit'],['dispose','Dispose']],'State'),
|
'state': fields.Selection([['admit','Admit'],['dispose','Dispose']],'State'),
|
||||||
'walkin': fields.Selection([['yes','Yes'],['no','No']],"Walkin"),
|
'walkin': fields.Selection([['yes','Yes'],['no','No']],"Walkin"),
|
||||||
#'department_names': fields.Text("Departments",function="_get_department_names"),
|
|
||||||
'location': fields.Char("Location"), #to filter
|
'location': fields.Char("Location"), #to filter
|
||||||
'cw_time': fields.DateTime("Cycle Updated"),
|
'cw_time': fields.DateTime("Cycle Updated"),
|
||||||
'cw_uid': fields.Many2One("base.user"," Cycle Edit"),
|
'cw_uid': fields.Many2One("base.user"," Cycle Edit"),
|
||||||
|
@ -376,6 +375,7 @@ class Patient(Model):
|
||||||
else:
|
else:
|
||||||
vals['state']='admit'
|
vals['state']='admit'
|
||||||
vals['rm_remain_visit']=False
|
vals['rm_remain_visit']=False
|
||||||
|
vals['resign_date']=None
|
||||||
ctx={}
|
ctx={}
|
||||||
if 'active' in vals.keys():
|
if 'active' in vals.keys():
|
||||||
if not vals['active']:
|
if not vals['active']:
|
||||||
|
|
|
@ -301,10 +301,10 @@ class PaymentMatching(Model):
|
||||||
pc=0
|
pc=0
|
||||||
if total_invoice:
|
if total_invoice:
|
||||||
pc=(total_match_invoice/total_invoice)*100
|
pc=(total_match_invoice/total_invoice)*100
|
||||||
if inv_match_ids and obj:
|
#if inv_match_ids and obj:
|
||||||
obj.write({
|
#obj.write({
|
||||||
'inv_ids': str(inv_match_ids),
|
#'inv_ids': str(inv_match_ids),
|
||||||
})
|
#})
|
||||||
data={
|
data={
|
||||||
'lines': lines,
|
'lines': lines,
|
||||||
'date_from': date_from,
|
'date_from': date_from,
|
||||||
|
|
|
@ -5,14 +5,31 @@ from calendar import monthrange
|
||||||
|
|
||||||
from netforce.model import Model,fields,get_model
|
from netforce.model import Model,fields,get_model
|
||||||
from netforce.database import get_active_db, get_connection
|
from netforce.database import get_active_db, get_connection
|
||||||
from netforce.access import get_active_user
|
from netforce.access import get_active_user, get_active_company
|
||||||
import netforce.config as config
|
import netforce.config as config
|
||||||
|
|
||||||
class PrintLaborCost(Model):
|
class PrintLaborCost(Model):
|
||||||
_name="clinic.print.labor.cost"
|
_name="clinic.print.labor.cost"
|
||||||
_string="Print Report Labor Cost"
|
_string="Report Labor Cost"
|
||||||
|
|
||||||
|
def _get_name(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
year_frm,month_frm,day_frm=obj.date_from.split("-")
|
||||||
|
year_to,month_to,day_to=obj.date_to.split("-")
|
||||||
|
name=''.join([year_frm,month_frm,day_frm,month_to,day_to])
|
||||||
|
if obj.cycle_id:
|
||||||
|
name+=obj.cycle_id.name
|
||||||
|
if obj.branch_id:
|
||||||
|
name+=obj.branch_id.name
|
||||||
|
if obj.department_id:
|
||||||
|
name+=obj.department_id.name
|
||||||
|
name+='-'+obj.staff_type
|
||||||
|
res[obj.id]=name
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
|
"name": fields.Char("Name",function="_get_name"),
|
||||||
"date": fields.Date("Month"),
|
"date": fields.Date("Month"),
|
||||||
"period_id": fields.Many2One("clinic.period.line","Period"),
|
"period_id": fields.Many2One("clinic.period.line","Period"),
|
||||||
"date_from": fields.Date("From", required=True),
|
"date_from": fields.Date("From", required=True),
|
||||||
|
@ -31,9 +48,46 @@ class PrintLaborCost(Model):
|
||||||
'ot_report_id': fields.Many2One("clinic.report.labor.cost.overtime","Overtime Report"),
|
'ot_report_id': fields.Many2One("clinic.report.labor.cost.overtime","Overtime Report"),
|
||||||
'report_summary': fields.File("Summary"),
|
'report_summary': fields.File("Summary"),
|
||||||
'report_labor_cost': fields.File("Labor Cost"),
|
'report_labor_cost': fields.File("Labor Cost"),
|
||||||
|
'state': fields.Selection([['draft','Draft'],['waiting_doc','Waiting Document'],['done','Done']],'State'),
|
||||||
|
'company_id': fields.Many2One('company','Company'),
|
||||||
|
'zip_file': fields.File("File"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def reload(self,ids,context={}):
|
def _get_date_from(self,context={}):
|
||||||
|
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
||||||
|
#return '%s-%s-01'%(year,month)
|
||||||
|
return '%s-%s-%s'%(year,month,day)
|
||||||
|
|
||||||
|
def _get_date_to(self,context={}):
|
||||||
|
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
||||||
|
weekday, total_day=monthrange(int(year), int(month))
|
||||||
|
#return "%s-%s-%s"%(year,month,total_day)
|
||||||
|
return "%s-%s-%s"%(year,month,day)
|
||||||
|
|
||||||
|
def default_get(self,field_names=None,context={},**kw):
|
||||||
|
defaults=context.get("defaults",{})
|
||||||
|
date_from=defaults.get("date_from", self._get_date_from())
|
||||||
|
date_to=defaults.get("date_to", self._get_date_to())
|
||||||
|
print('defaults ', defaults)
|
||||||
|
yearnow=date_from.split("-")[0]
|
||||||
|
for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
|
||||||
|
for line in period.lines:
|
||||||
|
if line.state=='open':
|
||||||
|
period_id=line.id
|
||||||
|
date_from=line.date_start
|
||||||
|
date_to=line.date_stop
|
||||||
|
break
|
||||||
|
res={
|
||||||
|
'period_id': period_id,
|
||||||
|
'date': time.strftime("%Y-%m-%d"),
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to,
|
||||||
|
'state': 'draft',
|
||||||
|
'company_id': get_active_company(),
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
|
def reset_data(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
context['defaults']={
|
context['defaults']={
|
||||||
'date_from': obj.date_from,
|
'date_from': obj.date_from,
|
||||||
|
@ -66,32 +120,26 @@ class PrintLaborCost(Model):
|
||||||
})
|
})
|
||||||
|
|
||||||
def do_generate(self,ids,context={}):
|
def do_generate(self,ids,context={}):
|
||||||
dom=[
|
self.trigger(ids,"do_gen")
|
||||||
['model', '=','clinic.print.labor.cost'],
|
|
||||||
['method','=','generate_report'],
|
def wkf_gen_report(self,context={},**kw):
|
||||||
]
|
print("#"*80)
|
||||||
for cj in get_model('cron.job').search_browse(dom):
|
trigger_ids=context.get("trigger_ids")
|
||||||
cj.write({
|
if not trigger_ids:
|
||||||
'state': 'waiting',
|
raise Exception("Missing trigger ids")
|
||||||
})
|
print("trigger_ids",trigger_ids)
|
||||||
vals={
|
self.generate_report(trigger_ids,context,**kw)
|
||||||
'to_id': get_active_user(),
|
|
||||||
'subject': 'Generate Report',
|
|
||||||
'body': """
|
|
||||||
Please wait until report is generated.
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
get_model("message").create(vals)
|
|
||||||
return {
|
|
||||||
'next': {
|
|
||||||
'type': 'reload',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def generate_report(self,ids,context={}):
|
def generate_report(self,ids,context={}):
|
||||||
|
db=get_connection()
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
obj.write({
|
||||||
|
'state': 'waiting_doc',
|
||||||
|
'zip_file': None,
|
||||||
|
})
|
||||||
|
db.commit()
|
||||||
# clear and reload
|
# clear and reload
|
||||||
obj.reload()
|
obj.reset_data()
|
||||||
def load_report(fname,link):
|
def load_report(fname,link):
|
||||||
host=config.config['host']
|
host=config.config['host']
|
||||||
port=config.config['port']
|
port=config.config['port']
|
||||||
|
@ -100,11 +148,15 @@ class PrintLaborCost(Model):
|
||||||
req=urllib.request.Request(link)
|
req=urllib.request.Request(link)
|
||||||
response=urllib.request.urlopen(req)
|
response=urllib.request.urlopen(req)
|
||||||
data=response.read()
|
data=response.read()
|
||||||
dbname=get_active_db()
|
fpath=os.path.join('/tmp/labor_cost',fname)
|
||||||
fdir=os.path.join("static","db",dbname,"files")
|
open(fpath,"wb").write(data)
|
||||||
open(os.path.join(fdir,fname),"wb").write(data)
|
|
||||||
|
dbname=get_active_db()
|
||||||
|
fdir=os.path.join("static","db",dbname,"files")
|
||||||
|
tmp_dir='/tmp/labor_cost'
|
||||||
|
if not os.path.isdir(tmp_dir):
|
||||||
|
os.system("mkdir %s"%(tmp_dir))
|
||||||
|
|
||||||
db=get_connection()
|
|
||||||
sum_id=obj.sum_report_id.id
|
sum_id=obj.sum_report_id.id
|
||||||
if not sum_id:
|
if not sum_id:
|
||||||
sum_id=get_model('clinic.report.labor.cost.summary').create({
|
sum_id=get_model('clinic.report.labor.cost.summary').create({
|
||||||
|
@ -182,15 +234,14 @@ class PrintLaborCost(Model):
|
||||||
report_lines=[
|
report_lines=[
|
||||||
{'report_file': 'report_detail','model': 'clinic.report.labor.cost.detail', 'report_id': obj.dt_report_id.id,'field_name': 'dt_report_id'},
|
{'report_file': 'report_detail','model': 'clinic.report.labor.cost.detail', 'report_id': obj.dt_report_id.id,'field_name': 'dt_report_id'},
|
||||||
{'report_file': 'report_sub_detail','model': 'clinic.report.labor.cost.sub.detail', 'report_id': obj.sub_dt_report_id.id,'field_name': 'sub_dt_report_id'},
|
{'report_file': 'report_sub_detail','model': 'clinic.report.labor.cost.sub.detail', 'report_id': obj.sub_dt_report_id.id,'field_name': 'sub_dt_report_id'},
|
||||||
#{'report_file': 'report_daily','model': 'clinic.report.labor.cost.daily', 'report_id': obj.dl_report_id.id,'field_name': 'dl_report_id'},
|
|
||||||
#{'report_file': 'report_ot','model': 'clinic.report.labor.cost.overtime', 'report_id': obj.ot_report_id.id,'field_name': 'ot_report_id'},
|
|
||||||
]
|
]
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
staff=line.staff_id
|
staff=line.staff_id
|
||||||
for report_line in report_lines:
|
for report_line in report_lines:
|
||||||
name=staff.number or staff.name or staff.id
|
name='%s-%s'%(staff.first_name,staff.number)
|
||||||
|
name=name.replace(" ","-")
|
||||||
fname='%s-%s.xlsx'%(name,report_line['report_file'])
|
fname='%s-%s.xlsx'%(name,report_line['report_file'])
|
||||||
report_file=report_line['report_file']
|
print('fname ---> ', fname)
|
||||||
report_model=report_line['model']
|
report_model=report_line['model']
|
||||||
report_template=report_model.replace(".","_").replace("clinic_","")
|
report_template=report_model.replace(".","_").replace("clinic_","")
|
||||||
report_id=report_line['report_id']
|
report_id=report_line['report_id']
|
||||||
|
@ -227,53 +278,36 @@ class PrintLaborCost(Model):
|
||||||
db.commit()
|
db.commit()
|
||||||
link='report_export_xls?model=%s&template=%s&active_id=%s'%(report_model,report_template,report_obj.id)
|
link='report_export_xls?model=%s&template=%s&active_id=%s'%(report_model,report_template,report_obj.id)
|
||||||
load_report(fname,link)
|
load_report(fname,link)
|
||||||
line.write({
|
|
||||||
report_file: fname,
|
|
||||||
})
|
|
||||||
db.commit()
|
db.commit()
|
||||||
print("Done!")
|
|
||||||
|
os.system("cp -rf %s ."%tmp_dir)
|
||||||
|
|
||||||
|
os.system("cp merge.py labor_cost/")
|
||||||
|
os.system("python labor_cost/merge.py labor_cost %s"%(obj.name))
|
||||||
|
os.system("rm labor_cost/*.py")
|
||||||
|
os.system("rm labor_cost/*.xlsx")
|
||||||
|
|
||||||
|
os.system("mv labor_cost %s"%obj.name)
|
||||||
|
os.system("zip %s.zip %s/*"%(obj.name,obj.name))
|
||||||
|
os.system("mv %s.zip %s/"%(obj.name,fdir))
|
||||||
|
os.system("rm -r %s*"%(obj.name))
|
||||||
|
os.system("rm %s/*"%tmp_dir)
|
||||||
|
|
||||||
|
obj.write({
|
||||||
|
'zip_file': '%s.zip'%obj.name,
|
||||||
|
'state': 'done',
|
||||||
|
})
|
||||||
|
|
||||||
vals={
|
vals={
|
||||||
'to_id': get_active_user(),
|
'to_id': get_active_user(),
|
||||||
'subject': 'Generate Report',
|
'subject': 'Generate Report',
|
||||||
'body': """
|
'body': """
|
||||||
Finish to generate report.
|
Generate labor cost report for successfully.
|
||||||
""",
|
""",
|
||||||
}
|
}
|
||||||
get_model("message").create(vals)
|
get_model("message").create(vals)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
def _get_date_from(self,context={}):
|
|
||||||
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
|
||||||
#return '%s-%s-01'%(year,month)
|
|
||||||
return '%s-%s-%s'%(year,month,day)
|
|
||||||
|
|
||||||
def _get_date_to(self,context={}):
|
|
||||||
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
|
||||||
weekday, total_day=monthrange(int(year), int(month))
|
|
||||||
#return "%s-%s-%s"%(year,month,total_day)
|
|
||||||
return "%s-%s-%s"%(year,month,day)
|
|
||||||
|
|
||||||
def default_get(self,field_names=None,context={},**kw):
|
|
||||||
defaults=context.get("defaults",{})
|
|
||||||
date_from=defaults.get("date_from", self._get_date_from())
|
|
||||||
date_to=defaults.get("date_to", self._get_date_to())
|
|
||||||
print('defaults ', defaults)
|
|
||||||
yearnow=date_from.split("-")[0]
|
|
||||||
for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
|
|
||||||
for line in period.lines:
|
|
||||||
if line.state=='open':
|
|
||||||
period_id=line.id
|
|
||||||
date_from=line.date_start
|
|
||||||
date_to=line.date_stop
|
|
||||||
break
|
|
||||||
res={
|
|
||||||
'period_id': period_id,
|
|
||||||
'date': time.strftime("%Y-%m-%d"),
|
|
||||||
'date_from': date_from,
|
|
||||||
'date_to': date_to,
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
|
|
||||||
def onchange_date(self,context={}):
|
def onchange_date(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
date=data['date']
|
date=data['date']
|
||||||
|
|
|
@ -216,8 +216,13 @@ class ReportAccountHDCaseSummary(Model):
|
||||||
records[hdcase_id]['misc']+=amt
|
records[hdcase_id]['misc']+=amt
|
||||||
else:
|
else:
|
||||||
records[hdcase_id]['misc']+=amt
|
records[hdcase_id]['misc']+=amt
|
||||||
lines=[]
|
|
||||||
|
|
||||||
|
#print('merge product categ of ivr, fine and dlz to misc')
|
||||||
|
records[hdcase_id]['misc']+=records[hdcase_id]['ivr']
|
||||||
|
records[hdcase_id]['misc']+=records[hdcase_id]['fine']
|
||||||
|
records[hdcase_id]['misc']+=records[hdcase_id]['dlz']
|
||||||
|
|
||||||
|
lines=[]
|
||||||
# nurse would like to see only receipt
|
# nurse would like to see only receipt
|
||||||
del_invoice=False
|
del_invoice=False
|
||||||
del_receipt=False
|
del_receipt=False
|
||||||
|
|
|
@ -19,6 +19,7 @@ class ReportCycleItem(Model):
|
||||||
"ptype_id": fields.Many2One("clinic.patient.type","Patient Type"),
|
"ptype_id": fields.Many2One("clinic.patient.type","Patient Type"),
|
||||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||||
'department_id': fields.Many2One("clinic.department","Department"),
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
|
'sort_by': fields.Selection([['hdcase_number','HDCase Number'],['pname','Patient Name'],['mdc_name','EPO']],'Sort By'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def default_get(self,field_names=None,context={},**kw):
|
def default_get(self,field_names=None,context={},**kw):
|
||||||
|
@ -51,6 +52,7 @@ class ReportCycleItem(Model):
|
||||||
'branch_id': branch_id,
|
'branch_id': branch_id,
|
||||||
'department_id': department_id,
|
'department_id': department_id,
|
||||||
'ptype_id': ptype_id,
|
'ptype_id': ptype_id,
|
||||||
|
'sort_by': 'mdc_name',
|
||||||
}
|
}
|
||||||
print('report.cycle.item.defautls', res)
|
print('report.cycle.item.defautls', res)
|
||||||
return res
|
return res
|
||||||
|
@ -67,6 +69,7 @@ class ReportCycleItem(Model):
|
||||||
print('date_from ', date_from)
|
print('date_from ', date_from)
|
||||||
month=date_from.split("-")[1]
|
month=date_from.split("-")[1]
|
||||||
cycle_id=None
|
cycle_id=None
|
||||||
|
sort_by='mdc_name'
|
||||||
if ids:
|
if ids:
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
month=obj.date_from.split("-")[1]
|
month=obj.date_from.split("-")[1]
|
||||||
|
@ -76,6 +79,7 @@ class ReportCycleItem(Model):
|
||||||
department_id=obj.department_id.id
|
department_id=obj.department_id.id
|
||||||
cycle_id=obj.cycle_id.id
|
cycle_id=obj.cycle_id.id
|
||||||
ptype_id=obj.ptype_id.id
|
ptype_id=obj.ptype_id.id
|
||||||
|
sort_by=obj.sort_by or 'mdc_name'
|
||||||
# new patient of this month
|
# new patient of this month
|
||||||
dom=[]
|
dom=[]
|
||||||
dom.append(['date','>=',date_from])
|
dom.append(['date','>=',date_from])
|
||||||
|
@ -98,17 +102,20 @@ class ReportCycleItem(Model):
|
||||||
ptypes={}
|
ptypes={}
|
||||||
for ptype in get_model("clinic.patient.type").search_read([],['name']):
|
for ptype in get_model("clinic.patient.type").search_read([],['name']):
|
||||||
ptypes[ptype['name'] or ""]=0
|
ptypes[ptype['name'] or ""]=0
|
||||||
|
cycle_check={}
|
||||||
for citem in get_model('clinic.cycle.item').search_browse(dom,order="date"):
|
for citem in get_model('clinic.cycle.item').search_browse(dom,order="date"):
|
||||||
cycle=citem.cycle_id
|
cycle=citem.cycle_id
|
||||||
date=citem.date
|
date=citem.date
|
||||||
key='%s-%s'%(date,cycle.id)
|
key='%s-%s'%(date,cycle.id)
|
||||||
if key not in cycles.keys():
|
if key not in cycles.keys():
|
||||||
cycles[key]=[]
|
cycles[key]=[]
|
||||||
|
cycle_check[key]=0
|
||||||
for line in citem.lines:
|
for line in citem.lines:
|
||||||
nurse=line.nurse_id
|
nurse=line.nurse_id
|
||||||
cycles[key].append({
|
cycles[key].append({
|
||||||
'name': nurse.name,
|
'name': nurse.name,
|
||||||
'first_name': nurse.first_name or "",
|
'first_name': nurse.first_name or "",
|
||||||
|
'cycle_item_id': citem.id,
|
||||||
})
|
})
|
||||||
for hdcase in citem.hd_cases:
|
for hdcase in citem.hd_cases:
|
||||||
if hdcase.state not in ('paid', 'waiting_payment'):
|
if hdcase.state not in ('paid', 'waiting_payment'):
|
||||||
|
@ -120,6 +127,8 @@ class ReportCycleItem(Model):
|
||||||
ptype=patient.type_id
|
ptype=patient.type_id
|
||||||
if ptype_id and ptype_id!=ptype.id:
|
if ptype_id and ptype_id!=ptype.id:
|
||||||
continue
|
continue
|
||||||
|
key='%s-%s'%(hdcase.date,hdcase.cycle_id.id)
|
||||||
|
cycle_check[key]+=1
|
||||||
ptypes[ptype.name or ""]+=1
|
ptypes[ptype.name or ""]+=1
|
||||||
doctor=hdcase.doctor_id
|
doctor=hdcase.doctor_id
|
||||||
cycle=hdcase.cycle_id
|
cycle=hdcase.cycle_id
|
||||||
|
@ -165,7 +174,7 @@ class ReportCycleItem(Model):
|
||||||
'mdc': hdcase.mdc,
|
'mdc': hdcase.mdc,
|
||||||
'hdcase_number': reformat_number(hdcase.number),
|
'hdcase_number': reformat_number(hdcase.number),
|
||||||
'hdcase_id': hdcase.id,
|
'hdcase_id': hdcase.id,
|
||||||
'mdc_name': hdcase.mdc_name or hdcase.epo,
|
'mdc_name': hdcase.mdc_name or hdcase.epo or '',
|
||||||
'iron_name': hdcase.iron_name or '',
|
'iron_name': hdcase.iron_name or '',
|
||||||
'fee': abs(hdcase.fee),
|
'fee': abs(hdcase.fee),
|
||||||
'dlz_name': hdcase.dlz_name,
|
'dlz_name': hdcase.dlz_name,
|
||||||
|
@ -194,6 +203,7 @@ class ReportCycleItem(Model):
|
||||||
branch=get_model("clinic.branch").browse(branch_id)
|
branch=get_model("clinic.branch").browse(branch_id)
|
||||||
company_name+=" ("+branch.name+")"
|
company_name+=" ("+branch.name+")"
|
||||||
nlines=[]
|
nlines=[]
|
||||||
|
clines=[]
|
||||||
index=0
|
index=0
|
||||||
old=[]
|
old=[]
|
||||||
total_fee=0
|
total_fee=0
|
||||||
|
@ -221,7 +231,6 @@ class ReportCycleItem(Model):
|
||||||
sub_mdc+=x['mdc'] or 0
|
sub_mdc+=x['mdc'] or 0
|
||||||
if not epos.get(x['mdc_name']):
|
if not epos.get(x['mdc_name']):
|
||||||
epos[x['mdc_name']]=0
|
epos[x['mdc_name']]=0
|
||||||
#XXX
|
|
||||||
if not epos.get(x['iron_name']):
|
if not epos.get(x['iron_name']):
|
||||||
epos[x['iron_name']]=0
|
epos[x['iron_name']]=0
|
||||||
epos[x['iron_name']]+=x['total_ivr'] or 0 #XXX
|
epos[x['iron_name']]+=x['total_ivr'] or 0 #XXX
|
||||||
|
@ -245,12 +254,58 @@ class ReportCycleItem(Model):
|
||||||
key='%s-%s'%(date,cid)
|
key='%s-%s'%(date,cid)
|
||||||
cres=cycles[key]
|
cres=cycles[key]
|
||||||
line['nurse']=''
|
line['nurse']=''
|
||||||
|
more_lines=[]
|
||||||
if index < len(cres):
|
if index < len(cres):
|
||||||
line['nurse']=cres[index]['name']
|
line['nurse']=cres[index]['name']
|
||||||
line['nfirst_name']=cres[index]['first_name']
|
line['nfirst_name']=cres[index]['first_name']
|
||||||
nlines.append(line)
|
if index+1==cycle_check[key]:
|
||||||
|
for i in range(index+1,len(cres)):
|
||||||
|
more_lines.append({
|
||||||
|
'nurse': cres[i]['name'],
|
||||||
|
'nfirst_name': cres[i]['first_name'],
|
||||||
|
'ctid': cres[i]['cycle_item_id'],
|
||||||
|
})
|
||||||
|
#nlines.append(line)
|
||||||
|
clines.append(line)
|
||||||
|
# if nurse more that cres, should show name of nurses
|
||||||
|
nlines+=more_lines
|
||||||
if no==count:
|
if no==count:
|
||||||
epo_items=[{'name': k, 'qty': v} for k,v in epos.items() if k ]
|
epo_items=[{'name': k, 'qty': v} for k,v in epos.items() if k ]
|
||||||
|
#sort item
|
||||||
|
clines=sorted(clines,key=lambda cl: cl[sort_by])
|
||||||
|
no=1
|
||||||
|
index=len(nlines)
|
||||||
|
date_txt=''
|
||||||
|
cseq_txt=''
|
||||||
|
nurse_items=[]
|
||||||
|
for cline in clines:
|
||||||
|
if cline.get('nfirst_name'):
|
||||||
|
nurse_items.append({
|
||||||
|
'nurse': cline.get('nurse'),
|
||||||
|
'nfirst_name': cline.get('nfirst_name'),
|
||||||
|
'ctid': cline.get('ctid'),
|
||||||
|
})
|
||||||
|
cline['nurse']=''
|
||||||
|
cline['nfirst_name']=''
|
||||||
|
cline['ctid']=''
|
||||||
|
if cline.get('cseq_txt'):
|
||||||
|
date_txt=cline.get('date_txt')
|
||||||
|
cseq_txt=cline.get('cseq_txt')
|
||||||
|
cline['date_txt']=''
|
||||||
|
cline['cseq_txt']=''
|
||||||
|
cline['no']=no
|
||||||
|
nlines.append(cline)
|
||||||
|
no+=1
|
||||||
|
nlines[index]['date_txt']=date_txt
|
||||||
|
nlines[index]['cseq_txt']=cseq_txt
|
||||||
|
for nurse_item in nurse_items:
|
||||||
|
nlines[index].update({
|
||||||
|
'nurse': nurse_item['nurse'],
|
||||||
|
'nfirst_name': nurse_item['nfirst_name'],
|
||||||
|
'ctid': nurse_item['ctid'],
|
||||||
|
})
|
||||||
|
index+=1
|
||||||
|
clines=[]
|
||||||
nlines.append({
|
nlines.append({
|
||||||
'sub': 'show',
|
'sub': 'show',
|
||||||
'is_sub': True,
|
'is_sub': True,
|
||||||
|
|
|
@ -201,7 +201,7 @@ class ReportHDCaseDetail(Model):
|
||||||
dom.append(['reg_date','>=',time_start])
|
dom.append(['reg_date','>=',time_start])
|
||||||
dom.append(['reg_date','<=',time_stop])
|
dom.append(['reg_date','<=',time_stop])
|
||||||
dom.append(['walkin','=',"no"])
|
dom.append(['walkin','=',"no"])
|
||||||
dom.append(['dispose','=',False])
|
#dom.append(['dispose','=',False])
|
||||||
if branch_id:
|
if branch_id:
|
||||||
dom.append(['branch_id','=',branch_id])
|
dom.append(['branch_id','=',branch_id])
|
||||||
if department_id:
|
if department_id:
|
||||||
|
|
|
@ -41,7 +41,9 @@ class ReportLaborCost(Model):
|
||||||
report_type=defaults.get("report_type","cross")
|
report_type=defaults.get("report_type","cross")
|
||||||
print('defaults ', defaults)
|
print('defaults ', defaults)
|
||||||
yearnow=date_from.split("-")[0]
|
yearnow=date_from.split("-")[0]
|
||||||
for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
|
period_id=None
|
||||||
|
#for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
|
||||||
|
for period in get_model('clinic.period').search_browse([[]]):
|
||||||
for line in period.lines:
|
for line in period.lines:
|
||||||
if line.state=='open':
|
if line.state=='open':
|
||||||
period_id=line.id
|
period_id=line.id
|
||||||
|
|
|
@ -134,6 +134,7 @@ class ReportLaborCostSummary(Model):
|
||||||
dpt=citem.department_id
|
dpt=citem.department_id
|
||||||
qty=line.qty or 0
|
qty=line.qty or 0
|
||||||
total_hdcase+=qty
|
total_hdcase+=qty
|
||||||
|
print("total_hdcase ", total_hdcase)
|
||||||
amt=line.amount or 0
|
amt=line.amount or 0
|
||||||
staff=line.staff_id
|
staff=line.staff_id
|
||||||
categ_name=''
|
categ_name=''
|
||||||
|
|
|
@ -72,7 +72,7 @@ class ReportRecentPatient(Model):
|
||||||
dom.append(['reg_date','>=',time_start])
|
dom.append(['reg_date','>=',time_start])
|
||||||
dom.append(['reg_date','<=',time_stop])
|
dom.append(['reg_date','<=',time_stop])
|
||||||
dom.append(['walkin','=',"no"])
|
dom.append(['walkin','=',"no"])
|
||||||
dom.append(['dispose','=',False])
|
#dom.append(['dispose','=',False])
|
||||||
if branch_id:
|
if branch_id:
|
||||||
dom.append(['branch_id','=',branch_id])
|
dom.append(['branch_id','=',branch_id])
|
||||||
if department_id:
|
if department_id:
|
||||||
|
|
|
@ -69,14 +69,16 @@ class Sequence(Model):
|
||||||
user=get_model('base.user').browse(user_id)
|
user=get_model('base.user').browse(user_id)
|
||||||
dpt=user.department_id
|
dpt=user.department_id
|
||||||
branch=user.branch_id
|
branch=user.branch_id
|
||||||
if dpt:
|
if context.get('branch_id'):
|
||||||
|
comp_dom=comp_dom+[["branch_id","=",context['branch_id']]]
|
||||||
|
elif dpt:
|
||||||
branch_id=dpt.branch_id.id
|
branch_id=dpt.branch_id.id
|
||||||
comp_dom=comp_dom+[["branch_id","=",branch_id]]
|
comp_dom=comp_dom+[["branch_id","=",branch_id]]
|
||||||
elif branch:
|
elif branch:
|
||||||
branch_id=branch.id
|
branch_id=branch.id
|
||||||
comp_dom=comp_dom+[["branch_id","=",branch_id]]
|
comp_dom=comp_dom+[["branch_id","=",branch_id]]
|
||||||
elif context.get('branch_id'):
|
#elif context.get('branch_id'):
|
||||||
comp_dom=comp_dom+[["branch_id","=",context['branch_id']]]
|
#comp_dom=comp_dom+[["branch_id","=",context['branch_id']]]
|
||||||
print('com_dom ', comp_dom)
|
print('com_dom ', comp_dom)
|
||||||
res=self.search(comp_dom,order="id")
|
res=self.search(comp_dom,order="id")
|
||||||
if res:
|
if res:
|
||||||
|
|
|
@ -64,6 +64,8 @@ class ClinicSetting(Model):
|
||||||
'staff_from_id': fields.Many2One("clinic.staff","Staff From"),
|
'staff_from_id': fields.Many2One("clinic.staff","Staff From"),
|
||||||
'staff_to_id': fields.Many2One("clinic.staff","Staff To"),
|
'staff_to_id': fields.Many2One("clinic.staff","Staff To"),
|
||||||
'product_categ_view': fields.Many2Many("product.categ","Product Category View"),
|
'product_categ_view': fields.Many2Many("product.categ","Product Category View"),
|
||||||
|
'hdcase_picking_auto': fields.Boolean("HDCase Auto Picking"),
|
||||||
|
'dlz_picking_auto': fields.Boolean("DLZ Auto Picking"),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Visit(Model):
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
while 1:
|
while 1:
|
||||||
seq_type='clinic_visit'
|
seq_type='clinic_visit'
|
||||||
seq_id=get_model("sequence").find_sequence(type=seq_type)
|
seq_id=get_model("sequence").find_sequence(type=seq_type,context=context)
|
||||||
if not seq_id:
|
if not seq_id:
|
||||||
raise Exception("Can not found sequence %s"%seq_type)
|
raise Exception("Can not found sequence %s"%seq_type)
|
||||||
num=get_model("sequence").get_next_number(seq_id,context=context)
|
num=get_model("sequence").get_next_number(seq_id,context=context)
|
||||||
|
@ -203,10 +203,13 @@ class Visit(Model):
|
||||||
hd_case_id=None
|
hd_case_id=None
|
||||||
if obj.hd_cases:
|
if obj.hd_cases:
|
||||||
hd_case=obj.hd_cases[0]
|
hd_case=obj.hd_cases[0]
|
||||||
|
# prevent duplicate staff: del old staff
|
||||||
|
for staff in hd_case.staffs:
|
||||||
|
staff.delete()
|
||||||
hd_case.write(vals)
|
hd_case.write(vals)
|
||||||
hd_case_id=hd_case.id
|
hd_case_id=hd_case.id
|
||||||
else:
|
else:
|
||||||
hd_case_id=hd_case_obj.create(vals)
|
hd_case_id=hd_case_obj.create(vals,context=context)
|
||||||
|
|
||||||
if context.get("called"): #XXX call outside
|
if context.get("called"): #XXX call outside
|
||||||
return hd_case_id
|
return hd_case_id
|
||||||
|
@ -476,8 +479,8 @@ class Visit(Model):
|
||||||
'flash': 'Visit\'s %s has been cancelled'%obj.patient_id.name
|
'flash': 'Visit\'s %s has been cancelled'%obj.patient_id.name
|
||||||
}
|
}
|
||||||
|
|
||||||
def create(self, vals,**kw):
|
def create(self, vals,context):
|
||||||
new_id=super().create(vals,**kw)
|
new_id=super().create(vals,context=context)
|
||||||
self.function_store([new_id])
|
self.function_store([new_id])
|
||||||
return new_id
|
return new_id
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ class VisitBoard(Model):
|
||||||
defaults=self.default_get(context=context)
|
defaults=self.default_get(context=context)
|
||||||
department_id=defaults.get("department_id",None)
|
department_id=defaults.get("department_id",None)
|
||||||
branch_id=defaults.get("branch_id",None)
|
branch_id=defaults.get("branch_id",None)
|
||||||
|
context['branch_id']=branch_id
|
||||||
state=defaults.get("state",'pending')
|
state=defaults.get("state",'pending')
|
||||||
if ids:
|
if ids:
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
@ -96,6 +97,7 @@ class VisitBoard(Model):
|
||||||
doctor_id=obj.doctor_id.id
|
doctor_id=obj.doctor_id.id
|
||||||
department_id=obj.department_id.id
|
department_id=obj.department_id.id
|
||||||
branch_id=obj.branch_id.id
|
branch_id=obj.branch_id.id
|
||||||
|
context['branch_id']=branch_id
|
||||||
state=obj.state
|
state=obj.state
|
||||||
# auto generate visit day to day
|
# auto generate visit day to day
|
||||||
def auto_gen_visit(dom=[]):
|
def auto_gen_visit(dom=[]):
|
||||||
|
@ -147,7 +149,7 @@ class VisitBoard(Model):
|
||||||
'visit_date': date_txt,
|
'visit_date': date_txt,
|
||||||
'state': 'pending',
|
'state': 'pending',
|
||||||
}
|
}
|
||||||
visit_id=get_model("clinic.visit").create(vals)
|
visit_id=get_model("clinic.visit").create(vals,context=context)
|
||||||
print('create new visit %s for %s'%(visit_id,pt.name))
|
print('create new visit %s for %s'%(visit_id,pt.name))
|
||||||
time_start='%s 00:00:00'%(date_from)
|
time_start='%s 00:00:00'%(date_from)
|
||||||
time_stop='%s 23:59:59'%(date_to)
|
time_stop='%s 23:59:59'%(date_to)
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1,7 @@
|
||||||
- move patient to antother location
|
redesign print payment & invoice from hdcase
|
||||||
|
- print payment
|
||||||
|
- direct payment
|
||||||
|
- invoice payment
|
||||||
|
|
||||||
|
migration:
|
||||||
|
match invoice less than 2015-06-30 to hdcase
|
||||||
|
|
Loading…
Reference in New Issue