From ab9920aab5088b39f7038a7f0f9148cd5e60c233 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Sun, 8 Feb 2015 15:48:08 +0700 Subject: [PATCH] nurse category --- .../actions/clinic_report_labor_cost.xml | 8 -- .../clinic_report_labor_cost_summary.xml | 8 ++ .../layouts/clinic_cycle_item_form.xml | 3 +- .../layouts/clinic_labor_cost_entry_form.xml | 6 +- .../layouts/clinic_labor_cost_form.xml | 12 +-- .../layouts/clinic_menu_inherit.xml | 4 +- ...l => clinic_report_labor_cost_summary.xml} | 2 +- netforce_clinic/layouts/clinic_staff_form.xml | 4 +- netforce_clinic/layouts/clinic_staff_list.xml | 2 +- netforce_clinic/models/__init__.py | 2 +- netforce_clinic/models/account_payment.py | 28 ++++++- netforce_clinic/models/cycle_item.py | 2 + netforce_clinic/models/cycle_item_copy.py | 2 +- netforce_clinic/models/cycle_item_line.py | 1 + netforce_clinic/models/labor_cost.py | 12 +-- netforce_clinic/models/labor_cost_entry.py | 19 +++-- .../models/labor_cost_entry_line.py | 1 + netforce_clinic/models/labor_cost_line.py | 2 +- ...r_cost.py => report_labor_cost_summary.py} | 31 ++++---- netforce_clinic/models/setting.py | 73 ++++++++++--------- netforce_clinic/models/staff.py | 2 +- netforce_clinic/models/visit.py | 6 +- ...cost.hbs => report_labor_cost_summary.hbs} | 8 +- 23 files changed, 138 insertions(+), 100 deletions(-) delete mode 100644 netforce_clinic/actions/clinic_report_labor_cost.xml create mode 100644 netforce_clinic/actions/clinic_report_labor_cost_summary.xml rename netforce_clinic/layouts/{clinic_report_labor_cost.xml => clinic_report_labor_cost_summary.xml} (81%) rename netforce_clinic/models/{report_labor_cost.py => report_labor_cost_summary.py} (86%) rename netforce_clinic/templates/{report_labor_cost.hbs => report_labor_cost_summary.hbs} (77%) diff --git a/netforce_clinic/actions/clinic_report_labor_cost.xml b/netforce_clinic/actions/clinic_report_labor_cost.xml deleted file mode 100644 index ffb141e..0000000 --- a/netforce_clinic/actions/clinic_report_labor_cost.xml +++ /dev/null @@ -1,8 +0,0 @@ - - Report Labor Cost - report - clinic.report.labor.cost - report_labor_cost - report_labor_cost - account_menu - diff --git a/netforce_clinic/actions/clinic_report_labor_cost_summary.xml b/netforce_clinic/actions/clinic_report_labor_cost_summary.xml new file mode 100644 index 0000000..1a2b810 --- /dev/null +++ b/netforce_clinic/actions/clinic_report_labor_cost_summary.xml @@ -0,0 +1,8 @@ + + Report Labor Cost Summary + report + clinic.report.labor.cost.summary + report_labor_cost_summary + report_labor_cost_summary + account_menu + diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml index 39e721f..e27459a 100644 --- a/netforce_clinic/layouts/clinic_cycle_item_form.xml +++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml @@ -22,7 +22,8 @@ - + + diff --git a/netforce_clinic/layouts/clinic_labor_cost_entry_form.xml b/netforce_clinic/layouts/clinic_labor_cost_entry_form.xml index f19a2f9..8cd1fdd 100644 --- a/netforce_clinic/layouts/clinic_labor_cost_entry_form.xml +++ b/netforce_clinic/layouts/clinic_labor_cost_entry_form.xml @@ -12,7 +12,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_labor_cost_form.xml b/netforce_clinic/layouts/clinic_labor_cost_form.xml index 93ec199..ef561ed 100644 --- a/netforce_clinic/layouts/clinic_labor_cost_form.xml +++ b/netforce_clinic/layouts/clinic_labor_cost_form.xml @@ -5,12 +5,6 @@ - @@ -46,9 +40,7 @@ - - - + @@ -61,7 +53,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_menu_inherit.xml b/netforce_clinic/layouts/clinic_menu_inherit.xml index c004c4f..c5110a7 100644 --- a/netforce_clinic/layouts/clinic_menu_inherit.xml +++ b/netforce_clinic/layouts/clinic_menu_inherit.xml @@ -2,14 +2,12 @@ - -
- + diff --git a/netforce_clinic/layouts/clinic_report_labor_cost.xml b/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml similarity index 81% rename from netforce_clinic/layouts/clinic_report_labor_cost.xml rename to netforce_clinic/layouts/clinic_report_labor_cost_summary.xml index 8eb9e93..6e0a2c6 100644 --- a/netforce_clinic/layouts/clinic_report_labor_cost.xml +++ b/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml @@ -1,4 +1,4 @@ -
+ diff --git a/netforce_clinic/layouts/clinic_staff_form.xml b/netforce_clinic/layouts/clinic_staff_form.xml index c8a30b4..b7c8daa 100644 --- a/netforce_clinic/layouts/clinic_staff_form.xml +++ b/netforce_clinic/layouts/clinic_staff_form.xml @@ -1,6 +1,6 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_staff_list.xml b/netforce_clinic/layouts/clinic_staff_list.xml index 9d7ee65..e8db363 100644 --- a/netforce_clinic/layouts/clinic_staff_list.xml +++ b/netforce_clinic/layouts/clinic_staff_list.xml @@ -15,5 +15,5 @@ - + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 57b13e4..3b65837 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -74,7 +74,7 @@ from . import report_staff_fee from . import report_staff_fee_detail from . import report_staff_fee_sum from . import report_payment_matching -from . import report_labor_cost +from . import report_labor_cost_summary from . import branch from . import period from . import period_line diff --git a/netforce_clinic/models/account_payment.py b/netforce_clinic/models/account_payment.py index d394292..ae216b2 100644 --- a/netforce_clinic/models/account_payment.py +++ b/netforce_clinic/models/account_payment.py @@ -108,7 +108,33 @@ class AccountPayment(Model): 'credit': rvals['credit'], "track_id": track_id, })) - lines=lines1+lines2 #debit, credit + + if obj.type=="in": + rate_type="sell" + else: + rate_type="buy" + adjust_lines=[] + adjust_amt=0 + for jline in obj.adjust_lines: + cur_amt=get_model("currency").convert(line.amount,obj.currency_id.id,settings.currency_id.id,date=obj.date,rate_type=rate_type) + tax_base=get_model("currency").convert(line.tax_base or 0,obj.currency_id.id,settings.currency_id.id,date=obj.date,rate_type=rate_type) + cur_amt=abs(cur_amt) + adjust_lines.append(('create',{ + "move_id": move_id, + "description": desc, + "account_id": line.account_id.id, + "tax_comp_id": line.tax_comp_id.id, + "tax_base": tax_base, + "track_id": line.track_id.id, + "partner_id": obj.partner_id.id, + "credit":0, + "debit": cur_amt, + })) + #XXX + adjust_amt+=cur_amt + lines1[0][1]['debit']-=cur_amt + + lines=lines1+adjust_lines+lines2 #debit, debit, credit move=get_model("account.move").browse(move_id) move.write({ 'lines': lines, diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py index 19ccf3b..d68062c 100644 --- a/netforce_clinic/models/cycle_item.py +++ b/netforce_clinic/models/cycle_item.py @@ -139,6 +139,7 @@ class CycleItem(Model): nurse_id=line['nurse_id'] nurse=get_model('clinic.staff').browse(nurse_id) line['level_id']=nurse.level_id.id + line['categ_id']=nurse.categ_id.id return data def view_schedule(self,ids,context={}): @@ -201,6 +202,7 @@ class CycleItem(Model): lines.append(('create',{ 'nurse_id': nurse.id, 'level_id': level.id, + 'categ_id': nurse.categ_id.id, })) for line in obj.lines: line.delete() diff --git a/netforce_clinic/models/cycle_item_copy.py b/netforce_clinic/models/cycle_item_copy.py index e9e8536..cea004d 100644 --- a/netforce_clinic/models/cycle_item_copy.py +++ b/netforce_clinic/models/cycle_item_copy.py @@ -84,7 +84,7 @@ class CycleItemCopy(Model): lines.append(('create', { 'nurse_id': nr.id, 'level_id': nr.level_id.id, - 'state': nr.state, + 'categ_id': nr.categ_id.id, })) item.write({ 'lines': lines, diff --git a/netforce_clinic/models/cycle_item_line.py b/netforce_clinic/models/cycle_item_line.py index b467f40..39eb443 100644 --- a/netforce_clinic/models/cycle_item_line.py +++ b/netforce_clinic/models/cycle_item_line.py @@ -10,6 +10,7 @@ class CycleItemLine(Model): 'nurse_id': fields.Many2One("clinic.staff",'Nurse',domain=[['type','=','nurse']]), 'department_id': fields.Many2One("clinic.department","Department"), "state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True), + 'categ_id': fields.Many2One("clinic.staff.categ",'Category',domain=[['type','=','nurse']]), } CycleItemLine.register() diff --git a/netforce_clinic/models/labor_cost.py b/netforce_clinic/models/labor_cost.py index 6ba440a..28031f0 100644 --- a/netforce_clinic/models/labor_cost.py +++ b/netforce_clinic/models/labor_cost.py @@ -269,7 +269,7 @@ class LaborCost(Model): 'cycle_id': item.cycle_id.id, 'staff_id': nurse.id, 'level_id': level_id, - 'state': nurse.state, + 'categ_id': nurse.categ_id.id, 'rate': rate, 'type': 'nurse', 'qty': 1, @@ -292,7 +292,7 @@ class LaborCost(Model): staff_total[staff.id]={ 'base': 0, 'type': staff.type, - 'state': staff.state, + 'categ_id': staff.categ_id.id, 'level_id': staff.level_id.id, 'qty': 0, } @@ -307,12 +307,12 @@ class LaborCost(Model): type=value['type'] qty=value['qty'] level_id=value['level_id'] - state=value['state'] + categ_id=value['categ_id'] lines.append(('create',{ 'cycle_id': item.cycle_id.id, 'staff_id': doctor_id, 'level_id': level_id, - 'state': state, + 'categ_id': categ_id, 'rate': base, 'qty': qty, 'type': type, @@ -333,7 +333,7 @@ class LaborCost(Model): staff_id=vals['staff_id'] rate=vals['rate'] or 0 qty=vals['qty'] or 0 - state=vals['state'] + categ_id=vals['categ_id'] amount=qty*rate key=(cycle_id,staff_id) if not key in glines.keys(): @@ -344,7 +344,7 @@ class LaborCost(Model): 'qty': qty, 'type': vals['type'], 'description': vals.get("description",""), - 'state': state, + 'categ_id': categ_id, } continue glines[key]['amount']+=amount diff --git a/netforce_clinic/models/labor_cost_entry.py b/netforce_clinic/models/labor_cost_entry.py index f8fb063..a81be28 100644 --- a/netforce_clinic/models/labor_cost_entry.py +++ b/netforce_clinic/models/labor_cost_entry.py @@ -49,7 +49,8 @@ class LaborCostEntry(Model): "lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Lines"), "nurse_lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Nurse Lines",domain=[['type','=','nurse']]), "doctor_lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Doctor Lines",domain=[['type','=','doctor']]), - "work_state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True), + #"work_state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True), + 'categ_id': fields.Many2One("clinic.staff.categ", "Category",search=True), "state": fields.Selection([["draft","Draft"],["approved","Approved"]],"Status"), 'user_id': fields.Many2One("base.user","Approver",search=True), 'note': fields.Text("Note"), @@ -91,8 +92,8 @@ class LaborCostEntry(Model): dom.append(['labor_cost_id.cycle_item_id.branch_id','=',obj.branch_id.id]) if obj.department_id: dom.append(['labor_cost_id.cycle_item_id.department_id','=',obj.department_id.id]) - if obj.work_state: - dom.append(['staff_id.state','=',obj.work_state]) + if obj.categ_id: + dom.append(['staff_id.categ_id','=',obj.categ_id.id]) for lc_id in get_model("clinic.labor.cost.line").search(dom): line_ids.append(lc_id) staffs={} @@ -100,7 +101,8 @@ class LaborCostEntry(Model): staff=line.staff_id qty=line.qty amt=line.amount - state=line.state or staff.state + #state=line.state or staff.state + categ=line.categ_id dpt=staff.department_id citem=line.labor_cost_id.cycle_item_id if not dpt: @@ -112,7 +114,8 @@ class LaborCostEntry(Model): 'qty': 0, 'amt': 0, 'rate': 0, # XXX for special nurse - 'state': state, + #'state': state, + 'categ_id': categ.id, 'report_staff_id': get_model("clinic.report.staff").create({ 'date_from': obj.date_from, 'date_to': obj.date_to, @@ -130,7 +133,8 @@ class LaborCostEntry(Model): for staff_id, vals in staffs.items(): qty=vals['qty'] or 0 amt=vals['amt'] or 0.0 - state=vals['state'] + #state=vals['state'] + categ_id=vals['categ_id'] report_staff_id=vals['report_staff_id'] report_staff=get_model("clinic.report.staff").browse(report_staff_id) @@ -178,7 +182,8 @@ class LaborCostEntry(Model): 'amount': amt, 'date': timenow, 'rate': rate, - 'state': state, + #'state': state, + 'categ_id': categ_id, 'department_id': vals['department_id'], 'report_staff_id': report_staff.id, })) diff --git a/netforce_clinic/models/labor_cost_entry_line.py b/netforce_clinic/models/labor_cost_entry_line.py index 66b8984..67f35c9 100644 --- a/netforce_clinic/models/labor_cost_entry_line.py +++ b/netforce_clinic/models/labor_cost_entry_line.py @@ -39,6 +39,7 @@ class LaborCostEntryLine(Model): 'max_cycle': fields.Integer("Max Cycle", function="_get_all",function_multi=True), 'over_cycle': fields.Integer("Over Cycle", function="_get_all",function_multi=True), 'report_staff_id2': fields.Many2One("clinic.report.staff","#PT",function="_get_all",function_multi=True), + 'categ_id': fields.Many2One("clinic.staff.categ",'Category'), } _order="type" diff --git a/netforce_clinic/models/labor_cost_line.py b/netforce_clinic/models/labor_cost_line.py index dc4e63c..6cdc6ef 100644 --- a/netforce_clinic/models/labor_cost_line.py +++ b/netforce_clinic/models/labor_cost_line.py @@ -18,7 +18,7 @@ class LaborCostLine(Model): 'date': fields.Date("Date",search=True), 'description': fields.Char("Description"), 'company_id': fields.Many2One('company','Company'), - "state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True), + 'categ_id': fields.Many2One("clinic.staff.categ", "Category",domain=[['type','=','nurse']],search=True), } _defaults={ diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost_summary.py similarity index 86% rename from netforce_clinic/models/report_labor_cost.py rename to netforce_clinic/models/report_labor_cost_summary.py index c3d872e..295a0f0 100644 --- a/netforce_clinic/models/report_labor_cost.py +++ b/netforce_clinic/models/report_labor_cost_summary.py @@ -4,9 +4,9 @@ from calendar import monthrange from netforce.model import Model,fields,get_model from netforce.access import get_active_company -class ReportLaborCost(Model): - _name="clinic.report.labor.cost" - _string="Report Labor Cost" +class ReportLaborCostSummary(Model): + _name="clinic.report.labor.cost.summary" + _string="Report Labor Cost Summary" _transient=True _fields={ @@ -52,6 +52,7 @@ class ReportLaborCost(Model): if _type: dom.append(['type','=',_type]) staffs={} + print('dom ', dom) for line in get_model("clinic.labor.cost.line").search_browse(dom): lcost=line.labor_cost_id citem=lcost.cycle_item_id @@ -62,15 +63,19 @@ class ReportLaborCost(Model): staffs[staff.name]={ dpt.name: { 'type': staff.type, - 'amt': 0, + 'amt': amt, }, } - if not staffs[staff.name].get(dpt.name): - staffs[staff.name][dpt.name]={ - 'type': staff.type, - 'amt': 0, - } - staffs[staff.name][dpt.name]['amt']+=amt + else: + #XXX bug + if not staffs[staff.name].get(dpt.name): + staffs[staff.name][dpt.name]={ + 'type': staff.type, + 'amt': amt, + } + #if staffs.get(staff.name): + #if staffs[staff.name].get(dpt.name): + #staffs[staff.name][dpt.name]['amt']+=amt lines=[] dpts=get_model("clinic.department").search_read([],['name']) @@ -123,8 +128,8 @@ class ReportLaborCost(Model): total_lines.append({'amt': total}) data={ 'title': title, - 'date_from': obj.date_from, - 'date_to': obj.date_to, + 'date_from': date_from, + 'date_to': date_to, 'dpts': dpts, 'comp_name': comp.name or 0, 'comp_span': len(dpts), @@ -142,4 +147,4 @@ class ReportLaborCost(Model): data['date_to']="%s-%s-%s"%(year,month,total_day) return data -ReportLaborCost.register() +ReportLaborCostSummary.register() diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 7075c14..45f16c6 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -109,45 +109,50 @@ class ClinicSetting(Model): print("Only admin!!") return obj=self.browse(1) - t={} - [t.update({x.code : x.id}) for x in get_model("clinic.patient.type").search_browse([])] - for prod in get_model("product").search_browse([]): - code=prod.code or "" - tcodes=code.split("-") - tids=[] - for tcode in tcodes: - tid=t.get(tcode,None) - if tid: - tids.append(tid) + categs={} + for ct in get_model("clinic.staff.categ").search_read([['type','=','nurse']],['name']): + categs[ct['name']]=ct['id'] - prod.write({ - 'patient_types': [('add',tids)] + for cline in get_model("clinic.cycle.item.line").search_browse([]): + nr=cline.nurse_id + st=nr.state or "" + if st=='part_time': + st='Part Time' + elif st=='full_time': + st='Full Time' + else: + st='Others' + ct_id=categs.get(st,None) + cline.write({ + 'categ_id': ct_id, }) - for line in obj.account_products: - acc=line.ar_debit_id - type='credit' - if acc: - if acc.code=='101101': - type='cash' - line.write({ - 'type': type, + for cline in get_model("clinic.labor.cost.line").search_browse([]): + staff=cline.staff_id + st=staff.state or "" + if st=='part_time': + st='Part Time' + elif st=='full_time': + st='Full Time' + else: + st='Others' + ct_id=categs.get(st,None) + cline.write({ + 'categ_id': ct_id, }) - - print("Update product completed!") - for vs in get_model("clinic.visit").search_browse([['state','in', ['draft','pending']],['doctor_id','=',None]]): - doctor=vs.patient_id.doctor_id - if doctor: - vs.write({ - 'doctor_id': doctor.id, - }) - print("update visit.date ", vs.visit_date) - print("Update visit completed!") - for shop in get_model("clinic.shop").search_browse([]): - shop.write({ - 'company_id': 1, + + for staff in get_model("clinic.staff").search_browse([]): + st=staff.state + if st=='part_time': + st='Part Time' + elif st=='full_time': + st='Full Time' + else: + st='Others' + ct_id=categs.get(st,None) + staff.write({ + 'categ_id': ct_id, }) - print("Update shop completed!") print("Done! ") def reset_last_import(self,ids,context={}): diff --git a/netforce_clinic/models/staff.py b/netforce_clinic/models/staff.py index a24b309..28f97b5 100644 --- a/netforce_clinic/models/staff.py +++ b/netforce_clinic/models/staff.py @@ -100,7 +100,7 @@ class Staff(Model): "user_id": fields.Many2One("base.user","User",search=True), 'image': fields.File("Image"), 'note': fields.Text("Note"), - 'categ_id': fields.Many2One("clinic.staff.categ", "Category"), + 'categ_id': fields.Many2One("clinic.staff.categ", "Category",search=True), 'level_id': fields.Many2One("clinic.staff.level", "Level", function="_get_level"), 'active': fields.Boolean("Active"), 'date': fields.Date("Register Date"), diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py index c7899c2..0ea6ef0 100644 --- a/netforce_clinic/models/visit.py +++ b/netforce_clinic/models/visit.py @@ -258,7 +258,8 @@ class Visit(Model): item_vals['lines'].append(('create',{ 'nurse_id': nurse.id, 'level_id': nurse.level_id.id, - 'state': nurse.state, + #'state': nurse.state, + 'categ_id': nurse.categ_id.id, })) item.write(item_vals) @@ -276,7 +277,8 @@ class Visit(Model): lines.append(('create', { 'nurse_id': nr.id, 'level_id': nr.level_id.id, - 'state': nr.state, + #'state': nr.state, + 'categ_id': nr.categ_id.id, })) if lines: print("copy nurse from %s to %s"%(item2.name, item.name)) diff --git a/netforce_clinic/templates/report_labor_cost.hbs b/netforce_clinic/templates/report_labor_cost_summary.hbs similarity index 77% rename from netforce_clinic/templates/report_labor_cost.hbs rename to netforce_clinic/templates/report_labor_cost_summary.hbs index c780c3e..a2c0ca2 100644 --- a/netforce_clinic/templates/report_labor_cost.hbs +++ b/netforce_clinic/templates/report_labor_cost_summary.hbs @@ -10,7 +10,7 @@ {{#each dpts}} - {{name}} + {{name}} {{/each}} @@ -24,9 +24,9 @@ {{no}} {{staff_name}} {{#each sub_lines}} - {{amt}} + {{currency amt zero=""}} {{/each}} - {{total}} + {{currency total zero=""}} {{/each}} @@ -34,7 +34,7 @@ {{#each total_lines}} - {{amt}} + {{currency amt zero=""}} {{/each}}