From 5673bc37f2d19483ec8caaa1acdc6accec28e9c9 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Thu, 27 Nov 2014 13:04:20 +0700 Subject: [PATCH] xxxx --- .../layouts/clinic_cycle_daily_form.xml | 1 + netforce_clinic/layouts/clinic_staff_form.xml | 13 +++++++------ netforce_clinic/layouts/clinic_staff_list.xml | 2 ++ netforce_clinic/models/cycle_daily.py | 19 +++++++++++++++++-- netforce_clinic/models/cycle_monthly_line.py | 4 ++++ netforce_clinic/models/patient.py | 2 +- netforce_clinic/models/staff.py | 5 +++-- 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/netforce_clinic/layouts/clinic_cycle_daily_form.xml b/netforce_clinic/layouts/clinic_cycle_daily_form.xml index 1a941ab..1bb97f7 100644 --- a/netforce_clinic/layouts/clinic_cycle_daily_form.xml +++ b/netforce_clinic/layouts/clinic_cycle_daily_form.xml @@ -4,6 +4,7 @@ diff --git a/netforce_clinic/layouts/clinic_staff_form.xml b/netforce_clinic/layouts/clinic_staff_form.xml index 446d19e..4514f6f 100644 --- a/netforce_clinic/layouts/clinic_staff_form.xml +++ b/netforce_clinic/layouts/clinic_staff_form.xml @@ -5,20 +5,21 @@ + + + + + + + - - - - - - diff --git a/netforce_clinic/layouts/clinic_staff_list.xml b/netforce_clinic/layouts/clinic_staff_list.xml index 0922e3e..d1516a4 100644 --- a/netforce_clinic/layouts/clinic_staff_list.xml +++ b/netforce_clinic/layouts/clinic_staff_list.xml @@ -1,6 +1,8 @@ + + diff --git a/netforce_clinic/models/cycle_daily.py b/netforce_clinic/models/cycle_daily.py index 713ed84..24a971f 100644 --- a/netforce_clinic/models/cycle_daily.py +++ b/netforce_clinic/models/cycle_daily.py @@ -24,6 +24,7 @@ class CycleDaily(Model): "name": fields.Char("Name"), 'date': fields.Date("Date", required=True, search=True), 'cycle_items': fields.One2Many("clinic.cycle.item","cycle_daily_id", "Cycle Items"), + 'cycle_monthly_id': fields.Many2One("clinic.cycle.monthly","Monthly"), 'lines': fields.One2Many("clinic.cycle.daily.line","cycle_daily_id", "Lines"), "state": fields.Selection([("draft","Draft"),('confirmed','Confirmed')],"Status",required=True), 'company_id': fields.Many2One("company","Company"), @@ -50,7 +51,8 @@ class CycleDaily(Model): obj.write({ 'state': 'confirmed', }) - # TODO create cycle monthly + + # TODO create/update cycle monthly all_vals={} for line in obj.lines: staff=line.staff_id @@ -61,6 +63,7 @@ class CycleDaily(Model): all_vals[staff.id]={ 'level_id': level.id, 'type': line.type, + 'date': obj.date, 'qty': 0, 'amount': 0, } @@ -81,7 +84,8 @@ class CycleDaily(Model): mid=res[0]['id'] monthly=mobj.browse(mid) for line in monthly.lines: - line.delete() + if line.date==obj.date: + line.delete() monthly.write({ 'lines': lines, }) @@ -152,5 +156,16 @@ class CycleDaily(Model): total+=qty*rate data['total']=total return data + + def view_cycle_monthly(self,ids,context): + obj=self.browse(ids)[0] + monthly=obj.cycle_monthly_id + return { + 'next': { + 'name': 'clinic_monthly', + 'mode': 'form', + 'active_id': monthly.id, + }, + } CycleDaily.register() diff --git a/netforce_clinic/models/cycle_monthly_line.py b/netforce_clinic/models/cycle_monthly_line.py index eade95e..50a3cf5 100644 --- a/netforce_clinic/models/cycle_monthly_line.py +++ b/netforce_clinic/models/cycle_monthly_line.py @@ -1,3 +1,5 @@ +import time + from netforce.model import Model, fields from netforce.access import get_active_company @@ -9,6 +11,7 @@ class CycleMonthlyLine(Model): "cycle_monthly_id": fields.Many2One("clinic.cycle.monthly","Cycle Monthly"), 'staff_id': fields.Many2One("clinic.staff", "Staff"), 'level_id': fields.Many2One("clinic.staff.level", "Level"), + 'date': fields.Date("Date"), 'qty': fields.Integer("Qty"), 'rate': fields.Float("Rate"), 'amount': fields.Float("Amount"), @@ -18,6 +21,7 @@ class CycleMonthlyLine(Model): _defaults={ 'company_id': lambda *a: get_active_company(), + 'date': lambda *a: time.strftime("%Y-%m-%d"), } diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 79e07f3..0ace877 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -14,7 +14,7 @@ class Patient(Model): _string="Patient" _audit_log=True _multi_company=True - _key=["number,name"] + _key=['name'] def _get_age(self,ids,context): res={} diff --git a/netforce_clinic/models/staff.py b/netforce_clinic/models/staff.py index 8b41ac8..bc93a45 100644 --- a/netforce_clinic/models/staff.py +++ b/netforce_clinic/models/staff.py @@ -8,7 +8,7 @@ class Staff(Model): _string="Staff" _audit_log=True _multi_company=True - _key=["name"] + _key=["number","name"] def _get_age(self,ids,context={}): res={} @@ -56,7 +56,7 @@ class Staff(Model): _fields={ 'employee_id': fields.Many2One("hr.employee","Employee"), - "number": fields.Char("Ref.",required=True,search=True), + "number": fields.Char("Number",required=True,search=True), "name": fields.Char("Name",required=True,search=True), "name_eng": fields.Char("Eng Name",search=True), "nick_name": fields.Char("Nick Name",search=True), @@ -98,6 +98,7 @@ class Staff(Model): "rotations": fields.One2Many("clinic.staff.rotation","staff_id","Staff Rotation"), "cycles": fields.One2Many("clinic.staff.cycle","staff_id","Cycles"), 'cycle_id': fields.Many2One('clinic.cycle','Last Cycle',function="_get_cycle"), + 'branch_id': fields.Many2One("clinic.branch","Branch"), } def _get_number(self,context={}):