From 1a542dd3602d3bf9122685008f6f4205bdf934bb Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Mon, 24 Nov 2014 08:28:46 +0700 Subject: [PATCH] order create line of cycle dialy by seq of cycle --- .../layouts/clinic_cycle_dialy_form.xml | 1 + netforce_clinic/layouts/clinic_menu.xml | 9 +++++++-- netforce_clinic/models/cycle_dialy.py | 15 +++++++++++---- netforce_clinic/models/cycle_item.py | 8 +++++++- netforce_clinic/todo.txt | 1 + 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/netforce_clinic/layouts/clinic_cycle_dialy_form.xml b/netforce_clinic/layouts/clinic_cycle_dialy_form.xml index 6b8abb0..bc256ab 100644 --- a/netforce_clinic/layouts/clinic_cycle_dialy_form.xml +++ b/netforce_clinic/layouts/clinic_cycle_dialy_form.xml @@ -3,6 +3,7 @@ diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 8db377d..7f25e33 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -14,6 +14,7 @@ + @@ -29,8 +30,6 @@ - -
@@ -43,10 +42,16 @@ +
+ +
+ + + diff --git a/netforce_clinic/models/cycle_dialy.py b/netforce_clinic/models/cycle_dialy.py index 1e61d69..574ef04 100644 --- a/netforce_clinic/models/cycle_dialy.py +++ b/netforce_clinic/models/cycle_dialy.py @@ -57,19 +57,26 @@ class CycleDialy(Model): 'flash':'Confirmed', } - def post(self,ids,context={}): - # create journal entry + def recheck_item(self,ids,context={}): + # copy cost of nurse and doctor from cycle item obj=self.browse(ids)[0] + lines=[] + ctx=context.copy() + context['called']=True + # sorted by sequence of cycle + for cycle_item in sorted(obj.cycle_items, key=lambda x: x.cycle_id.sequence): + lines+=cycle_item.validate(context=context) obj.write({ - 'state': 'done', + 'lines': lines, }) + context=ctx return { 'next': { 'name': 'clinic_cycle_dialy', 'mode': 'form', 'active_id': obj.id, }, - 'flash':'Done!', + 'flash':'Recheck successfully', } def to_draft(self,ids,context={}): diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py index bbf9bcb..43dc67d 100644 --- a/netforce_clinic/models/cycle_item.py +++ b/netforce_clinic/models/cycle_item.py @@ -143,6 +143,8 @@ class CycleItem(Model): personals=hd_case.personals for ps in personals: personal=ps.personal_id + if not personal: + continue base=personal.base if not base: base=cost_per_case @@ -209,7 +211,11 @@ class CycleItem(Model): } line.update(vals) lines.append(('create',line)) - + + # call from outside + if context.get('called'): + return lines + cycle_dialy.write({ 'lines': lines, }) diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index b0ec302..e070d3b 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,4 +1,5 @@ ======= + - add picture of patient to visit/hd case dialy - cycle dialy - lines - order by cycle