improve hd case staff

conv_bal
watcha.h@almacom.co.th 2015-05-06 22:23:16 +07:00
parent 168badd98f
commit d7743fb6fc
2 changed files with 14 additions and 1 deletions

View File

@ -1,4 +1,9 @@
<form model="clinic.hd.case.staff"> <form model="clinic.hd.case.staff">
<head>
<button string="Options" dropdown="1">
<item string="Recompute Labor Cost" method="recompute_cost"/>
</button>
</head>
<field name="hd_case_id"/> <field name="hd_case_id"/>
<field name="type"/> <field name="type"/>
<field name="staff_id"/> <field name="staff_id"/>

View File

@ -1,6 +1,6 @@
import time import time
from netforce.model import Model, fields from netforce.model import Model, fields, get_model
class HDCaseStaff(Model): class HDCaseStaff(Model):
_name="clinic.hd.case.staff" _name="clinic.hd.case.staff"
@ -42,5 +42,13 @@ class HDCaseStaff(Model):
'date': lambda *a: time.strftime("%Y-%m-%d"), 'date': lambda *a: time.strftime("%Y-%m-%d"),
} }
def recompute_cost(self,ids,context={}):
obj=self.browse(ids)[0]
hdcase=obj.hd_case_id
citem=hdcase.cycle_item_id
for lc in get_model('clinic.labor.cost').search_browse([['cycle_item_id','=',citem.id]]):
lc.compute()
print("Done!")
HDCaseStaff.register() HDCaseStaff.register()