From ba6adec61166bcd0e63da630de5a29946778986c Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Wed, 26 Nov 2014 23:04:58 +0700 Subject: [PATCH] fix bug --- .../layouts/clinic_cycle_item_form.xml | 3 ++- netforce_clinic/layouts/clinic_menu.xml | 4 ++-- netforce_clinic/models/cycle_item.py | 21 ++++++++++++++++--- netforce_clinic/models/schedule.py | 16 +++++++------- netforce_clinic/models/setting_level.py | 2 +- netforce_clinic/models/setting_product.py | 2 +- 6 files changed, 33 insertions(+), 15 deletions(-) diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml index e88c1cc..6e9e412 100644 --- a/netforce_clinic/layouts/clinic_cycle_item_form.xml +++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml @@ -5,6 +5,7 @@ + @@ -30,7 +31,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 48af121..396acfa 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -18,8 +18,8 @@ -
- +
+ diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py index 2710ee3..51cbb90 100644 --- a/netforce_clinic/models/cycle_item.py +++ b/netforce_clinic/models/cycle_item.py @@ -231,7 +231,7 @@ class CycleItem(Model): 'mode': 'form', 'active_id': cycle_dialy.id, }, - 'flash': 'Cycle Item has been confirmed, please see detail of cost below.', + 'flash': 'Cycle Item has been validated, please see the detail of cost below.', } def to_draft(self,ids,context={}): @@ -254,8 +254,11 @@ class CycleItem(Model): } } levels.update(vals) - for nurse in obj.nurses: - level=nurse.level_id + + for ns in obj.nurses: + level=ns.level_id + if not level: + raise Exception("Please specify level for %s"%ns.nurse_id.name) levels[level.id]['total']+=1 st_levels={} @@ -403,6 +406,18 @@ class CycleItem(Model): 'active_id': schedule_id, } } + + def view_cycle_dialy(self,ids,context={}): + obj=self.browse(ids)[0] + if not obj.cycle_dialy_id: + raise Exception("Please validate cycle item") + return { + 'next': { + 'name': 'clinic_cycle_dialy', + 'mode': 'form', + 'active_id': obj.cycle_dialy_id.id, + } + } def load_nurse_from_schedule(self,ids,context={}): obj=self.browse(ids)[0] diff --git a/netforce_clinic/models/schedule.py b/netforce_clinic/models/schedule.py index 236b47b..bb5dce0 100644 --- a/netforce_clinic/models/schedule.py +++ b/netforce_clinic/models/schedule.py @@ -107,17 +107,19 @@ class Schedule(Model): for line in obj.lines: nurse=line.nurse_id cycle=line.cycle_id - item_ids=get_model("clinic.cycle.item").search([['date','=',date],['cycle_id','=',cycle.id],['state','=','draft']]) - if item_ids: - item_id=item_ids[0] - if not items.get(item_id): - items[item_id]=[] - items[item_id].append(('create',{ + item_objs=get_model("clinic.cycle.item").search_browse([['date','=',date],['cycle_id','=',cycle.id]]) + if item_objs: + item=item_objs[0] + if item.state!='draft': + continue + if not items.get(item.id): + items[item.id]=[] + items[item.id].append(('create',{ 'nurse_id': nurse.id, 'level_id': nurse.level_id.id, })) line.write({ - 'cycle_item_id': item_id, + 'cycle_item_id': item.id, }) cycles.update({cycle.name}) else: diff --git a/netforce_clinic/models/setting_level.py b/netforce_clinic/models/setting_level.py index 4b70836..a9913ad 100644 --- a/netforce_clinic/models/setting_level.py +++ b/netforce_clinic/models/setting_level.py @@ -14,7 +14,7 @@ class SettingLevel(Model): "setting_id": fields.Many2One("clinic.setting","Setting"), "level_id": fields.Many2One("clinic.staff.level","Level",domain=[['type','=','nurse']]), 'var_a': fields.Char("Ax"), - "op": fields.Selection([["+","+"],["-","-"],["*","*"],["/","/"]],"Operation"), + "op": fields.Selection([["+","+"],["-","-"]],"Operation"), 'var_b': fields.Char("B"), 'formular': fields.Text("Formular (Ax op B)",function="_get_formular"), } diff --git a/netforce_clinic/models/setting_product.py b/netforce_clinic/models/setting_product.py index 817d761..f5faf70 100644 --- a/netforce_clinic/models/setting_product.py +++ b/netforce_clinic/models/setting_product.py @@ -6,7 +6,7 @@ class SettingProduct(Model): _fields={ "setting_id": fields.Many2One("clinic.setting","Setting"), - "type": fields.Selection([("fee","FEE"),("others","Others")],"Type",required=True), + "type": fields.Selection([("fee","Fee"),("others","Others")],"Type",required=True), "patient_type": fields.Selection([("sc","Social Security"),("uc","UC"),("others","Others")],"Patient Type",required=True), 'uom_id': fields.Many2One("uom","UOM", required=True), "product_id": fields.Many2One("product","Product"),