decrease use time (dlz)

conv_bal
watcha.h@almacom.co.th 2015-01-15 13:32:52 +07:00
parent bac0f31a6b
commit bf98e00c42
4 changed files with 34 additions and 18 deletions

View File

@ -24,7 +24,10 @@
<group span="6" columns="1">
</group>
<group span="6" columns="1">
<separator string="Note: Use time will count automatic after finish HD Case."/>
<template>
<div><b>Note:</b> 'Use time' will count automatic after finish HD Case.</div>
</template>
<!--<separator string="Note: 'Use time' will count automatic after finish HD Case."/>-->
</group>
<foot>
<button string="Confirm" type="success" states="new" method="confirm"/>

View File

@ -147,7 +147,6 @@ class HDCase(Model):
"date": lambda *a: time.strftime("%Y-%m-%d"),
"time_start": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
"time_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
#"number": _get_number,
'number': '/',
"company_id": lambda *a: get_active_company(),
'wt_start': 0.0,
@ -603,15 +602,21 @@ class HDCase(Model):
def update_usetime(self,ids,context={}):
for obj in self.browse(ids):
is_decrease=context.get('is_decrease')
for dlz_line in obj.dialyzers:
dlz=dlz_line.dialyzer_id
use_time=dlz_line.use_time or 0
if is_decrease:
use_time-=use_time
print("decrease ok")
print("use_time ", use_time)
if dlz_line.use_time < dlz.max_use_time:
dlz.write({
'use_time': dlz_line.use_time,
'use_time': use_time,
})
elif dlz_line.use_time==dlz.max_use_time:
dlz.write({
'use_time': dlz_line.use_time,
'use_time': use_time,
'state': 'expire',
})
else:
@ -625,7 +630,15 @@ class HDCase(Model):
if not datenow:
datenow=time.strftime('%Y-%m-%d')
cycle_id=obj.cycle_id.id
cycle_item_ids=cycle_item.search([['date','=',datenow],['cycle_id','=',cycle_id]])
branch_id=obj.branch_id.id
dom=[]
if datenow:
dom.append(['date','=',datenow])
if cycle_id:
dom.append(['cycle_id','=',cycle_id])
if branch_id:
dom.append(['branch_id','=',branch_id])
cycle_item_ids=cycle_item.search(dom)
cycle_item_id=None
if cycle_item_ids:
cycle_item_id=cycle_item_ids[0]
@ -680,7 +693,6 @@ class HDCase(Model):
obj=self.browse(ids)[0]
obj.make_invoices(context=context)
obj.post_invoices(context=context)
obj.update_usetime()
obj.create_cycle_item()
obj.do_expense(context=context)
vals={
@ -727,6 +739,8 @@ class HDCase(Model):
def undo(self,ids,context={}):
obj=self.browse(ids)[0]
context['is_decrease']=True
obj.update_usetime(context=context)
for line in obj.lines:
line.write({
'state': 'draft',
@ -778,8 +792,7 @@ class HDCase(Model):
def request_fee(self,ids,context={}):
obj=self.browse(ids)[0]
obj.update_usetime()
#if not obj.amount:
#obj.update_usetime()
obj.complete()
# send some message to anyboby: patient
return {
@ -800,6 +813,7 @@ class HDCase(Model):
def done(self,ids,context={}):
obj=self.browse(ids)[0]
obj.update_usetime()
obj.write({
'state': 'completed',
})

View File

@ -49,10 +49,10 @@ class HDCasePayment(Model):
vals={
'state': 'paid',
}
#hd_case.update_usetime()
else:
vals={
'state': 'waiting_payment',
#'req_fee': 1, # show pay button
}
hd_case.write(vals)
hd_case.do_expense()
@ -75,11 +75,7 @@ class HDCasePayment(Model):
hd_case.make_invoices(context=context)
hd_case.post_invoices()
hd_case.create_cycle_item()
#if obj.pay_amount==obj.to_pay:
#vals={
#'state': 'paid',
#}
#hd_case.write(vals)
#hd_case.update_usetime()
hd_case.do_expense()
return {
'next': {

View File

@ -200,9 +200,12 @@ class Visit(Model):
cycle=obj.cycle_id
branch=obj.branch_id
dom=[]
dom.append(['date','=',date])
dom.append(['cycle_id','=',cycle.id])
dom.append(['branch_id','=',branch.id])
if date:
dom.append(['date','=',date])
if cycle:
dom.append(['cycle_id','=',cycle.id])
if branch:
dom.append(['branch_id','=',branch.id])
item_obj=get_model('clinic.cycle.item')
item_ids=item_obj.search(dom)
@ -233,6 +236,7 @@ class Visit(Model):
for nurse in item.nurses:
nurse.delete()
# get nurse from schedule
item=item_obj.browse(item_id)
if item.state!='draft':
schedule=get_schedule(date)
@ -392,7 +396,6 @@ class Visit(Model):
line.delete()
for ps in hd_case.staffs:
ps.delete()
#hd_case.delete()
obj.write({
'state': 'draft',
})