From f8521a2e161ccd316c1d6065487ed9958a2bab16 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Wed, 8 Apr 2015 14:32:19 +0700 Subject: [PATCH] prevent to duplicate enter account product/patient --- .../layouts/clinic_account_menu.xml | 2 +- .../clinic_report_labor_cost_summary.xml | 2 +- netforce_clinic/models/labor_cost.py | 11 ++++--- .../models/report_labor_cost_summary.py | 2 +- netforce_clinic/models/setting.py | 17 ++++++++-- .../models/setting_account_patient.py | 7 ++-- .../models/setting_account_product.py | 10 +++--- .../templates/report_labor_cost.hbs | 2 +- .../templates/report_labor_cost_summary.hbs | 32 ++++++++++++------- 9 files changed, 56 insertions(+), 29 deletions(-) diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml index 881f7ed..f48c160 100644 --- a/netforce_clinic/layouts/clinic_account_menu.xml +++ b/netforce_clinic/layouts/clinic_account_menu.xml @@ -11,7 +11,7 @@
- + diff --git a/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml b/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml index 6b11d67..3f2452b 100644 --- a/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml +++ b/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml @@ -6,7 +6,7 @@ - + diff --git a/netforce_clinic/models/labor_cost.py b/netforce_clinic/models/labor_cost.py index 3f9aa35..c610734 100644 --- a/netforce_clinic/models/labor_cost.py +++ b/netforce_clinic/models/labor_cost.py @@ -59,7 +59,10 @@ class LaborCost(Model): total_stcost=0.0 for line in obj.staff_lines: total_stcost+=line.amount or 0.0 - #XXX + total_ncost=round(total_ncost,0) + total_dcost=round(total_dcost,0) + total_stcost=round(total_stcost,0) + total_formular=round(total_formular,0) total=total_ncost+total_dcost+total_stcost res[obj.id]={ 'var_pt': total_case, @@ -69,10 +72,10 @@ class LaborCost(Model): 'var_fml3': '(%s%s)/%s'%(var_ptx,total_bstr,total_a), 'var_x': round(var_x,2), 'total': total, - 'total_formular': round(total_formular,0), - 'total_ncost': round(total_ncost,0), + 'total_formular': total_formular, + 'total_ncost': total_ncost, 'total_nqty': total_nqty, - 'total_dcost': round(total_dcost,0), + 'total_dcost': total_dcost, 'total_dqty': total_dqty, 'total_stcost': total_stcost, } diff --git a/netforce_clinic/models/report_labor_cost_summary.py b/netforce_clinic/models/report_labor_cost_summary.py index d258e7e..e954c3e 100644 --- a/netforce_clinic/models/report_labor_cost_summary.py +++ b/netforce_clinic/models/report_labor_cost_summary.py @@ -99,7 +99,6 @@ class ReportLaborCostSummary(Model): citems={} print('dom ', dom) total_hdcase=0 - x=set() for line in get_model("clinic.labor.cost.line").search_browse(dom): lcost=line.labor_cost_id citem=lcost.cycle_item_id @@ -245,6 +244,7 @@ class ReportLaborCostSummary(Model): 'total_lines': total_lines, 'total_hdcase': total_hdcase or 0, 'total_cost': round(total_cost,0) or 0, + 'staff_type': staff_type, } return data diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 1d28f8c..b907814 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -20,8 +20,16 @@ DAYS={ class ClinicSetting(Model): _name="clinic.setting" _string="Setting" + _field_name="var_k" + + def _get_name(self,ids,context={}): + res={} + for obj in self.browse(ids): + res[obj.id]='xxx' + return res _fields={ + 'name': fields.Char("Name", function="_get_name"), "var_k": fields.Float("K"), 'signature': fields.File("Signature"), 'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"), @@ -152,11 +160,16 @@ class ClinicSetting(Model): if user_id !=1: print("Only admin!!") return - path='/tmp/test' - self.update_pcycle(path,['ls1.csv','ls2.csv','ls3.csv']) + #path='/tmp/test' + #self.update_pcycle(path,['ls1.csv','ls2.csv','ls3.csv']) ###TODO remove douplicate patient ###TODO remove douplicate staff ###TODO remove douplicate visit + obj=self.browse(ids)[0] + for ap_line in obj.account_patients: + pt=ap_line.patient_id + if not pt: + ap_line.delete() print("Done!") def multi_department(self,ids,context={}): diff --git a/netforce_clinic/models/setting_account_patient.py b/netforce_clinic/models/setting_account_patient.py index 8e56c12..e607581 100644 --- a/netforce_clinic/models/setting_account_patient.py +++ b/netforce_clinic/models/setting_account_patient.py @@ -7,9 +7,9 @@ class SettingAccountPatient(Model): _fields={ "setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"), - "patient_id": fields.Many2One("clinic.patient","Patient",domain=[["state","=","admit"]], search=True), - 'partner_id': fields.Many2One("partner","Contact", search=True), - 'type_id': fields.Many2One("clinic.patient.type","Type", search=True), + "patient_id": fields.Many2One("clinic.patient","Patient",domain=[["state","=","admit"]], search=True,required=True), + 'partner_id': fields.Many2One("partner","Contact", search=True,required=True), + 'type_id': fields.Many2One("clinic.patient.type","Type", search=True,required=True), 'hn': fields.Char("HN", search=True), 'card_no': fields.Char("ID Card",size=13, search=True), 'company_id': fields.Many2One("company","Company"), @@ -18,6 +18,7 @@ class SettingAccountPatient(Model): 'setting_id': 1, "company_id": lambda *a: get_active_company(), } + _sql_constraints=("clinic_setting_acc_pt_key_uniq","unique(patient_id,partner_id,type_id,hn,card_no)","account patient should be unique"), _order="type_id,patient_id" SettingAccountPatient.register() diff --git a/netforce_clinic/models/setting_account_product.py b/netforce_clinic/models/setting_account_product.py index 2a8c327..720a173 100644 --- a/netforce_clinic/models/setting_account_product.py +++ b/netforce_clinic/models/setting_account_product.py @@ -8,20 +8,20 @@ class SettingAccountProduct(Model): _fields={ "setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"), - "patient_type_id": fields.Many2One("clinic.patient.type","Patient Type",search=True), - 'categ_id': fields.Many2One("product.categ","Category",search=True), - "product_id": fields.Many2One("product","Product",search=True), + "patient_type_id": fields.Many2One("clinic.patient.type","Patient Type",search=True,required=True), + 'categ_id': fields.Many2One("product.categ","Category",search=True,required=True), + "product_id": fields.Many2One("product","Product",search=True,required=True), "ar_credit_id": fields.Many2One("account.account","Income Credit",multi_company=True,search=True), "ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True,search=True), + "type": fields.Selection([("cash","Cash"),("credit","Credit")],"Type",search=True,required=True), 'company_id': fields.Many2One("company","Company"), - "type": fields.Selection([("cash","Cash"),("credit","Credit")],"Type",search=True), } _defaults={ "company_id": lambda *a: get_active_company(), 'setting_id': 1, } - + _sql_constraints=("clinic_setting_acc_prod_key_uniq","unique(patient_type_id,categ_id,product_id,ar_credit_id,ar_debit_id,type)","account product should be unique"), _order="patient_type_id" SettingAccountProduct.register() diff --git a/netforce_clinic/templates/report_labor_cost.hbs b/netforce_clinic/templates/report_labor_cost.hbs index 4a17efb..669da25 100644 --- a/netforce_clinic/templates/report_labor_cost.hbs +++ b/netforce_clinic/templates/report_labor_cost.hbs @@ -9,7 +9,7 @@ - + {{#each lines }} diff --git a/netforce_clinic/templates/report_labor_cost_summary.hbs b/netforce_clinic/templates/report_labor_cost_summary.hbs index c8834b9..c58a599 100644 --- a/netforce_clinic/templates/report_labor_cost_summary.hbs +++ b/netforce_clinic/templates/report_labor_cost_summary.hbs @@ -20,12 +20,16 @@ - - - - {{#each dpts}} - - {{/each}} + {{#ifeq staff_type "nurse"}} + + + + {{else}} + + {{/ifeq}} + {{#each dpts}} + + {{/each}} @@ -35,11 +39,17 @@ - + + {{/ifeq}} {{#each sub_lines}}
ชั้นจำนวน HD Caseรวม
# รหัสชื่อ-สกุลตำแหน่งหมวดหมู่{{name}}ชื่อ-สกุลตำแหน่งหมวดหมู่ชื่อ-สกุล{{name}} รวม
{{no}} {{number}} - - {{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}} - {{staff_level}} - {{categ_name}} + {{#ifeq ../staff_type "nurse"}} + + {{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}} + {{staff_level}} + {{categ_name}} + {{else}} + + {{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}} + {{currency amt zero=""}}