fee profile
parent
6e39dbb31c
commit
e2c8e36c56
|
@ -27,6 +27,7 @@
|
||||||
<field name="bp_stop"/>
|
<field name="bp_stop"/>
|
||||||
<field name="per_bp_stop"/>
|
<field name="per_bp_stop"/>
|
||||||
<field name="hct" onchange="onchange_hct"/>
|
<field name="hct" onchange="onchange_hct"/>
|
||||||
|
<field name="nu"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field offset="2" name="hct_msg" nolabel="1" readonly="1"/>
|
<field offset="2" name="hct_msg" nolabel="1" readonly="1"/>
|
||||||
<field name="dialyzers" nolabel="1">
|
<field name="dialyzers" nolabel="1">
|
||||||
|
@ -46,13 +47,13 @@
|
||||||
<tab string="Expenses">
|
<tab string="Expenses">
|
||||||
<field name="lines" count="3" nolabel="1">
|
<field name="lines" count="3" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="type" onchange="onchange_line"/>
|
<field name="type"/>
|
||||||
<field name="product_id" onchange="onchange_product"/>
|
<field name="product_id" onchange="onchange_product"/>
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
<field name="qty" onchange="onchange_line"/>
|
<field name="qty" onchange="onchange_line"/>
|
||||||
<field name="uom_id"/>
|
<field name="uom_id"/>
|
||||||
<field name="price" onchange="onchange_line"/>
|
<field name="price" onchange="onchange_line"/>
|
||||||
<field name="amount"/>
|
<field name="amount" onchange="onchange_line"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
<group span="8" form_layout="stacked" attrs='{"invisible":[["amount","=",0]]}'>
|
<group span="8" form_layout="stacked" attrs='{"invisible":[["amount","=",0]]}'>
|
||||||
|
|
|
@ -1,5 +1,27 @@
|
||||||
<form model="clinic.setting" title="Clinic Settings">
|
<form model="clinic.setting" title="Clinic Settings">
|
||||||
<tabs>
|
<tabs>
|
||||||
|
<tab string="HD Case">
|
||||||
|
<field name="products" nolabel="1">
|
||||||
|
<list>
|
||||||
|
<field name="patient_type"/>
|
||||||
|
<field name="type"/>
|
||||||
|
<field name="product_id" onchange="onchange_product"/>
|
||||||
|
<field name="description"/>
|
||||||
|
<field name="uom_id"/>
|
||||||
|
<field name="qty" onchange="onchange_product"/>
|
||||||
|
<field name="amount"/>
|
||||||
|
</list>
|
||||||
|
<form>
|
||||||
|
<field name="patient_type"/>
|
||||||
|
<field name="type"/>
|
||||||
|
<field name="product_id"/>
|
||||||
|
<field name="description"/>
|
||||||
|
<field name="uom_id"/>
|
||||||
|
<field name="qty"/>
|
||||||
|
<field name="amount"/>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</tab>
|
||||||
<tab string="Labor Cost">
|
<tab string="Labor Cost">
|
||||||
<separator string="Nurse"/>
|
<separator string="Nurse"/>
|
||||||
<field name="var_k"/>
|
<field name="var_k"/>
|
||||||
|
@ -22,17 +44,17 @@
|
||||||
<separator string="Doctor"/>
|
<separator string="Doctor"/>
|
||||||
<field name="cost_per_case"/>
|
<field name="cost_per_case"/>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Testing">
|
<!--<tab string="Testing">-->
|
||||||
<group form_layout="stacked">
|
<!--<group form_layout="stacked">-->
|
||||||
<field name="file" span="3"/>
|
<!--<field name="file" span="3"/>-->
|
||||||
<newline/>
|
<!--<newline/>-->
|
||||||
<button string="Make Visit" method="make_visit" span="2"/>
|
<!--<button string="Make Visit" method="make_visit" span="2"/>-->
|
||||||
<newline/>
|
<!--<newline/>-->
|
||||||
<button string="Make HD Case" method="make_done" span="2"/>
|
<!--<button string="Make HD Case" method="make_done" span="2"/>-->
|
||||||
<newline/>
|
<!--<newline/>-->
|
||||||
<button string="Complete HD Case" method="make_complete" span="2"/>
|
<!--<button string="Complete HD Case" method="make_complete" span="2"/>-->
|
||||||
</group>
|
<!--</group>-->
|
||||||
</tab>
|
<!--</tab>-->
|
||||||
</tabs>
|
</tabs>
|
||||||
<foot>
|
<foot>
|
||||||
</foot>
|
</foot>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import setting
|
from . import setting
|
||||||
|
from . import setting_product
|
||||||
from . import setting_level
|
from . import setting_level
|
||||||
from . import cause_chronic
|
from . import cause_chronic
|
||||||
from . import comorbidity
|
from . import comorbidity
|
||||||
|
|
|
@ -56,11 +56,12 @@ class Dialyzer(Model):
|
||||||
for prod in get_model("product").search_browse([]):
|
for prod in get_model("product").search_browse([]):
|
||||||
if found:
|
if found:
|
||||||
break
|
break
|
||||||
for categ in prod.categs:
|
if prod.categ_id.id in categ_ids:
|
||||||
if categ.id in categ_ids:
|
product_id=prod.id
|
||||||
product_id=prod.id
|
found=True
|
||||||
found=True
|
break
|
||||||
break
|
if not product_id:
|
||||||
|
raise Exception("No Product with category 'Dialyzer'")
|
||||||
return product_id
|
return product_id
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
|
|
@ -6,6 +6,8 @@ from netforce.utils import get_data_path, get_file_path
|
||||||
from netforce.access import get_active_user,set_active_user
|
from netforce.access import get_active_user,set_active_user
|
||||||
from netforce.access import get_active_company
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
|
from . import utils
|
||||||
|
|
||||||
class HDCase(Model):
|
class HDCase(Model):
|
||||||
_name="clinic.hd.case"
|
_name="clinic.hd.case"
|
||||||
_string="HD Case"
|
_string="HD Case"
|
||||||
|
@ -76,6 +78,7 @@ class HDCase(Model):
|
||||||
"total_doctor": fields.Integer("Total Doctor",function="get_staff",function_multi=True),
|
"total_doctor": fields.Integer("Total Doctor",function="get_staff",function_multi=True),
|
||||||
"total_nurse": fields.Integer("Total Nurse",function="get_staff",function_multi=True),
|
"total_nurse": fields.Integer("Total Nurse",function="get_staff",function_multi=True),
|
||||||
'doctor_id': fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']],function="get_staff",function_multi=True),
|
'doctor_id': fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']],function="get_staff",function_multi=True),
|
||||||
|
'nu': fields.Char("N/U"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
|
@ -146,54 +149,49 @@ class HDCase(Model):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def onchange_line(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
path=context['path']
|
||||||
|
line=get_data_path(data,path,parent=True)
|
||||||
|
qty=line['qty'] or 0
|
||||||
|
price=line['price'] or 0.0
|
||||||
|
line['amount']=qty*price
|
||||||
|
self.update_amount(data)
|
||||||
|
return data
|
||||||
|
|
||||||
def onchange_product(self,context={}):
|
def onchange_product(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
path=context["path"]
|
path=context['path']
|
||||||
line=get_data_path(data,path,parent=True)
|
line=get_data_path(data,path,parent=True)
|
||||||
product_id=line.get('product_id')
|
product_id=line.get('product_id')
|
||||||
if not product_id:
|
|
||||||
return
|
|
||||||
prod=get_model("product").browse(product_id)
|
prod=get_model("product").browse(product_id)
|
||||||
line['uom_id']=prod.uom_id.id
|
line['uom_id']=prod.uom_id.id
|
||||||
line['description']=prod.name
|
line['description']=prod.name
|
||||||
line['qty']=1
|
qty=1
|
||||||
line['price']=prod.sale_price or 0.0
|
price=prod.sale_price or 0.0
|
||||||
line['amount']=prod.sale_price or 0.0
|
amt=qty*price
|
||||||
self.onchange_line(context)
|
line['qty']=qty
|
||||||
|
line['price']=price
|
||||||
|
line['amount']=amt
|
||||||
|
self.update_amount(data)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def onchange_line(self,context={}):
|
def update_amount(self,data):
|
||||||
data=context['data']
|
total_amt=0.0
|
||||||
total=0.0
|
|
||||||
fee_amt=0.0
|
fee_amt=0.0
|
||||||
for line in data['lines']:
|
for line in data['lines']:
|
||||||
price=line.get('price') or 0
|
price=line.get('price') or 0
|
||||||
qty=line.get('qty') or 0
|
qty=line.get('qty') or 0
|
||||||
amt=qty * price
|
amt=qty*price
|
||||||
line['amount']=amt
|
|
||||||
if line['type']=='fee':
|
if line['type']=='fee':
|
||||||
fee_amt+=amt
|
fee_amt+=amt
|
||||||
else:
|
else:
|
||||||
total+=amt
|
total_amt+=amt
|
||||||
|
data['total']=total_amt+fee_amt
|
||||||
data['total']=total+fee_amt
|
|
||||||
data['fee_amount']=fee_amt
|
data['fee_amount']=fee_amt
|
||||||
for line in data['payment_lines']:
|
for line in data['payment_lines']:
|
||||||
total-=line['amount'] or 0.0
|
total_amt-=line['amount'] or 0.0
|
||||||
data['amount']=total
|
data['amount']=total_amt
|
||||||
if not data.get('pay_date'):
|
|
||||||
data['pay_date']=time.strftime("%Y-%m-%d")
|
|
||||||
if not data.get('pay_account_id'):
|
|
||||||
patient_id=data['patient_id']
|
|
||||||
if patient_id:
|
|
||||||
patient=get_model("clinic.patient").browse(patient_id)
|
|
||||||
partner=patient.partner_id
|
|
||||||
if partner:
|
|
||||||
account_id=partner.account_payable_id
|
|
||||||
if not account_id:
|
|
||||||
settings=get_model("settings").browse(1)
|
|
||||||
account_id=settings.account_receivable_id
|
|
||||||
data['pay_account_id']=account_id.id
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def onchange_pay(self,context={}):
|
def onchange_pay(self,context={}):
|
||||||
|
@ -213,23 +211,29 @@ class HDCase(Model):
|
||||||
remaining_amt+=line.amount or 0.0
|
remaining_amt+=line.amount or 0.0
|
||||||
for line in obj.payment_lines:
|
for line in obj.payment_lines:
|
||||||
remaining_amt-=line.amount or 0.0
|
remaining_amt-=line.amount or 0.0
|
||||||
partner_id=obj.patient_id.partner_id.id
|
partner=obj.patient_id.partner_id
|
||||||
if not partner_id:
|
if not partner:
|
||||||
raise Exception("No contact on this patient")
|
raise Exception("No contact on this patient")
|
||||||
company_id=get_active_company()
|
company_id=get_active_company()
|
||||||
account_id=obj.pay_account_id.id
|
account_receivable_id=partner.account_receivable_id
|
||||||
|
if not account_receivable_id:
|
||||||
|
st=get_model('settings').browse(1)
|
||||||
|
account_receivable_id=st.account_receivable_id
|
||||||
|
if not account_receivable_id:
|
||||||
|
raise Exception("Not found account recieveable in account setting")
|
||||||
|
account_id=account_receivable_id.id
|
||||||
if not account_id:
|
if not account_id:
|
||||||
raise Exception("No Account for payment")
|
raise Exception("No Account for payment")
|
||||||
pay_amount=obj.pay_amount
|
pay_amount=obj.pay_amount
|
||||||
# XXX get from popup
|
|
||||||
if context.get("amount",0):
|
if context.get("amount",0):
|
||||||
pay_amount=context['amount'] or 0.0
|
pay_amount=context['amount'] or 0.0
|
||||||
vals={
|
vals={
|
||||||
"partner_id": partner_id,
|
"partner_id": partner.id,
|
||||||
"company_id": company_id,
|
"company_id": company_id,
|
||||||
"type": "in",
|
"type": "in",
|
||||||
"pay_type": "direct",
|
"pay_type": "direct",
|
||||||
"date": obj.pay_date,
|
'date': time.strftime("%Y-%m-%d"),
|
||||||
"account_id": account_id,
|
"account_id": account_id,
|
||||||
'related_id': "clinic.hd.case,%s"%obj.id,
|
'related_id': "clinic.hd.case,%s"%obj.id,
|
||||||
'direct_lines': [],
|
'direct_lines': [],
|
||||||
|
@ -264,22 +268,6 @@ class HDCase(Model):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
obj.write({" state":"cancelled"})
|
obj.write({" state":"cancelled"})
|
||||||
|
|
||||||
def onchange_gmproduct(self,context={}):
|
|
||||||
data=context['data']
|
|
||||||
path=context["path"]
|
|
||||||
line=get_data_path(data,path,parent=True)
|
|
||||||
product_id=line.get('product_id')
|
|
||||||
if not product_id:
|
|
||||||
return
|
|
||||||
prod=get_model("product").browse(product_id)
|
|
||||||
line['uom_id']=prod.uom_id.id
|
|
||||||
line['description']=prod.name
|
|
||||||
line['qty']=1
|
|
||||||
line['price']=prod.sale_price or 0.0
|
|
||||||
line['amount']=prod.sale_price or 0.0
|
|
||||||
data=self.onchange_gmline(context)
|
|
||||||
return data
|
|
||||||
|
|
||||||
def make_invoices(self,ids,context={}):
|
def make_invoices(self,ids,context={}):
|
||||||
setting=get_model("settings").browse(1)
|
setting=get_model("settings").browse(1)
|
||||||
currency_id=setting.currency_id.id
|
currency_id=setting.currency_id.id
|
||||||
|
@ -468,6 +456,7 @@ class HDCase(Model):
|
||||||
cycle_item_id=cycle_item_ids[0]
|
cycle_item_id=cycle_item_ids[0]
|
||||||
else:
|
else:
|
||||||
cycle_item_id=cycle_item.create({
|
cycle_item_id=cycle_item.create({
|
||||||
|
'date': obj.date,
|
||||||
'cycle_id': obj.cycle_id.id,
|
'cycle_id': obj.cycle_id.id,
|
||||||
})
|
})
|
||||||
obj.write({
|
obj.write({
|
||||||
|
@ -702,4 +691,58 @@ class HDCase(Model):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def get_staff_line(self,vals,patient_id=None):
|
||||||
|
if not patient_id:
|
||||||
|
return vals
|
||||||
|
patient=get_model("clinic.patient").browse(patient_id)
|
||||||
|
doctor=patient.doctor_id
|
||||||
|
if doctor:
|
||||||
|
if not vals.get('staffs'):
|
||||||
|
vals['staffs']=[]
|
||||||
|
vals['staffs'].append(('create',{
|
||||||
|
'staff_id': doctor.id,
|
||||||
|
'type': 'doctor',
|
||||||
|
'priop': 'owner',
|
||||||
|
}))
|
||||||
|
|
||||||
|
st=get_model("clinic.setting").browse(1)
|
||||||
|
if not vals.get('lines'):
|
||||||
|
vals['lines']=[]
|
||||||
|
for st_prod in st.products:
|
||||||
|
if patient.type==st_prod.patient_type:
|
||||||
|
prod=st_prod.product_id
|
||||||
|
vals['lines'].append(('create',{
|
||||||
|
'product_id': prod.id,
|
||||||
|
'uom_id': st_prod.uom_id.id,
|
||||||
|
'type': st_prod.type,
|
||||||
|
'description': st_prod.description,
|
||||||
|
'qty': st_prod.qty,
|
||||||
|
'amount': st_prod.amount,
|
||||||
|
}))
|
||||||
|
|
||||||
|
categ_name=utils.PATIENT_TYPE.get(patient.type)
|
||||||
|
categ_ids=get_model("partner.categ").search([['name','=',categ_name]])
|
||||||
|
if not categ_ids:
|
||||||
|
raise Exception("Partner Category: %s not found"%categ_name)
|
||||||
|
partner_id=None
|
||||||
|
if patient.type in ("mg","sc","uc"):
|
||||||
|
partner_obj=get_model("partner")
|
||||||
|
for partner in partner_obj.search_browse([]):
|
||||||
|
if partner.categ_id.id in categ_ids:
|
||||||
|
partner_id=partner.id
|
||||||
|
vals['fee_partner_id']=partner_id
|
||||||
|
break
|
||||||
|
return vals
|
||||||
|
|
||||||
|
def create(self,vals,**kw):
|
||||||
|
patient_id=vals['patient_id']
|
||||||
|
vals=self.get_staff_line(vals,patient_id)
|
||||||
|
new_id=super().create(vals,**kw)
|
||||||
|
return new_id
|
||||||
|
|
||||||
|
def write(self,ids,vals,**kw):
|
||||||
|
patient_id=vals.get('patient_id')
|
||||||
|
vals=self.get_staff_line(vals,patient_id)
|
||||||
|
super().write(ids,vals,**kw)
|
||||||
|
|
||||||
HDCase.register()
|
HDCase.register()
|
||||||
|
|
|
@ -10,11 +10,11 @@ class Hdcaseline(Model):
|
||||||
"uom_id": fields.Many2One("uom","UOM",required=True,search=True),
|
"uom_id": fields.Many2One("uom","UOM",required=True,search=True),
|
||||||
"price":fields.Float("Price"),
|
"price":fields.Float("Price"),
|
||||||
"amount":fields.Float("Amount"),
|
"amount":fields.Float("Amount"),
|
||||||
"type": fields.Selection([("fee","Fee"),("other","Other"),("service","Service")],"Type",required=True),
|
"type": fields.Selection([("fee","Fee"),("others","Others")],"Type",required=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'type': 'other',
|
'type': 'others',
|
||||||
}
|
}
|
||||||
|
|
||||||
Hdcaseline.register()
|
Hdcaseline.register()
|
||||||
|
|
|
@ -15,6 +15,7 @@ class ClinicSetting(Model):
|
||||||
"var_k": fields.Float("K"),
|
"var_k": fields.Float("K"),
|
||||||
'file': fields.File("File"),
|
'file': fields.File("File"),
|
||||||
'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
|
'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
|
||||||
|
'products': fields.One2Many("clinic.setting.product","setting_id","Products"),
|
||||||
'cost_per_case': fields.Float("Cost Per Case"),
|
'cost_per_case': fields.Float("Cost Per Case"),
|
||||||
'company_id': fields.Many2One("company", 'Company'),
|
'company_id': fields.Many2One("company", 'Company'),
|
||||||
}
|
}
|
||||||
|
@ -289,4 +290,23 @@ class ClinicSetting(Model):
|
||||||
line['formular']='%sX%s%s'%(var_a,op,var_b)
|
line['formular']='%sX%s%s'%(var_a,op,var_b)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def onchange_product(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
path=context['path']
|
||||||
|
line=get_data_path(data,path,parent=True)
|
||||||
|
product_id=line['product_id']
|
||||||
|
if product_id:
|
||||||
|
prod=get_model("product").browse(product_id)
|
||||||
|
uom=prod.uom_id
|
||||||
|
if not uom:
|
||||||
|
uom=get_model("uom").browse(1)
|
||||||
|
if not uom:
|
||||||
|
raise Exception("Not found uom 'Unit'")
|
||||||
|
line['uom_id']=uom.id
|
||||||
|
line['description']=prod.name
|
||||||
|
qty=line['qty'] or 0
|
||||||
|
amt=qty*(prod.sale_price or 0.0)
|
||||||
|
line['amount']=amt
|
||||||
|
return data
|
||||||
|
|
||||||
ClinicSetting.register()
|
ClinicSetting.register()
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
from netforce.model import Model, fields, get_model
|
||||||
|
|
||||||
|
class SettingProduct(Model):
|
||||||
|
_name="clinic.setting.product"
|
||||||
|
_string="Setting Product"
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
"setting_id": fields.Many2One("clinic.setting","Setting"),
|
||||||
|
"type": fields.Selection([("fee","FEE"),("others","Others")],"Type",required=True),
|
||||||
|
"patient_type": fields.Selection([("sc","Social Security"),("uc","UC"),("others","Others")],"Patient Type",required=True),
|
||||||
|
'uom_id': fields.Many2One("uom","UOM", required=True),
|
||||||
|
"product_id": fields.Many2One("product","Product"),
|
||||||
|
'description': fields.Char("Description"),
|
||||||
|
'qty': fields.Integer("Qty"),
|
||||||
|
'amount': fields.Float("Amount"),
|
||||||
|
}
|
||||||
|
|
||||||
|
_defaults={
|
||||||
|
'type': 'fee',
|
||||||
|
'patient_type': 'sc',
|
||||||
|
'qty': 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
_order="patient_type,type"
|
||||||
|
|
||||||
|
|
||||||
|
SettingProduct.register()
|
|
@ -15,7 +15,7 @@ MONTHS={
|
||||||
|
|
||||||
PATIENT_TYPE={
|
PATIENT_TYPE={
|
||||||
"sc":"ปกส.",
|
"sc":"ปกส.",
|
||||||
"uc":"uc.",
|
"uc":"UC.",
|
||||||
"others": "จ่ายเอง",
|
"others": "จ่ายเอง",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,62 +116,12 @@ class Visit(Model):
|
||||||
'time_stop': obj.time_stop,
|
'time_stop': obj.time_stop,
|
||||||
'cycle_id' : obj.cycle_id.id,
|
'cycle_id' : obj.cycle_id.id,
|
||||||
'visit_id': obj.id,
|
'visit_id': obj.id,
|
||||||
'cycle_id': obj.cycle_id.id,
|
|
||||||
'lines':[],
|
'lines':[],
|
||||||
'dialyzers': [],
|
'dialyzers': [],
|
||||||
'staffs': [],
|
'staffs': [],
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
}
|
}
|
||||||
|
|
||||||
vals['staffs'].append(('create',{
|
|
||||||
'staff_id': obj.doctor_id.id,
|
|
||||||
'type': 'doctor',
|
|
||||||
'priop': 'owner',
|
|
||||||
}))
|
|
||||||
|
|
||||||
products=get_model("product").search_browse([['code','=','FEE']])
|
|
||||||
for product in products:
|
|
||||||
vals['lines'].append(('create',{
|
|
||||||
'type': 'fee',
|
|
||||||
'product_id': product.id,
|
|
||||||
'description': product.name or "",
|
|
||||||
'qty': 2,
|
|
||||||
'price': product.sale_price or 0.0,
|
|
||||||
'amount': product.sale_price or 0.0,
|
|
||||||
'uom_id': product.uom_id.id,
|
|
||||||
}))
|
|
||||||
if obj.patient_id.type=='sc':
|
|
||||||
products=get_model("product").search_browse([['code','=','S0001']]) #XXX
|
|
||||||
for product in products:
|
|
||||||
vals['lines'].append(('create',{
|
|
||||||
'type': 'fee',
|
|
||||||
'product_id': product.id,
|
|
||||||
'description': product.name or "",
|
|
||||||
'qty': 1,
|
|
||||||
'price': product.sale_price or 0.0,
|
|
||||||
'amount': product.sale_price or 0.0,
|
|
||||||
'uom_id': product.uom_id.id,
|
|
||||||
}))
|
|
||||||
|
|
||||||
|
|
||||||
patient_type={
|
|
||||||
"sc":"Social Security",
|
|
||||||
"uc":"UC",
|
|
||||||
"others": "Others",
|
|
||||||
}
|
|
||||||
categ_name=patient_type.get(obj.patient_id.type)
|
|
||||||
categ_ids=get_model("partner.categ").search([['name','=',categ_name]])
|
|
||||||
if not categ_ids:
|
|
||||||
raise Exception("Partner Category: %s not found"%categ_name)
|
|
||||||
partner_id=None
|
|
||||||
if obj.patient_id.type in ("mg","sc","uc"):
|
|
||||||
partner_obj=get_model("partner")
|
|
||||||
for partner in partner_obj.search_browse([]):
|
|
||||||
if partner.categ_id.id in categ_ids:
|
|
||||||
partner_id=partner.id
|
|
||||||
vals['fee_partner_id']=partner_id
|
|
||||||
break
|
|
||||||
|
|
||||||
# use exist hd_case (in case set to draft)
|
# use exist hd_case (in case set to draft)
|
||||||
hd_case_id=None
|
hd_case_id=None
|
||||||
if obj.hd_cases:
|
if obj.hd_cases:
|
||||||
|
@ -190,7 +140,6 @@ class Visit(Model):
|
||||||
dom=[]
|
dom=[]
|
||||||
dom.append(['date','=',date])
|
dom.append(['date','=',date])
|
||||||
dom.append(['cycle_id','=',cycle.id])
|
dom.append(['cycle_id','=',cycle.id])
|
||||||
#dom.append(['state','=','draft'])
|
|
||||||
item_obj=get_model('clinic.cycle.item')
|
item_obj=get_model('clinic.cycle.item')
|
||||||
item_ids=item_obj.search(dom)
|
item_ids=item_obj.search(dom)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue