filter product by 1. categ, 2. code = patient type code
parent
dacfa2bded
commit
89b7542ea3
|
@ -19,6 +19,7 @@
|
|||
<field name="req_fee" span="2" invisible="1"/>
|
||||
<field name="company_id" span="2" invisible="1"/> <!-- to show company name, don't remove -->
|
||||
<field name="hct_include" span="2" invisible="1"/>
|
||||
<field name="type_code" span="2" invisible="1"/>
|
||||
</group>
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
|
@ -56,8 +57,8 @@
|
|||
<group span="12" form_layout="stacked">
|
||||
<field name="lines" count="3" nolabel="1">
|
||||
<list>
|
||||
<field name="product_id" onchange="onchange_product"/>
|
||||
<field name="product_categ_id" onchange="onchange_line"/>
|
||||
<field name="product_id" domain='[["categ_id.id","=",product_categ_id],["code","like",parent.type_code]]' onchange="onchange_product"/>
|
||||
<field name="description"/>
|
||||
<field name="reimbursable" onchange="onchange_line"/>
|
||||
<field name="qty" onchange="onchange_line"/>
|
||||
|
|
|
@ -11,11 +11,12 @@
|
|||
<separator string="Expenes"/>
|
||||
<field name="products" nolabel="1">
|
||||
<list>
|
||||
<field name="patient_type_id"/>
|
||||
<field name="product_id" onchange="onchange_product"/>
|
||||
<field name="account_id"/>
|
||||
<field name="patient_type_id" onchange="onchange_ptype"/>
|
||||
<field name="type_code" invisible="1"/>
|
||||
<field name="product_categ_id"/>
|
||||
<field name="product_id" domain='[["categ_id.id","=",product_categ_id],["code","like",type_code]]' onchange="onchange_product"/>
|
||||
<field name="description"/>
|
||||
<field name="account_id"/>
|
||||
<field name="reimbursable"/>
|
||||
<field name="uom_id"/>
|
||||
<field name="price" onchange="onchange_setting_line"/>
|
||||
|
@ -26,7 +27,6 @@
|
|||
</group>
|
||||
</tab>
|
||||
<tab string="Development">
|
||||
<!--<field name='branch_id'/>-->
|
||||
<button string="Click Me" type="default" method="run_script" perm="clinic_setting_test"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
<tab string="General">
|
||||
<field name="lines" nolabel="1">
|
||||
<list>
|
||||
<field name="product_id" onchange="onchange_product"/>
|
||||
<field name="product_id" domain='[["categ_id.code","=","EPO"]]' onchange="onchange_product"/>
|
||||
<field name="description"/>
|
||||
<field name="uom_id"/>
|
||||
<field name="qty"/>
|
||||
<field name="price"/>
|
||||
<field name="qty" onchange="onchange_line"/>
|
||||
<field name="price" onchange="onchange_line"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
</field>
|
||||
|
|
|
@ -58,13 +58,17 @@ class HDCase(Model):
|
|||
res[obj.id]=patient.type_id.id
|
||||
return res
|
||||
|
||||
def _get_hct_include(self,ids,context={}):
|
||||
def _get_store(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
include=False
|
||||
type_code=obj.patient_id.type_id.code
|
||||
if obj.patient_id.type_id.hct_include:
|
||||
include=True
|
||||
res[obj.id]=include
|
||||
res[obj.id]={
|
||||
'hct_include': include,
|
||||
'type_code': type_code,
|
||||
}
|
||||
return res
|
||||
|
||||
_fields={
|
||||
|
@ -90,7 +94,8 @@ class HDCase(Model):
|
|||
"ultrafittration": fields.Float("Ultrafiltration (kg.)"),
|
||||
"hct": fields.Integer("Hct",required=True),
|
||||
"hct_msg" : fields.Char(""),
|
||||
'hct_include': fields.Boolean("HCT Include", function="_get_hct_include",store=True),
|
||||
'hct_include': fields.Boolean("HCT Include", function="_get_store", function_multi=True,store=True),
|
||||
'type_code': fields.Char("Product Code", function="_get_store", function_multi=True,store=True),
|
||||
"state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),("completed","Finish Treatment"),('paid','Paid'),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True),
|
||||
"staffs": fields.One2Many("clinic.hd.case.staff","hd_case_id","Staffs"),
|
||||
"comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
|
||||
|
@ -220,6 +225,7 @@ class HDCase(Model):
|
|||
data['branch_id']=branch.id
|
||||
data['cycle_id']=cycle.id
|
||||
data['patient_type_id']=patient.type_id.id
|
||||
data['type_code']=patient.type_id.code
|
||||
if patient.type_id.hct_include:
|
||||
data['hct_include']=True
|
||||
else:
|
||||
|
|
|
@ -67,6 +67,15 @@ class ClinicSetting(Model):
|
|||
line['amount']=amt
|
||||
return data
|
||||
|
||||
def onchange_ptype(self,context={}):
|
||||
data=context['data']
|
||||
path=context['path']
|
||||
line=get_data_path(data,path,parent=True)
|
||||
ptype_id=line['patient_type_id']
|
||||
ptype=get_model("clinic.patient.type").browse(ptype_id)
|
||||
line['type_code']=ptype.code or ''
|
||||
return data
|
||||
|
||||
def onchange_setting_line(self,context={}):
|
||||
data=context['data']
|
||||
path=context['path']
|
||||
|
@ -91,15 +100,13 @@ class ClinicSetting(Model):
|
|||
return True
|
||||
|
||||
def run_script(self,ids,context={}):
|
||||
#db=get_connection()
|
||||
#db.execute('update clinic_cycle_item set date_validate=write_time;')
|
||||
dom=[]
|
||||
dom.append(['nurse_id','=',338])
|
||||
dom.append(['cycle_item_id.date','>=','2015-01-15'])
|
||||
dom.append(['cycle_item_id.date','<=','2015-01-15'])
|
||||
for tline in get_model("clinic.cycle.item.line").search_browse(dom):
|
||||
item=tline.cycle_item_id
|
||||
print(item.name)
|
||||
hids=get_model("clinic.hd.case").search([])
|
||||
get_model('clinic.hd.case').function_store(hids)
|
||||
obj=self.browse(ids)[0]
|
||||
for prod in obj.products:
|
||||
prod.write({
|
||||
'type_code': prod.patient_type_id.code,
|
||||
})
|
||||
print("Done! ")
|
||||
|
||||
def reset_last_import(self,ids,context={}):
|
||||
|
|
|
@ -9,6 +9,7 @@ class SettingProduct(Model):
|
|||
_fields={
|
||||
"setting_id": fields.Many2One("clinic.setting","Setting"),
|
||||
"patient_type_id": fields.Many2One("clinic.patient.type","Patient Type"),
|
||||
'type_code': fields.Char("Code"),
|
||||
"product_categ_id": fields.Many2One("product.categ","Category",domain=[['expense','=',True]]),
|
||||
'reimbursable': fields.Selection([['yes','Yes'],['no','No']],"Reimbursable"),
|
||||
'uom_id': fields.Many2One("uom","UOM", required=True),
|
||||
|
|
|
@ -11,8 +11,12 @@ class Shop(Model):
|
|||
def _get_all(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
total=0
|
||||
for line in obj.lines:
|
||||
amt=line.amount or 0
|
||||
total+=amt
|
||||
res[obj.id]={
|
||||
'total': 0,
|
||||
'total': total,
|
||||
}
|
||||
return res
|
||||
|
||||
|
@ -50,6 +54,21 @@ class Shop(Model):
|
|||
'department_id': _get_department,
|
||||
'state': 'draft',
|
||||
}
|
||||
|
||||
def update_all(self,context={}):
|
||||
data=context['data']
|
||||
data['total']=0
|
||||
for line in data['lines']:
|
||||
data['total']+=line['amount'] or 0
|
||||
return data
|
||||
|
||||
def onchange_line(self,context={}):
|
||||
data=context['data']
|
||||
path=context['path']
|
||||
line=get_data_path(data,path,parent=True)
|
||||
line['amount']=(line['qty'] or 0)*(line['price'] or 0)
|
||||
data=self.update_all(context=context)
|
||||
return data
|
||||
|
||||
def onchange_product(self,context={}):
|
||||
data=context['data']
|
||||
|
@ -63,6 +82,7 @@ class Shop(Model):
|
|||
if not line.get('qty'):
|
||||
line['qty']=1
|
||||
line['amount']=line['price']*line['qty']
|
||||
data=self.update_all(context)
|
||||
return data
|
||||
|
||||
Shop.register()
|
||||
|
|
Loading…
Reference in New Issue