diff --git a/netforce_clinic/layouts/clinic_cycle_dialy_list.xml b/netforce_clinic/layouts/clinic_cycle_dialy_list.xml index e84e9aa..2531bce 100644 --- a/netforce_clinic/layouts/clinic_cycle_dialy_list.xml +++ b/netforce_clinic/layouts/clinic_cycle_dialy_list.xml @@ -1,4 +1,4 @@ - + diff --git a/netforce_clinic/layouts/clinic_personal_form.xml b/netforce_clinic/layouts/clinic_personal_form.xml index 11c7cb0..288478c 100644 --- a/netforce_clinic/layouts/clinic_personal_form.xml +++ b/netforce_clinic/layouts/clinic_personal_form.xml @@ -41,6 +41,7 @@ + @@ -69,7 +70,8 @@ - + + diff --git a/netforce_clinic/layouts/clinic_personal_move_form.xml b/netforce_clinic/layouts/clinic_personal_move_form.xml index c7846a2..ee21c80 100644 --- a/netforce_clinic/layouts/clinic_personal_move_form.xml +++ b/netforce_clinic/layouts/clinic_personal_move_form.xml @@ -6,5 +6,6 @@ + diff --git a/netforce_clinic/layouts/clinic_personal_move_list.xml b/netforce_clinic/layouts/clinic_personal_move_list.xml index cadc581..e2183ee 100644 --- a/netforce_clinic/layouts/clinic_personal_move_list.xml +++ b/netforce_clinic/layouts/clinic_personal_move_list.xml @@ -5,6 +5,7 @@ + diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py index b48998c..1b744e1 100644 --- a/netforce_clinic/models/cycle_item.py +++ b/netforce_clinic/models/cycle_item.py @@ -168,6 +168,32 @@ class CycleItem(Model): if obj.cycle_id.id==cycle.id: # only own cycle line.delete() + # group personal and cycle date + glines={} + for line in lines: + mode,vals=line + cycle_id=vals['cycle_id'] + personal_id=vals['personal_id'] + paid_amount=vals['paid_amount'] or 0 + key=(cycle_id,personal_id) + if not key in glines.keys(): + glines[key]={ + 'paid_amount': paid_amount, + 'type': vals['type'], + } + continue + glines[key]['paid_amount']+=paid_amount + + lines=[] + for key,vals in glines.items(): + cycle_id,personal_id=key + line={ + 'cycle_id': cycle_id, + 'personal_id': personal_id, + } + line.update(vals) + lines.append(('create',line)) + cycle_dialy.write({ 'lines': lines, }) diff --git a/netforce_clinic/models/personal.py b/netforce_clinic/models/personal.py index 0ff227c..b88028b 100644 --- a/netforce_clinic/models/personal.py +++ b/netforce_clinic/models/personal.py @@ -43,9 +43,14 @@ class Personal(Model): res={} for obj in self.browse(ids): base=0 + max_cycle=0 for mv in obj.moves: base=mv.wage - res[obj.id]=base + max_cycle=mv.max_cycle + res[obj.id]={ + 'base': base, + 'max_cycle': max_cycle, + } return res _fields={ @@ -83,7 +88,8 @@ class Personal(Model): 'level_id': fields.Many2One("clinic.personal.level", "Personal Level", function="_get_level"), 'active': fields.Boolean("Active"), 'date': fields.Date("Register Date"), - 'base': fields.Float("Base Amount", function="_get_base"), + 'base': fields.Float("Base Amount", function="_get_base",function_multi=True), + 'max_cycle': fields.Integer("Max Cycle", function="_get_base",function_multi=True), 'hire_date': fields.Date("Hire Date"), 'resign_date': fields.Date("Resign Date"), "documents": fields.One2Many("document","related_id","Documents"), diff --git a/netforce_clinic/models/personal_move.py b/netforce_clinic/models/personal_move.py index a436b55..1c2e35d 100644 --- a/netforce_clinic/models/personal_move.py +++ b/netforce_clinic/models/personal_move.py @@ -13,6 +13,7 @@ class PersonalMove(Model): "hire_date": fields.Date("Hire Date", search=True), "resign_date": fields.Date("Resign Date", search=True), "wage": fields.Float("Wage"), + "max_cycle": fields.Integer("Max Cycle"), "note": fields.Text("Note"), 'company_id': fields.Many2One("company","Company"), } diff --git a/netforce_clinic/models/report_clinic.py b/netforce_clinic/models/report_clinic.py index b8ccd11..f9350c2 100644 --- a/netforce_clinic/models/report_clinic.py +++ b/netforce_clinic/models/report_clinic.py @@ -1,3 +1,5 @@ +import time + from netforce.model import Model from netforce.database import get_connection from netforce.access import get_active_company @@ -9,7 +11,11 @@ class Report(Model): def cycle_recent_widget(self,context={}): db=get_connection() company_id=get_active_company() - res=db.query("select count(cycle_id) as count, c.name from clinic_hd_case as hd inner join clinic_cycle as c on c.id=hd.cycle_id where hd.company_id=%s group by c.name",company_id) + #datenow=time.strftime("%Y-%m-%d") + #time_start='%s 00:00:00'%(datenow) + #time_stop='%s 23:59:59'%(datenow) + #res=db.query("select count(cycle_id) as count, c.name from clinic_hd_case as hd inner join clinic_cycle as c on c.id=hd.cycle_id where hd.company_id =%s and hd.date >= %s and hd.date <= %s group by c.name",company_id,time_start,time_stop) + res=db.query("select count(cycle_id) as count, c.name from clinic_hd_case as hd inner join clinic_cycle as c on c.id=hd.cycle_id where hd.company_id =%s group by c.name",company_id) data=[] for r in res: data.append((r.name,r.count))