dpt & branch (need sharing setting for each nurse)

conv_bal
watcha.h@almacom.co.th 2015-01-16 22:34:20 +07:00
parent e177f2744f
commit b8ff75b412
9 changed files with 40 additions and 19 deletions

View File

@ -1,10 +1,10 @@
<list model="clinic.hd.case" colors='{"#cfc":[["state","=","completed"]],"#f9e37d":[["state","=","in_progress"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]],"#70DB93":[["state","=","paid"]]}'> <list model="clinic.hd.case" colors='{"#cfc":[["state","=","completed"]],"#f9e37d":[["state","=","in_progress"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]],"#70DB93":[["state","=","paid"]]}'>
<field name="number"/> <field name="number"/>
<field name="date"/> <field name="date"/>
<field name="cycle_id"/>
<field name="patient_id"/> <field name="patient_id"/>
<field name="patient_type_id"/> <field name="patient_type_id"/>
<field name="sickbed_id"/> <field name="sickbed_id"/>
<field name="cycle_id"/>
<field name="department_id"/> <field name="department_id"/>
<field name="doctor_id"/> <field name="doctor_id"/>
<field name="state"/> <field name="state"/>

View File

@ -12,6 +12,8 @@
<tab string="General"> <tab string="General">
<group form_layout="stacked"> <group form_layout="stacked">
<field name="date" span="3" onchange="onchange_date"/> <field name="date" span="3" onchange="onchange_date"/>
<field name="department_id" span="3"/>
<field name="branch_id" span="3"/>
<field name="lines" nolabel="1"> <field name="lines" nolabel="1">
<list> <list>
<field name="cycle_id"/> <field name="cycle_id"/>
@ -22,7 +24,6 @@
</list> </list>
</field> </field>
<field name="company_id" invisible="1"/> <field name="company_id" invisible="1"/>
<field name="branch_id" invisible="1"/>
</group> </group>
</tab> </tab>
<tab string="Planning"> <tab string="Planning">

View File

@ -1,5 +1,7 @@
<list model="clinic.schedule"> <list model="clinic.schedule">
<field name="date"/> <field name="date"/>
<field name="department_id"/>
<field name="branch_id"/>
<field name="user_id"/> <field name="user_id"/>
<field name="state"/> <field name="state"/>
</list> </list>

View File

@ -11,7 +11,7 @@
<field name="name_eng"/> <field name="name_eng"/>
<field name="nick_name"/> <field name="nick_name"/>
<field name="branch_id" required="1"/> <field name="branch_id" required="1"/>
<field name="department_id"/> <field name="department_id" required="1"/>
<field name="company_id" invisible="1"/> <field name="company_id" invisible="1"/>
<tabs> <tabs>
<tab string="General"> <tab string="General">

View File

@ -1,7 +1,9 @@
<search model="clinic.visit"> <search model="clinic.visit">
<field name="visit_date"/>
<field name="number"/> <field name="number"/>
<field name="patient_id"/> <field name="patient_id"/>
<field name="doctor_id"/> <field name="doctor_id"/>
<field name="visit_date"/>
<field name="cycle_id"/> <field name="cycle_id"/>
<field name="department_id"/>
<field name="branch_id"/>
</search> </search>

View File

@ -20,7 +20,7 @@ class CycleItem(Model):
name="%s-%s"%(cycle_name,obj.date) name="%s-%s"%(cycle_name,obj.date)
res[obj.id]={ res[obj.id]={
'name': name, 'name': name,
'sequence':'%s-%s'%(obj.date,cycle.sequence), 'sequence':'%s-%s-%s-%s'%(obj.date,cycle.sequence,obj.branch_id.id,obj.department_id.id),
} }
return res return res

View File

@ -632,6 +632,7 @@ class HDCase(Model):
datenow=time.strftime('%Y-%m-%d') datenow=time.strftime('%Y-%m-%d')
cycle_id=obj.cycle_id.id cycle_id=obj.cycle_id.id
branch_id=obj.branch_id.id branch_id=obj.branch_id.id
department_id=obj.department_id.id
dom=[] dom=[]
if datenow: if datenow:
dom.append(['date','=',datenow]) dom.append(['date','=',datenow])
@ -639,6 +640,8 @@ class HDCase(Model):
dom.append(['cycle_id','=',cycle_id]) dom.append(['cycle_id','=',cycle_id])
if branch_id: if branch_id:
dom.append(['branch_id','=',branch_id]) dom.append(['branch_id','=',branch_id])
if department_id:
dom.append(['department_id','=',department_id])
cycle_item_ids=cycle_item.search(dom) cycle_item_ids=cycle_item.search(dom)
cycle_item_id=None cycle_item_id=None
if cycle_item_ids: if cycle_item_ids:
@ -646,7 +649,9 @@ class HDCase(Model):
else: else:
cycle_item_id=cycle_item.create({ cycle_item_id=cycle_item.create({
'date': obj.date, 'date': obj.date,
'cycle_id': obj.cycle_id.id, 'cycle_id': cycle_id,
'branch_id': branch_id,
'department_id': department_id,
}) })
obj.write({ obj.write({
'cycle_item_id': cycle_item_id, 'cycle_item_id': cycle_item_id,

View File

@ -90,18 +90,25 @@ class ScheduleCopy(Model):
time_start=obj.schedule_id.time_start[11:] time_start=obj.schedule_id.time_start[11:]
time_stop=obj.schedule_id.time_stop[11:] time_stop=obj.schedule_id.time_stop[11:]
exist_date={} exist_date={}
for r in get_model("clinic.schedule").search_read([['date','>=',obj.date_from],['date','<=',(date_to+timedelta(days=8)).strftime(FMT_DATE)]],['date','state']): dom=[]
dom.append(['date','>=',obj.date_from])
dom.append(['date','<=',(date_to+timedelta(days=8)).strftime(FMT_DATE)])
branch=schedule.branch_id
department=schedule.department_id
if branch:
dom.append(['branch_id','=',branch.id])
if department:
dom.append(['department_id','=',department.id])
for r in get_model("clinic.schedule").search_read(dom,['date','state']):
exist_date.update({ exist_date.update({
r['date']:{ r['date']:{
'id': r['id'], 'id': r['id'],
'date': r['date'], 'date': r['date'],
'state': r['state'] 'state': r['state'],
'branch_id': branch.id,
'department_id': department.id,
}}) }})
print('exist date')
print("="*50)
for k,v in exist_date.items():
print(k)
print("="*50)
for weekday in days: for weekday in days:
wd=date_from.weekday() wd=date_from.weekday()
start_date=date_from start_date=date_from
@ -125,17 +132,21 @@ class ScheduleCopy(Model):
get_model("clinic.schedule").delete([eid]) get_model("clinic.schedule").delete([eid])
print("delete ", exist_date) print("delete ", exist_date)
count+=7 # looking for next week if dow is not exist count+=7 # looking for next week if dow is not exist
print("x ", schedules)
if date not in [v['date'] for k,v in exist_date.items()]+[schedule_date]: if date not in [v['date'] for k,v in exist_date.items()]+[schedule_date]:
schedules.append({ schedules.append({
'date': date, 'date': date,
'branch_id': branch.id,
'department_id': department.id,
'lines': lines, 'lines': lines,
}) })
else: else:
print("y ", schedules) print("copy to exist nurse ", lines)
# copy to exist nurse dom2=[['date','=',date]]
schds=get_model("clinic.schedule").search_browse([['date','=',date]]) if branch:
print("update lines ", lines) dom2.append(['branch_id','=',branch.id])
if department:
dom2.append(['department_id','=',department.id])
schds=get_model("clinic.schedule").search_browse(dom2)
if schds and lines: if schds and lines:
schd=schds[0] schd=schds[0]
for line in schd.lines: for line in schd.lines:

View File

@ -47,7 +47,7 @@ class Visit(Model):
'print_date': fields.Date('Print Date',function="_get_print_date"), 'print_date': fields.Date('Print Date',function="_get_print_date"),
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), #XXX on_delete="cascade" -> rm visit from cycle item 'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), #XXX on_delete="cascade" -> rm visit from cycle item
'sequence': fields.Char("Sequence",function="_get_all",function_multi=True,store=True), 'sequence': fields.Char("Sequence",function="_get_all",function_multi=True,store=True),
'visit_date': fields.Date('Visit Date'), 'visit_date': fields.Date('Date'),
'cycle_color': fields.Char('Color',function="_get_all",function_multi=True,store=True), 'cycle_color': fields.Char('Color',function="_get_all",function_multi=True,store=True),
'note': fields.Text('Note'), 'note': fields.Text('Note'),
'branch_id': fields.Many2One("clinic.branch","Branch"), 'branch_id': fields.Many2One("clinic.branch","Branch"),