show company

conv_bal
watcha.h@almacom.co.th 2015-01-09 12:19:52 +07:00
parent 7eff465fd1
commit cbde2cc6ff
45 changed files with 259 additions and 161 deletions

View File

@ -1,4 +1,5 @@
<inherit model="partner" inherit="contact_form"> <inherit model="partner" inherit="contact_form">
<!--
<field name="payment_terms" position="after"> <field name="payment_terms" position="after">
<newline/> <newline/>
<separator string="Clinic"/> <separator string="Clinic"/>
@ -8,4 +9,5 @@
<field name="account_payment_id" attrs='{"required":[["type","=","org"]]}'/> <field name="account_payment_id" attrs='{"required":[["type","=","org"]]}'/>
<field name="account_income_id" attrs='{"required":[["type","=","org"]]}'/> <field name="account_income_id" attrs='{"required":[["type","=","org"]]}'/>
</field> </field>
-->
</inherit> </inherit>

View File

@ -1,4 +1,4 @@
<form model="clinic.cycle"> <form model="clinic.cycle" show_company="1">
<head> <head>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
</button> </button>
@ -10,6 +10,7 @@
<field name="color"/> <field name="color"/>
<field name="duration"/> <field name="duration"/>
<field name="note"/> <field name="note"/>
<field name="company_id" invisible="1"/>
<related> <related>
<field name="cycle_items"/> <field name="cycle_items"/>
<field name="visits"/> <field name="visits"/>

View File

@ -10,28 +10,8 @@
<field name="cycle_id" required="1"/> <field name="cycle_id" required="1"/>
<field name="date"/> <field name="date"/>
<field name="company_id" invisible="1"/>
<tabs> <tabs>
<!--
<tab string="HDCase">
<field name="hd_cases" nolabel="1" count="5">
<list model="clinic.hd.case" colors='{"#cfc":[["state","=","completed"]],"#f9e37d":[["state","=","in_progress"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]],"#70DB93":[["state","=","paid"]]}'>
<field name="sickbed_id" domain="[['available','=',true]]" span="2"/>
<field name="patient_id" span="2"/>
<field name="time_start" span="2"/>
<field name="wt_start" span="2"/>
<field name="bp_start" span="2"/>
<field name="membrane_type" span="2"/>
<field name="vascular_acc" span="2"/>
<field name="bid_flow_rate" span="2"/>
<field name="ultrafittration" span="2"/>
<field name="time_stop" span="2"/>
<field name="wt_stop" span="2"/>
<field name="bp_stop" span="2"/>
<field name="hd_case_id" span="2"/>
</list>
</field>
</tab>
-->
<tab string="Nurses"> <tab string="Nurses">
<field name="nurses" nolabel="1"> <field name="nurses" nolabel="1">
<list> <list>

View File

@ -18,6 +18,7 @@
<field name="use_time" readonly="1"/> <field name="use_time" readonly="1"/>
<field name="max_use_time"/> <field name="max_use_time"/>
<field name="description"/> <field name="description"/>
<field name="company_id" invisible="1"/>
</group> </group>
<foot> <foot>
<button string="Confirm" type="success" states="new" method="confirm"/> <button string="Confirm" type="success" states="new" method="confirm"/>

View File

@ -8,14 +8,16 @@
</head> </head>
<group form_layout="stacked" attrs='{"readonly":[["state","=","completed"]]}'> <group form_layout="stacked" attrs='{"readonly":[["state","=","completed"]]}'>
<field name="number" span="2"/> <field name="number" span="2"/>
<field name="sickbed_id" domain="[['available','=',true]]" required="1" span="2"/> <field name="sickbed_id" attrs='{"readonly":[["state","in",["completed","waiting_payment","paid"]]]}' domain="[['state','=','available']]" required="1" span="2"/>
<field name="patient_id" span="2" onchange="onchange_patient"/> <field name="patient_id" span="2" onchange="onchange_patient"/>
<field name="patient_type_id" span="2"/> <field name="patient_type_id" span="2"/>
<field name="cycle_id" span="2" required="1" onchange="onchange_cycle"/> <field name="cycle_id" span="2" required="1" onchange="onchange_cycle"/>
<field name="department_id" span="2"/> <field name="department_id" span="2"/>
<field name="cycle_item_id" span="2" domain="[['cycle_id','=',cycle_id]]"/> <field name="cycle_item_id" span="2" domain="[['cycle_id','=',cycle_id]]"/>
<field name="visit_id" span="2"/> <field name="visit_id" span="2"/>
<field name="req_fee" span="2" readonly="1" invisible="1"/> <field name="req_fee" span="2" invisible="1"/>
<!-- enable show_company=1 -->
<field name="company_id" span="2" invisible="1"/>
</group> </group>
<tabs> <tabs>
<tab string="General"> <tab string="General">
@ -119,7 +121,8 @@
<button string="Done" type="success" icon="ok" method="done" states="in_progress"/> <button string="Done" type="success" icon="ok" method="done" states="in_progress"/>
<button string="Discard" type="danger" icon="remove" action="clinic_hd_case_distcont" states="in_progress"/> <button string="Discard" type="danger" icon="remove" action="clinic_hd_case_distcont" states="in_progress"/>
<button string="Claim Expense" type="default" icon="arrow-right" states="completed" method="request_fee" attrs='{"invisible":[["req_fee","=",1]]}'/> <button string="Claim Expense" type="default" icon="arrow-right" states="completed" method="request_fee" attrs='{"invisible":[["req_fee","=",1]]}'/>
<button string="Pay" type="success" icon="ok" method="pay" states="completed" attrs='{"invisible":[["req_fee","=",0]]}'/> <!--<button string="Pay" type="success" icon="ok" method="pay" states="completed" attrs='{"invisible":[["req_fee","=",0]]}'/>-->
<button string="Pay" type="success" icon="ok" method="pay" states="completed,waiting_payment" attrs='{"invisible":[["req_fee","=",0]]}'/>
</foot> </foot>
<related> <related>
<field name="invoices" click_action="view_invoice"> <field name="invoices" click_action="view_invoice">

View File

@ -2,6 +2,7 @@
<field name="number"/> <field name="number"/>
<field name="date"/> <field name="date"/>
<field name="patient_id"/> <field name="patient_id"/>
<field name="patient_type_id"/>
<field name="sickbed_id"/> <field name="sickbed_id"/>
<field name="cycle_id"/> <field name="cycle_id"/>
<field name="department_id"/> <field name="department_id"/>

View File

@ -36,29 +36,21 @@
<item string="Visits"> <item string="Visits">
<item string="Visits" action="clinic_visit"/> <item string="Visits" action="clinic_visit"/>
<item string="Visit Board" action="clinic_visit_board"/> <item string="Visit Board" action="clinic_visit_board"/>
<!--<item string="Generate Visit" action="clinic_gen_visit_form"/>-->
</item> </item>
<item string="HD Cases">
<item string="HD Cases" action="clinic_hd_case"/> <item string="HD Cases" action="clinic_hd_case"/>
<item string="Sickbed" action="clinic_sickbed"/>
</item>
<item string="Reports"> <item string="Reports">
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/> <item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
<item string="Medical Summary" action="clinic_report_medical_summary"/> <item string="Medical Summary" action="clinic_report_medical_summary"/>
<item string="Recent Patient" action="clinic_report_recent_patient"/> <item string="Recent Patient" action="clinic_report_recent_patient"/>
<item string="Discontinue Patient" action="clinic_report_discontinue_patient"/> <item string="Discontinue Patient" action="clinic_report_discontinue_patient"/>
</item> </item>
<!--
<item string="Others">
<header string="TESTING"/>
<item string="Import Product" action="import_clinic_product"/>
<item string="Import Patient" action="import_clinic_patient"/>
<item string="Import Visit" action="import_clinic_visit"/>
<item string="Import HD Case" action="import_clinic_hd_case"/>
</item>
-->
<item string="Settings"> <item string="Settings">
<item string="Branch" action="clinic_branch"/> <item string="Branch" action="clinic_branch"/>
<item string="Departments" action="clinic_department"/> <item string="Departments" action="clinic_department"/>
<item string="Hospital" action="clinic_hospital"/> <item string="Hospital" action="clinic_hospital"/>
<item string="Sickbed" action="clinic_sickbed"/>
<item string="Nationalities" action="clinic_nation"/> <item string="Nationalities" action="clinic_nation"/>
<item string="Valcular Access" action="clinic_vascular_access"/> <item string="Valcular Access" action="clinic_vascular_access"/>
<item string="Clinic Settings" action="clinic_setting"/> <item string="Clinic Settings" action="clinic_setting"/>

View File

@ -4,13 +4,15 @@
<item string="Labor Cost" action="clinic_labor_cost"/> <item string="Labor Cost" action="clinic_labor_cost"/>
<item string="Labor Cost Items" action="clinic_labor_cost_item"/> <item string="Labor Cost Items" action="clinic_labor_cost_item"/>
<item string="Labor Cost Entries" action="clinic_labor_cost_entry"/> <item string="Labor Cost Entries" action="clinic_labor_cost_entry"/>
<!--<item string="Import Payment" action="import_clinic_payment"/>-->
<item string="Matching Invoices" action="clinic_report_payment_matching"/> <item string="Matching Invoices" action="clinic_report_payment_matching"/>
<item string="HD Case Expenses" action="clinic_hd_case_expense"/> <item string="HD Case Expenses" action="clinic_hd_case_expense"/>
<divider/> <divider/>
<header string="REPORTS"/> <header string="REPORTS"/>
<item string="Staff Fee Summary" action="clinic_report_staff_fee_sum"/> <item string="Staff Fee Summary" action="clinic_report_staff_fee_sum"/>
<item string="Staff Fee Detail" action="clinic_report_staff_fee_detail"/> <item string="Staff Fee Detail" action="clinic_report_staff_fee_detail"/>
<divider/>
<header string="SETTINGS"/>
<item string="Labor Cost Setting" action="clinic_report_staff_fee_sum"/>
</item> </item>
</item> </item>
<item string="Conversion Balances" position="after"> <item string="Conversion Balances" position="after">

View File

@ -1,4 +1,4 @@
<form model="clinic.patient"> <form model="clinic.patient" show_company="1">
<head> <head>
<field name="type_id"/> <field name="type_id"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
@ -8,7 +8,7 @@
</button> </button>
</head> </head>
<field name="number"/> <field name="number"/>
<field name="trt_number"/> <field name="trt_no"/>
<field name="type_id"/> <field name="type_id"/>
<field name="name"/> <field name="name"/>
<field name="hn"/> <field name="hn"/>
@ -28,7 +28,7 @@
<field name="card_exp"/> <field name="card_exp"/>
<field name="birthday"/> <field name="birthday"/>
<field name="age"/> <field name="age"/>
<field name="picture"/> <field name="image"/>
<field name="mobile"/> <field name="mobile"/>
<field name="email"/> <field name="email"/>
</group> </group>
@ -41,6 +41,7 @@
<field name="weight"/> <field name="weight"/>
<field name="height"/> <field name="height"/>
<field name="phone"/> <field name="phone"/>
<field name="company_id" invisible="1"/>
</group> </group>
</tab> </tab>
<tab string="Health Information"> <tab string="Health Information">
@ -98,7 +99,7 @@
<tab string="Other"> <tab string="Other">
<group form_layout="stacked"> <group form_layout="stacked">
<field name="cycle_id" span="2"/> <field name="cycle_id" span="2"/>
<field name="hn_num" span="2"/> <field name="hn_no" span="2"/>
</group> </group>
</tab> </tab>
</tabs> </tabs>

View File

@ -4,11 +4,12 @@
</head> </head>
<field name="reg_date"/> <field name="reg_date"/>
<field name="number"/> <field name="number"/>
<field name="hn"/> <field name="hn_no"/>
<field name="trt_no"/>
<field name="name"/> <field name="name"/>
<field name="department_id"/> <field name="department_id"/>
<field name="branch_id"/> <field name="branch_id"/>
<field name="categ_id"/> <field name="categ_id"/>
<!--<field name="type"/>-->
<field name="type_id"/> <field name="type_id"/>
<field name="image" preview='1'/>
</list> </list>

View File

@ -1,4 +1,4 @@
<form model="clinic.patient.type"> <form model="clinic.patient.type" show_company="1">
<head> <head>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="New Contact" method="new_contact"/> <item string="New Contact" method="new_contact"/>
@ -8,4 +8,5 @@
<field name="code"/> <field name="code"/>
<field name="contact_id"/> <field name="contact_id"/>
<field name="default"/> <field name="default"/>
<field name="company_id" invisible="1"/>
</form> </form>

View File

@ -1,4 +1,4 @@
<list model="clinic.patient.type"> <list model="clinic.patient.type" colors='{"#cfc":[["default","=",true]]}'>
<field name="name"/> <field name="name"/>
<field name="code"/> <field name="code"/>
<field name="contact_id"/> <field name="contact_id"/>

View File

@ -23,6 +23,7 @@
<field name="cycle_item_id" readonly="1"/> <field name="cycle_item_id" readonly="1"/>
</list> </list>
</field> </field>
<field name="company_id" invisible="1"/>
</group> </group>
</tab> </tab>
<tab string="Planning"> <tab string="Planning">

View File

@ -13,6 +13,7 @@
<list> <list>
<field name="patient_type_id"/> <field name="patient_type_id"/>
<field name="product_id" onchange="onchange_product"/> <field name="product_id" onchange="onchange_product"/>
<field name="account_id"/>
<field name="product_categ_id"/> <field name="product_categ_id"/>
<field name="description"/> <field name="description"/>
<field name="reimbursable"/> <field name="reimbursable"/>
@ -21,17 +22,6 @@
<field name="qty" onchange="onchange_setting_line"/> <field name="qty" onchange="onchange_setting_line"/>
<field name="amount"/> <field name="amount"/>
</list> </list>
<form>
<field name="patient_type_id"/>
<field name="product_id"/>
<field name="product_categ_id"/>
<field name="description"/>
<field name="reimbursable"/>
<field name="uom_id"/>
<field name="price"/>
<field name="qty"/>
<field name="amount"/>
</form>
</field> </field>
<!-- <!--
<separator string="Invoice Policy"/> <separator string="Invoice Policy"/>

View File

@ -1,4 +1,4 @@
<form model="clinic.sickbed"> <form model="clinic.sickbed" show_company="1">
<head> <head>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Copy" method="copy"/> <item string="Copy" method="copy"/>
@ -6,6 +6,7 @@
</head> </head>
<field name="name"/> <field name="name"/>
<field name="available" readonly="1"/> <field name="available" readonly="1"/>
<field name="company_id" invisible="1"/>
<related> <related>
<field name="hd_cases"/> <field name="hd_cases"/>
</related> </related>

View File

@ -1,4 +1,8 @@
<list model="clinic.sickbed"> <list model="clinic.sickbed" colors='{"#70db93":[["state","=","available"]],"#ee3322":[["state","=","not_available"]]}'>
<field name="name"/> <field name="name"/>
<field name="available"/> <field name="date"/>
<field name="patient_id"/>
<field name="image" preview="1"/>
<!--<field name="available"/>-->
<field name="state"/>
</list> </list>

View File

@ -1,5 +1,6 @@
<form model="clinic.staff.categ"> <form model="clinic.staff.categ" show_company="1">
<field name="name"/> <field name="name"/>
<field name="type"/> <field name="type"/>
<field name="parent_id" domain="[['type','=',type]]"/> <field name="parent_id" domain="[['type','=',type]]"/>
<field name="company_id" invisible="1"/>
</form> </form>

View File

@ -1,4 +1,4 @@
<form model="clinic.staff"> <form model="clinic.staff" show_company="1">
<head> <head>
<field name="state"/> <field name="state"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
@ -12,6 +12,7 @@
<field name="nick_name"/> <field name="nick_name"/>
<field name="department_id"/> <field name="department_id"/>
<field name="branch_id"/> <field name="branch_id"/>
<field name="company_id" invisible="1"/>
<tabs> <tabs>
<tab string="General"> <tab string="General">
<group span="6" columns="1"> <group span="6" columns="1">
@ -24,7 +25,7 @@
<field name="state"/> <field name="state"/>
</group> </group>
<group span="6" columns="1"> <group span="6" columns="1">
<field name="picture"/> <field name="image"/>
<field name="user_id"/> <field name="user_id"/>
<field name="employee_id"/> <field name="employee_id"/>
<field name="email"/> <field name="email"/>

View File

@ -1,4 +1,4 @@
<form model="clinic.staff.level"> <form model="clinic.staff.level" show_company="1">
<head> <head>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Copy" method="copy"/> <item string="Copy" method="copy"/>
@ -8,4 +8,5 @@
<field name="type"/> <field name="type"/>
<field name="sequence"/> <field name="sequence"/>
<field name="description"/> <field name="description"/>
<field name="company_id" invisible="1"/>
</form> </form>

View File

@ -14,5 +14,6 @@
<field name="level_id"/> <field name="level_id"/>
<field name="categ_id"/> <field name="categ_id"/>
<field name="type"/> <field name="type"/>
<field name="image"/>
<field name="state"/> <field name="state"/>
</list> </list>

View File

@ -1,4 +1,4 @@
<form model="clinic.staff.rotation"> <form model="clinic.staff.rotation" show_company="1">
<field name="staff_id"/> <field name="staff_id"/>
<field name="level_id"/> <field name="level_id"/>
<field name="from_company_id"/> <field name="from_company_id"/>
@ -8,4 +8,5 @@
<field name="wage"/> <field name="wage"/>
<field name="max_cycle"/> <field name="max_cycle"/>
<field name="note"/> <field name="note"/>
<field name="company_id" invisible="1"/>
</form> </form>

View File

@ -7,6 +7,7 @@
<button string="New Visit" method="make_visit" span="1" icon="plus" type="success" size="small"/> <button string="New Visit" method="make_visit" span="1" icon="plus" type="success" size="small"/>
</group> </group>
<group span="2" columns="1"> <group span="2" columns="1">
<button string="Make An Appointment" action="clinic_gen_visit_form" span="2" icon="calendar" type="default" size="small"/> <button string="Make An Appointment" action="clinic_gen_visit_form" span="1" icon="calendar" type="default" size="small"/>
</group> </group>
<!--<button string="calendar" icon="calendar" size="small" span="1"/>-->
</form> </form>

View File

@ -1,9 +1,8 @@
<calendar model="clinic.visit" states='draft' start_field="time_start" end_field="time_stop" colors='{"#090":[["cycle","=",1]],"#2400ff":[["cycle","=",2]],"orange":[["cycle","=",3]],"#f20000":[["cycle","=",4]]}'> <calendar model="clinic.visit" states='draft' start_field="time_start" end_field="time_stop" colors='{"#F1B2E1":[["cycle_color","=","#F1B2E1"]],"#B1DDF3":[["cycle_color","=","#B1DDF3"]],"#FFDE89":[["cycle_color","=","#FFDE89"]],"#E3675C":[["cycle_color","=","#E3675C"]]}'>
<field name="patient_id"/> <field name="patient_id"/>
<field name="cycle_id"/> <field name="cycle_id"/>
<field name="number"/> <field name="number"/>
<field name="doctor_id"/> <field name="doctor_id"/>
<field name="nurse_id"/> <field name="nurse_id"/>
<field name="cycle_color"/> <field name="cycle_color"/>
<!--<field name="state"/>-->
</calendar> </calendar>

View File

@ -21,6 +21,7 @@
<field name="time_stop"/> <field name="time_stop"/>
<field name="doctor_id"/> <field name="doctor_id"/>
<field name="visit_date" onchange="onchange_date"/> <field name="visit_date" onchange="onchange_date"/>
<field name="company_id" invisible="1"/>
</group> </group>
</tab> </tab>
<tab string="Confirmation"> <tab string="Confirmation">

View File

@ -1,6 +1,6 @@
<inherit model="settings" inherit="fin_settings"> <inherit model="settings" inherit="fin_settings">
<field name="rounding_account_id" position="after"> <field name="rounding_account_id" position="after">
<separator string="Clinic"/> <separator string="Clinic (Patient pay by them-self)"/>
<field name="cash_account_id" domain="[['type','!=','view']]"/> <field name="cash_account_id" domain="[['type','!=','view']]"/>
<field name="income_account_id" domain="[['type','!=','view']]"/> <field name="income_account_id" domain="[['type','!=','view']]"/>
<!--<field name="ap_doctor_id"/>--> <!--<field name="ap_doctor_id"/>-->

View File

@ -7,6 +7,7 @@ class Cycle(Model):
_name="clinic.cycle" _name="clinic.cycle"
_string="Cycle" _string="Cycle"
_key=["name"] _key=["name"]
_multi_company=True
def _get_duration(self,ids,context={}): def _get_duration(self,ids,context={}):
res={} res={}

View File

@ -8,6 +8,7 @@ class CycleItem(Model):
_name="clinic.cycle.item" _name="clinic.cycle.item"
_string="Cycle Item" _string="Cycle Item"
_name_field="name" _name_field="name"
_multi_company=True
def _get_all(self,ids,context={}): def _get_all(self,ids,context={}):
res={} res={}

View File

@ -114,6 +114,7 @@ class HDCase(Model):
"invoice_option": fields.Selection([("fee_mdc_plus","Combine Fee & Medicine"),("fee_mdc_split","Split Fee & Medicine")],"Invoice:"), "invoice_option": fields.Selection([("fee_mdc_plus","Combine Fee & Medicine"),("fee_mdc_split","Split Fee & Medicine")],"Invoice:"),
'req_fee': fields.Integer("Request Expense"), 'req_fee': fields.Integer("Request Expense"),
'hd_case_id': fields.Many2One("clinic.hd.case","HD",function="_get_all",function_multi=True), # XXX 'hd_case_id': fields.Many2One("clinic.hd.case","HD",function="_get_all",function_multi=True), # XXX
'company_id': fields.Many2One("company","Company"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -320,6 +321,7 @@ class HDCase(Model):
payment_id=get_model("account.payment").create(vals,context={"type":"in"}) payment_id=get_model("account.payment").create(vals,context={"type":"in"})
obj.write({ obj.write({
'state': 'paid',
'payment_lines': [('create',{ 'payment_lines': [('create',{
'payment_id': payment_id, 'payment_id': payment_id,
'amount': pay_amount, 'amount': pay_amount,
@ -360,32 +362,43 @@ class HDCase(Model):
context['inv_type']='invoice' context['inv_type']='invoice'
rmb_lines=[] #yes rmb_lines=[] #yes
normb_lines=[] #no normb_lines=[] #no
cst=get_model('clinic.setting').browse(1)
for line in obj.lines: for line in obj.lines:
if line.state!='draft': if line.state!='draft':
continue continue
prod=line.product_id prod=line.product_id
# 1.find in line
account_id=line.account_id.id
if not account_id:
# 2.find in clinic setting
for sline in cst.products:
stype=sline.patient_type_id
if stype.id==obj.patient_type_id.id and prod.id==sline.product_id.id:
account_id=sline.account_id.id
break
# 3.find in product(tab accounting)
if not account_id:
account_id=prod.sale_account_id.id account_id=prod.sale_account_id.id
if not account_id: if not account_id:
raise Exception("Please define sale account for product [%s] %s"%(prod.code, prod.name)) raise Exception("Please define sale account for product [%s] %s"%(prod.code, prod.name))
if line.reimbursable=='yes': if line.reimbursable=='yes':
rmb_lines.append(('create',{ rmb_lines.append(('create',{
"product_id": prod.id, "product_id": prod.id,
"description": line.description, "description": line.description or "",
"qty": line.qty, "qty": line.qty,
"uom_id": line.uom_id.id, "uom_id": line.uom_id.id,
"unit_price": line.price, "unit_price": line.price or 0,
"amount": line.amount, "amount": line.amount or 0,
'account_id': account_id, 'account_id': account_id,
})) }))
else: else:
normb_lines.append(('create',{ normb_lines.append(('create',{
"product_id": prod.id, "product_id": prod.id,
"description": line.description, "description": line.description or "",
"qty": line.qty, "qty": line.qty,
"uom_id": line.uom_id.id, "uom_id": line.uom_id.id,
"unit_price": line.price, "unit_price": line.price or 0,
"amount": line.amount, "amount": line.amount or 0,
'account_id': account_id, 'account_id': account_id,
})) }))
@ -522,11 +535,6 @@ class HDCase(Model):
#TODO should find dlz when confirm visit #TODO should find dlz when confirm visit
if not obj.dialyzers: if not obj.dialyzers:
raise Exception("Please input dialyzer!") raise Exception("Please input dialyzer!")
sickbed=obj.sickbed_id
sickbed.write({
'available': False,
})
vals={ vals={
'state': 'in_progress', 'state': 'in_progress',
} }
@ -751,7 +759,7 @@ class HDCase(Model):
'state': 'completed', 'state': 'completed',
}) })
obj.sickbed_id.write({ obj.sickbed_id.write({
'available': True, 'state': 'available',
}) })
return { return {
'next': { 'next': {
@ -882,6 +890,11 @@ class HDCase(Model):
price=st_prod.price price=st_prod.price
qty=st_prod.qty qty=st_prod.qty
amt=st_prod.amount amt=st_prod.amount
account_id=st_prod.account_id.id
if not account_id:
account_id=prod.sale_account_id.id
if not account_id:
raise Exception("Please define sale account for product [%s] %s"%(prod.code, prod.name))
if not amt: if not amt:
amt=qty*price amt=qty*price
categ=st_prod.product_categ_id categ=st_prod.product_categ_id
@ -894,6 +907,7 @@ class HDCase(Model):
'qty': qty, 'qty': qty,
'reimbursable': st_prod.reimbursable, 'reimbursable': st_prod.reimbursable,
'amount': amt, 'amount': amt,
'account_id': account_id,
})) }))
# XXX need to get default # XXX need to get default
partner=patient.type_id.contact_id partner=patient.type_id.contact_id
@ -925,21 +939,66 @@ class HDCase(Model):
def write(self,ids,vals,**kw): def write(self,ids,vals,**kw):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
vals['req_fee']=0 total_amt=0
due_amt=0
if 'lines' in vals.keys(): if 'lines' in vals.keys():
#for mode, line_ids, line_vals in vals['lines']:
for line in vals['lines']: for line in vals['lines']:
mode=line[0] mode=line[0]
if mode=='create': if mode=='create':
line_vals=line[1] line_vals=line[1]
else: else:
line_vals=line[2] line_vals=line[2]
if line_vals['reimbursable']=='no': amt=line_vals.get("amount",0)
vals['req_fee']=1 # to show button pay total_amt+=amt
rmb=line_vals.get("reimbursable","no")
print('rmb ', rmb)
if rmb=='no':
due_amt+=amt
else: else:
for line in obj.lines: for line in obj.lines:
amt=line.amount or 0
total_amt+=amt
print('>> rmb ', line.reimbursable)
if line.reimbursable=='no': if line.reimbursable=='no':
due_amt+=amt
pay_amt=0
if 'payment_lines' in vals.keys():
for line in vals['payment_lines']:
mode=line[0]
if mode=='create':
line_vals=line[1]
else:
line_vals=line[2]
pay_amt+=line_vals.get("amount",0)
for pline in obj.payment_lines:
pay_amt+=pline.amount or 0
due_amt-=pay_amt
vals['req_fee']=0
print('due_amt ', due_amt)
if due_amt<=0:
vals['req_fee']=1 vals['req_fee']=1
elif due_amt>0:
vals['req_fee']=1
#if obj.state=='completed':
#if pay_amt==0:
#vals['req_fee']=0 # to hide button pay
#elif pay_amt==total_amt:
#vals['req_fee']=1 # to show button pay
#elif pay_amt<total_amt:
#vals['req_fee']=1 # to show button pay
if 'sickbed_id' in vals.keys():
if vals['sickbed_id']!=obj.sickbed_id.id and obj.state!='draft':
if obj.sickbed_id:
obj.sickbed_id.write({
'state': 'available',
})
sb=get_model("clinic.sickbed").browse(vals['sickbed_id'])
sb.write({
'state': 'not_available',
})
super().write(ids,vals,**kw) super().write(ids,vals,**kw)
def approve(self,ids,context={}): def approve(self,ids,context={}):
@ -957,4 +1016,5 @@ class HDCase(Model):
} }
HDCase.register() HDCase.register()

View File

@ -14,6 +14,7 @@ class Hdcaseline(Model):
"product_categ_id": fields.Many2One("product.categ","Category",domain=[['expense','=',True]]), "product_categ_id": fields.Many2One("product.categ","Category",domain=[['expense','=',True]]),
'reimbursable': fields.Selection([['yes','Yes'],['no','No']],"Reimbursable"), 'reimbursable': fields.Selection([['yes','Yes'],['no','No']],"Reimbursable"),
'state': fields.Selection([['draft','Draft'],['done','Done']],"State"), 'state': fields.Selection([['draft','Draft'],['done','Done']],"State"),
"account_id": fields.Many2One("account.account","Account"),
} }
_defaults={ _defaults={

View File

@ -45,13 +45,14 @@ class HDCasePayment(Model):
hd_case.make_payment(context=context) hd_case.make_payment(context=context)
if obj.complete: if obj.complete:
hd_case.create_cycle_item() hd_case.create_cycle_item()
if obj.pay_amount==hd_case.total_amount: #XXX if obj.pay_amount==obj.to_pay:
vals={ vals={
'state': 'paid', 'state': 'paid',
} }
else: else:
vals={ vals={
'state': 'waiting_payment', 'state': 'waiting_payment',
#'req_fee': 1, # show pay button
} }
hd_case.write(vals) hd_case.write(vals)
hd_case.do_expense() hd_case.do_expense()
@ -74,11 +75,11 @@ class HDCasePayment(Model):
hd_case.make_invoices(context=context) hd_case.make_invoices(context=context)
hd_case.post_invoices() hd_case.post_invoices()
hd_case.create_cycle_item() hd_case.create_cycle_item()
if obj.pay_amount==obj.to_pay: #if obj.pay_amount==obj.to_pay:
vals={ #vals={
'state': 'paid', #'state': 'paid',
} #}
hd_case.write(vals) #hd_case.write(vals)
hd_case.do_expense() hd_case.do_expense()
return { return {
'next': { 'next': {

View File

@ -136,8 +136,8 @@ class ImportPayment(Model):
def get_all_patient(self): def get_all_patient(self):
print("getting patient") print("getting patient")
patients={} patients={}
for pt in get_model("clinic.patient").search_read([[]],['name','hn','hn_num']): for pt in get_model("clinic.patient").search_read([[]],['name','hn','hn_no']):
key=pt['hn_num'] key=pt['hn_no']
patients[key]={ patients[key]={
'id': pt['id'], 'id': pt['id'],
'name': pt['name'], 'name': pt['name'],
@ -157,7 +157,7 @@ class ImportPayment(Model):
} }
return hd_cases return hd_cases
def get_hn_num(self,hn=""): def get_hn_no(self,hn=""):
return ''.join(h for h in hn if h.isdigit()) return ''.join(h for h in hn if h.isdigit())
def import_payment_pks(self,ids,context={}): def import_payment_pks(self,ids,context={}):
@ -201,8 +201,8 @@ class ImportPayment(Model):
def get_invoice_epobills(self,lines): def get_invoice_epobills(self,lines):
for line in lines: for line in lines:
hn=line.get('hn',"") hn=line.get('hn',"")
hn_num=self.get_hn_num(hn) hn_no=self.get_hn_no(hn)
print(hn_num) print(hn_no)
return lines return lines
def get_invoice_hdbills(self,lines): def get_invoice_hdbills(self,lines):
@ -211,8 +211,8 @@ class ImportPayment(Model):
invno=line.get("invno") invno=line.get("invno")
hdrate=float(line.get("hdrate","0")) hdrate=float(line.get("hdrate","0"))
hn=line.get('hn',"") hn=line.get('hn',"")
hn_num=self.get_hn_num(hn) hn_no=self.get_hn_no(hn)
print(hn_num) print(hn_no)
return lines return lines
def import_payment_uc(self,ids,context={}): def import_payment_uc(self,ids,context={}):

View File

@ -41,7 +41,7 @@ class ImportUC(Model):
} }
patients={} patients={}
for p in get_model("clinic.patient").search_browse([]): for p in get_model("clinic.patient").search_browse([]):
patients[p.hn_num]=p.name patients[p.hn_no]=p.name
if obj.type_id.code=='U': if obj.type_id.code=='U':
fname=obj.file fname=obj.file
@ -52,10 +52,10 @@ class ImportUC(Model):
epoadm=0 epoadm=0
for line in lines: for line in lines:
hn=line.get('hn') hn=line.get('hn')
hn_num=''.join(x for x in hn if x.isdigit()) #XXX hn_no=''.join(x for x in hn if x.isdigit()) #XXX
epoadm=line.get("epoadm") epoadm=line.get("epoadm")
lines2=line.get("epos").get('EPO',[]) lines2=line.get("epos").get('EPO',[])
name='%s %s'%(hn,patients.get(hn_num,"")) name='%s %s'%(hn,patients.get(hn_no,""))
for l2 in lines2: for l2 in lines2:
if type(l2)==type(''): if type(l2)==type(''):
continue continue

View File

@ -67,9 +67,9 @@ class ImportVisit(Model):
raise Exception("Wrong File") raise Exception("Wrong File")
cycles=[(c['id'],'%s:00'%c['time_start'],'%s:00'%c['time_stop']) for c in get_model("clinic.cycle").search_read([[]],['time_start','time_stop'])] cycles=[(c['id'],'%s:00'%c['time_start'],'%s:00'%c['time_stop']) for c in get_model("clinic.cycle").search_read([[]],['time_start','time_stop'])]
patients={} patients={}
field_name=['name','hn','hn_num','department_id','doctor_id'] field_name=['name','hn','hn_no','department_id','doctor_id']
for pt in get_model("clinic.patient").search_read([[]],field_name): for pt in get_model("clinic.patient").search_read([[]],field_name):
hn_num=pt['hn_num'] hn_no=pt['hn_no']
dp=pt['department_id'] dp=pt['department_id']
department_id=None department_id=None
if dp: if dp:
@ -79,7 +79,7 @@ class ImportVisit(Model):
if doctor: if doctor:
doctor_id=doctor[0] doctor_id=doctor[0]
patients[hn_num]={ patients[hn_no]={
'id': pt['id'], 'id': pt['id'],
'hn': pt['hn'], 'hn': pt['hn'],
'department_id': department_id, 'department_id': department_id,
@ -93,13 +93,13 @@ class ImportVisit(Model):
return ''.join(h for h in hn if h.isdigit()) return ''.join(h for h in hn if h.isdigit())
for line in lines: for line in lines:
hn_num=line.get('hn') hn_no=line.get('hn')
hn=get_hn(hn_num) hn=get_hn(hn_no)
date,time=line.get("dttran").split("T") date,time=line.get("dttran").split("T")
patient=patients.get(hn) patient=patients.get(hn)
if not patient: if not patient:
fail_qty+=1 fail_qty+=1
msg+='%s,%s,%s\n'%(hn_num,'','Not found hn') msg+='%s,%s,%s\n'%(hn_no,'','Not found hn')
continue continue
vals={ vals={
'patient_id': patient['id'], 'patient_id': patient['id'],
@ -125,7 +125,7 @@ class ImportVisit(Model):
if not visit_ids: if not visit_ids:
visit_id=get_model('clinic.visit').create(vals) visit_id=get_model('clinic.visit').create(vals)
done_qty+=1 done_qty+=1
msg+='%s,%s,%s\n'%(hn_num,patient['name'],'Create visit %s'%date) msg+='%s,%s,%s\n'%(hn_no,patient['name'],'Create visit %s'%date)
print('create visit %s'%visit_id) print('create visit %s'%visit_id)
obj.write({ obj.write({

View File

@ -32,7 +32,7 @@ class Patient(Model):
res[obj.id]=cycle_id res[obj.id]=cycle_id
return res return res
def _get_hn_num(self,ids,context={}): def _get_hn_no(self,ids,context={}):
res={} res={}
for obj in self.browse(ids): for obj in self.browse(ids):
hn=''.join(x for x in (obj.hn or "") if x.isdigit()) hn=''.join(x for x in (obj.hn or "") if x.isdigit())
@ -42,9 +42,9 @@ class Patient(Model):
_fields={ _fields={
'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True), 'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True),
"number": fields.Char("Number",required=True,search=True), "number": fields.Char("Number",required=True,search=True),
"trt_number": fields.Char("TRT. NO",search=True), "trt_no": fields.Char("TRT. No",search=True),
"hn_no": fields.Char("HN",function="_get_hn_no"),
"hn": fields.Char("REF/HN",search=True), "hn": fields.Char("REF/HN",search=True),
"hn_num": fields.Char("HN Numeric",function="_get_hn_num"),
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
"reg_date": fields.Date("Register Date",required=False,search=True), "reg_date": fields.Date("Register Date",required=False,search=True),
"birthday": fields.Date("Birthday",required=False,search=True), "birthday": fields.Date("Birthday",required=False,search=True),
@ -52,7 +52,7 @@ class Patient(Model):
"mobile": fields.Char("Mobile",required=False,search=True), "mobile": fields.Char("Mobile",required=False,search=True),
"job": fields.Char("Job/Position"), "job": fields.Char("Job/Position"),
"age": fields.Integer("Age", function="_get_age"), "age": fields.Integer("Age", function="_get_age"),
'picture': fields.File("Picture"), 'image': fields.File("Image"),
'email': fields.Char("Email"), 'email': fields.Char("Email"),
"weight": fields.Float("Weight (cm)"), "weight": fields.Float("Weight (cm)"),
"height": fields.Float("Height (Kg)"), "height": fields.Float("Height (Kg)"),
@ -223,27 +223,31 @@ class Patient(Model):
print('remove visit auto %s'%visit_ids) print('remove visit auto %s'%visit_ids)
super().write(ids,vals,**kw) super().write(ids,vals,**kw)
def _name_get(self,ids,context={}): def name_get(self,ids,context={}):
vals=[] vals=[]
for obj in self.browse(ids): for obj in self.browse(ids):
name="%s %s %s"%(obj.number,obj.name, obj.hn) #name="%s [%s]"%(obj.name, obj.hn_no)
name=obj.name or ''
if obj.hn_no:
name+=" (HN: %s)"%obj.hn_no
vals.append((obj.id,name)) vals.append((obj.id,name))
return vals return vals
def name_search(self,name,domain=None,context={},**kw): def name_search(self,name,domain=None,context={},**kw):
dom=[["number","ilike","%"+name+"%"]]
if domain:
dom=[dom,domain]
ids1=self.search(dom)
dom=[["name","ilike","%"+name+"%"]] dom=[["name","ilike","%"+name+"%"]]
if domain: if domain:
dom=[dom,domain] dom=[dom,domain]
ids2=self.search(dom) ids1=self.search(dom)
dom=[["hn","ilike","%"+name+"%"]] dom=[["hn","ilike","%"+name+"%"]]
if domain: if domain:
dom=[dom,domain] dom=[dom,domain]
ids3=self.search(dom) ids2=self.search(dom)
ids=list(set(ids1+ids2+ids3)) ids=list(set(ids1+ids2))
#dom=[["hn","ilike","%"+name+"%"]]
#if domain:
#dom=[dom,domain]
#ids3=self.search(dom)
#ids=list(set(ids1+ids2+ids3))
return self.name_get(ids,context=context) return self.name_get(ids,context=context)
def simple_address(self,ids,context={}): def simple_address(self,ids,context={}):

View File

@ -1,19 +1,23 @@
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
class PatientType(Model): class PatientType(Model):
_name="clinic.patient.type" _name="clinic.patient.type"
_string="Patient Type" _string="Patient Type"
_key=['code','name'] _key=['code','name']
_multi_company=True
_fields={ _fields={
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
"code": fields.Char("Code",required=True,search=True), "code": fields.Char("Code",required=True,search=True),
'contact_id': fields.Many2One("partner","Contact",domain=[['type','=','org']],search=True), 'contact_id': fields.Many2One("partner","Contact",domain=[['type','=','org']],search=True),
'default': fields.Boolean("Default"), 'default': fields.Boolean("Default"),
'company_id': fields.Many2One("company","Company"),
} }
_defaults={ _defaults={
'defaults': False, 'defaults': False,
'company_id': lambda *a: get_active_company(),
} }
def new_contact(self,ids,context={}): def new_contact(self,ids,context={}):

View File

@ -101,7 +101,7 @@ class ReportPaymentMatching(Model):
patient=exp.patient_id patient=exp.patient_id
if obj.type_id.code=='S': if obj.type_id.code=='S':
key='%s:%s:%s:%s:%s'%( key='%s:%s:%s:%s:%s'%(
patient.hn_num, patient.hn_no,
exp.date, exp.date,
exp.fee_amt and exp.fee_amt or 0, exp.fee_amt and exp.fee_amt or 0,
exp.srv_amt and exp.srv_amt or 0, exp.srv_amt and exp.srv_amt or 0,
@ -109,7 +109,7 @@ class ReportPaymentMatching(Model):
) )
else: else:
key='%s:%s:%s'%( key='%s:%s:%s'%(
patient.hn_num, patient.hn_no,
exp.date, exp.date,
exp.fee_amt and exp.fee_amt or 0, exp.fee_amt and exp.fee_amt or 0,
) )

View File

@ -124,24 +124,25 @@ class ScheduleCopy(Model):
get_model("clinic.schedule").delete([eid]) get_model("clinic.schedule").delete([eid])
print("delete ", exist_date) print("delete ", exist_date)
count+=7 # looking for next week if dow is not exist count+=7 # looking for next week if dow is not exist
print("x ", schedules)
if date not in [v['date'] for k,v in exist_date.items()]+[schedule_date]: if date not in [v['date'] for k,v in exist_date.items()]+[schedule_date]:
schedules.append({ schedules.append({
'date': date, 'date': date,
'lines': lines, 'lines': lines,
}) })
else: else:
print("y ", schedules)
# copy to exist nurse # copy to exist nurse
schedules=get_model("clinic.schedule").search_browse([['date','=',date]]) schds=get_model("clinic.schedule").search_browse([['date','=',date]])
print("update lines ", lines) print("update lines ", lines)
if schedules and lines: if schds and lines:
schd=schedules[0] schd=schds[0]
for line in schd.lines: for line in schd.lines:
line.delete() line.delete()
schd.write({'lines': lines}) schd.write({'lines': lines})
start_date=tmp start_date=tmp
for sc in schedules: for sc in schedules:
date=sc['date'] date=sc['date']
sc['time_start']='%s %s'%(date,time_start) sc['time_start']='%s %s'%(date,time_start)

View File

@ -1,8 +1,10 @@
from netforce.model import Model, fields, get_model from netforce.model import Model, fields
from netforce.access import get_active_company
class SettingProduct(Model): class SettingProduct(Model):
_name="clinic.setting.product" _name="clinic.setting.product"
_string="Setting Product" _string="Setting Product"
_multi_company=True
_fields={ _fields={
"setting_id": fields.Many2One("clinic.setting","Setting"), "setting_id": fields.Many2One("clinic.setting","Setting"),
@ -15,11 +17,12 @@ class SettingProduct(Model):
'price': fields.Float("Price"), 'price': fields.Float("Price"),
'qty': fields.Integer("Qty"), 'qty': fields.Integer("Qty"),
'amount': fields.Float("Amount"), 'amount': fields.Float("Amount"),
"account_id": fields.Many2One("account.account","Account",multi_company=True),
'company_id': fields.Many2One("company","Company"),
} }
_defaults={ _defaults={
#'type': 'fee', "company_id": lambda *a: get_active_company(),
#'patient_type': 'sc',
'qty': 1, 'qty': 1,
'reimbursable': 'no', 'reimbursable': 'no',
} }

View File

@ -1,17 +1,43 @@
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
class SickBed(Model): class SickBed(Model):
_name="clinic.sickbed" _name="clinic.sickbed"
_string="Sickbed" _string="Sickbed"
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
hd_case=None
patient_id=None
image=None
date=''
for hd_case in sorted(obj.hd_cases, key=lambda a: a.id):
patient=hd_case.patient_id
patient_id=patient.id
image=patient.image
date=hd_case.date
res[obj.id]={
'patient_id': patient_id,
'image': image,
'date': date,
}
return res
_fields={ _fields={
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
"available": fields.Boolean("Available"), "available": fields.Boolean("Available"),
'hd_cases': fields.One2Many("clinic.hd.case",'sickbed_id','HDCases'), 'hd_cases': fields.One2Many("clinic.hd.case",'sickbed_id','HDCases'),
'company_id': fields.Many2One("company","Company"),
'patient_id': fields.Many2One("clinic.patient","Lasted Patient",function="_get_all",function_multi=True),
'image': fields.File("Image",function="_get_all",function_multi=True),
'date': fields.Date("Date",function="_get_all",function_multi=True),
"state": fields.Selection([("available","Available"),("not_available","Not Available")],"Status"),
} }
_defaults={ _defaults={
'available': True, 'available': True,
"company_id": lambda *a: get_active_company(),
} }
def copy(self,ids,context={}): def copy(self,ids,context={}):

View File

@ -84,7 +84,7 @@ class Staff(Model):
"doctor_visits": fields.One2Many("clinic.visit","doctor_id","Visits"), "doctor_visits": fields.One2Many("clinic.visit","doctor_id","Visits"),
"company_id": fields.Many2One("company","Company"), "company_id": fields.Many2One("company","Company"),
"user_id": fields.Many2One("base.user","User"), "user_id": fields.Many2One("base.user","User"),
'picture': fields.File("Picture"), 'image': fields.File("Image"),
'note': fields.Text("Note"), 'note': fields.Text("Note"),
'categ_id': fields.Many2One("clinic.staff.categ", "Category"), 'categ_id': fields.Many2One("clinic.staff.categ", "Category"),
'level_id': fields.Many2One("clinic.staff.level", "Level", function="_get_level"), 'level_id': fields.Many2One("clinic.staff.level", "Level", function="_get_level"),

View File

@ -5,6 +5,7 @@ class StaffCategory(Model):
_name="clinic.staff.categ" _name="clinic.staff.categ"
_string="Staff Category" _string="Staff Category"
_key=["name"] _key=["name"]
_multi_company=True
_fields={ _fields={
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),

View File

@ -5,12 +5,14 @@ class StaffLevel(Model):
_name="clinic.staff.level" _name="clinic.staff.level"
_string="Staff Level" _string="Staff Level"
_key=["name"] _key=["name"]
_multi_company=True
_fields={ _fields={
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
'description': fields.Text("Description", search=True), 'description': fields.Text("Description", search=True),
'sequence': fields.Integer("Sequence"), 'sequence': fields.Integer("Sequence"),
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),("nurse","Nurse")],"Staff Type",required=True, search=True), "type": fields.Selection([('staff','Staff'),("doctor","Doctor"),("nurse","Nurse")],"Staff Type",required=True, search=True),
'company_id': fields.Many2One("company","Company"),
} }
_defaults={ _defaults={

View File

@ -4,6 +4,7 @@ from netforce.access import get_active_company
class StaffRotation(Model): class StaffRotation(Model):
_name="clinic.staff.rotation" _name="clinic.staff.rotation"
_string="Staff Rotation" _string="Staff Rotation"
_multi_company=True
_fields={ _fields={
"staff_id": fields.Many2One("clinic.staff","Staff", search=True), "staff_id": fields.Many2One("clinic.staff","Staff", search=True),

View File

@ -19,11 +19,16 @@ class Visit(Model):
res[obj.id]=datetime.now().strftime("%Y-%m-%d %H:%M:%S") res[obj.id]=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return res return res
def _get_color(self,ids,context={}): def _get_all(self,ids,context={}):
res={} res={}
for obj in self.browse(ids): for obj in self.browse(ids):
color=get_model("clinic.cycle").browse(obj.cycle_id.id).color cycle=obj.cycle_id
res[obj.id]=color color=cycle.color
res[obj.id]={
'cycle_color': color,
'sequence': '%s-%s'%(obj.time_start[0:10],cycle.sequence), #date-sequence
'visit_date': obj.time_start[0:10]
}
return res return res
_fields={ _fields={
@ -38,13 +43,13 @@ class Visit(Model):
"company_id": fields.Many2One("company","Company"), "company_id": fields.Many2One("company","Company"),
'hd_cases': fields.One2Many('clinic.hd.case','visit_id',"HD Cases",readonly=True), 'hd_cases': fields.One2Many('clinic.hd.case','visit_id',"HD Cases",readonly=True),
"cycle_id": fields.Many2One("clinic.cycle","Cycle"), "cycle_id": fields.Many2One("clinic.cycle","Cycle"),
'cycle_color': fields.Char('Color',function="_get_color"),
"state": fields.Selection([["draft","Draft"],['pending','Pending'],["confirmed","Confirmed"],["cancelled","Cancelled"]],"Status",required=True), "state": fields.Selection([["draft","Draft"],['pending','Pending'],["confirmed","Confirmed"],["cancelled","Cancelled"]],"Status",required=True),
"comments": fields.One2Many("message","related_id","Comments"), "comments": fields.One2Many("message","related_id","Comments"),
'visit_date': fields.Date('Visit Date'),
'print_date': fields.Date('Print Date',function="_get_print_date"), 'print_date': fields.Date('Print Date',function="_get_print_date"),
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), #XXX on_delete="cascade" -> rm visit from cycle item 'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), #XXX on_delete="cascade" -> rm visit from cycle item
'sequence': fields.Char("Sequence"), 'sequence': fields.Char("Sequence",function="_get_all",function_multi=True,store=True),
'visit_date': fields.Date('Visit Date',function="_get_all",function_multi=True,store=True),
'cycle_color': fields.Char('Color',function="_get_all",function_multi=True,store=True),
'note': fields.Text('Note'), 'note': fields.Text('Note'),
} }
@ -393,15 +398,6 @@ class Visit(Model):
'flash': 'Generate number succesfully', 'flash': 'Generate number succesfully',
} }
def create(self, vals,**kw):
cycle_id=vals['cycle_id']
cycle=get_model("clinic.cycle").browse(cycle_id)
vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle.sequence) #date-sequence
vals['visit_date']=vals['time_start'][0:10]
new_id=super().create(vals,**kw)
print('create visit ', new_id)
return new_id
def cancel(self,ids,context={}): def cancel(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
obj.write({ obj.write({
@ -416,12 +412,14 @@ 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):
new_id=super().create(vals,**kw)
self.function_store([new_id])
return new_id
def write(self,ids,vals,**kw): def write(self,ids,vals,**kw):
obj=self.browse(ids)[0]
cycle=obj.cycle_id
vals['sequence']='%s-%s'%(obj.time_start[0:10],cycle.sequence) #date-sequence
vals['visit_date']=obj.time_start[0:10]
super().write(ids,vals,**kw) super().write(ids,vals,**kw)
self.function_store(ids)
def pending(self,ids,context={}): def pending(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]

View File

@ -1,5 +1,12 @@
===== =====
- get account id by product -bug
- generate schedule
- copy nurse
- create duplicate
- import
- check name
- get account id by product -> ok
- access right control
===== =====
create button reset at setting create button reset at setting