should enter product if have fee charge

stable
watcha.h 2016-02-11 14:07:42 +07:00
parent 02aa22a844
commit 4fa63302e1
3 changed files with 16 additions and 5 deletions

View File

@ -64,7 +64,7 @@
</tab> </tab>
<tab string="Expense"> <tab string="Expense">
<group span="12" form_layout="stacked"> <group span="12" form_layout="stacked">
<field name="lines" count="3" nolabel="1"> <field name="lines" count="3" nolabel="1" attrs='{"readonly":[["state","in",["waiting_payment","completed","paid"]]]}'>
<list> <list>
<field name="product_categ_id" onchange="onchange_line"/> <field name="product_categ_id" onchange="onchange_line"/>
<field name="product_id" domain='[["categ_id.id","=",product_categ_id],["patient_types.id","=",parent.patient_type_id]]' onchange="onchange_product"/> <field name="product_id" domain='[["categ_id.id","=",product_categ_id],["patient_types.id","=",parent.patient_type_id]]' onchange="onchange_product"/>
@ -100,9 +100,8 @@
</group> </group>
</tab> </tab>
<tab string="Doctors"> <tab string="Doctors">
<field name="staffs" nolabel="1"> <field name="staffs" nolabel="1" attrs='{"readonly":[["state","=","completed"]]}'>
<list> <list>
<!--<field name="type" invisible="1"/>-->
<field name="staff_id" onchange="onchange_staff" domain="[['type','=','doctor']]"/> <field name="staff_id" onchange="onchange_staff" domain="[['type','=','doctor']]"/>
<field name="priop"/> <field name="priop"/>
<field name="note"/> <field name="note"/>

View File

@ -6,4 +6,4 @@
#from . import del_gi #from . import del_gi
#from . import restore_picking #from . import restore_picking
#from . import rename_dbl_hdcase_number #from . import rename_dbl_hdcase_number
from . import reset_hdcase_number #from . import reset_hdcase_number

View File

@ -1150,10 +1150,22 @@ class HDCase(Model):
def done(self,ids,context={}): def done(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
if obj.patient_type_id.code=='SSO': if obj.patient_type_id.code=='SSO':
cond1=False
cond2=False
for line in obj.lines: for line in obj.lines:
prod=line.product_id prod=line.product_id
categ=line.product_categ_id
# force to enter unit price
if not line.price and prod: if not line.price and prod:
raise Exception("Can not complete HDCase because price of product %s is missing!"%(prod.name)) raise Exception("Missing unit price for product [%s] %s!"%(prod.code,prod.name))
elif not prod and categ.code=='EPO':
cond2=True
if categ.code=='FEE' and line.price:
cond1=True
# if fee and not enter product then hdcase should not finish
if cond1 and cond2:
raise Exception("%s is missing product"%(categ.name))
count=0 count=0
for sline in obj.staffs: for sline in obj.staffs:
if sline.staff_id: if sline.staff_id: