add partner from contact

conv_bal
watcha.h 2014-10-02 14:36:13 +07:00
parent d4d79da4ca
commit 35ce36852c
6 changed files with 67 additions and 15 deletions

View File

@ -16,5 +16,12 @@
<field name="dialyzer_type"/>
<field name="ultrafittration"/>
<field name="patient_id"/>
<field name="product_id"/>
<field name="state"/>
<foot>
<button string="Confirm" type="success" method="confirmed"/>
</foot>
<related>
<field name="pickings" click_action="view_picking"/>
</related>
</form>

View File

@ -45,21 +45,26 @@
<list>
<field name="product_id" onchange="onchange_product"/>
<field name="detail"/>
<field name="qty"/>
<field name="qty" onchange="onchange_product"/>
<field name="uom_id"/>
<field name="price"/>
<field name="price" onchange="onchange_product"/>
<field name="total"/>
</list>
</field>
<field name="fee" span="3" offset="9"/>
<field name="total" span="3" offset="9"/>
<field name="amount" span="2" offset="9"/>
<group span="6" columns="1">
<field name="fee" onchange="onchange_product"/>
<!--<field name="include_fee" offset="1"/>-->
</group>
<group span="6" columns="1">
<field name="total"/>
<field name="amount"/>
</group>
<foot>
<button string="Confirm" type="success" method="confirmed" states="draft" />
<button string="Approved" type="success" method="approved" states="confirmed"/>
<button string="Approve" type="success" method="approved" states="confirmed"/>
<button string="Validate" type="success" method="validate" states="approved" />
<button string="Paid" type="success" method="paid" states="validated" />
<button string="Canceled" type="danger" method="cancelled" confirm="Are you sure to cancel this HD case?"/>
<button string="Pay" type="success" method="paid" states="validated" />
<button string="Cancel" type="danger" method="cancelled" confirm="Are you sure to cancel this HD case?"/>
</foot>
<related>
<field name="invoices" click_action="view_invoice"/>

View File

@ -13,14 +13,15 @@
<field name="salary"/>
<field name="gender"/>
<field name="marital_status"/>
<field name="partner_id"/>
<tabs>
<tab string="General Information">
<group span="6" columns="1">
<field name="birthday"/>
<field name="age"/>
<field name="card_type"/>
<field name="card_no"/>
<field name="card_exp"/>
<field name="birthday"/>
<field name="age"/>
<field name="picture"/>
<field name="mobile"/>
<field name="email"/>

View File

@ -18,13 +18,15 @@ class Dialyzer(Model):
"max_use_time": fields.Integer("Max Use Time"),
"exp_date": fields.Date("Expire Date",search=True),
"patient_id": fields.Many2One("clinic.patient","Patient"),
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Member Type",required=True),
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type",required=True),
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type",required=True),
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",required=True,search=True),
"ultrafittration": fields.Float("Ultrafittration Kg.",required=True,search=True),
"state": fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status",required=True),
"comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"),
'product_id': fields.Many2One("product", "Product"),
"pickings": fields.One2Many("stock.picking","related_id","Pickings"),
}
def _get_number(self,context={}):
@ -45,6 +47,7 @@ class Dialyzer(Model):
"max_use_time": 10,
"use_time": 0,
"company_id": lambda *a: get_active_company(),
'product_id': 48, # TODO search product with categ name is "Dialyzer"
}
_order="date desc,number desc"

View File

@ -15,8 +15,8 @@ class HDcase(Model):
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
"doctor_id": fields.Many2One("clinic.doctor","Doctor", required=True,search=True),
"nurse_id": fields.Many2One("clinic.nurse","Nurse", required=True,search=True),
"date_start": fields.DateTime("Date start",required=True,search=True),
"date_stop": fields.DateTime("Date stop",required=True,search=True),
"date_start": fields.DateTime("Time start",required=True,search=True),
"date_stop": fields.DateTime("Time stop",required=True,search=True),
"department_id": fields.Many2One("clinic.department", "Department",search=True),
"wh_start": fields.Float("Wt.Kg start"),
"wh_stop": fields.Float("Wt.Kg stop"),
@ -30,7 +30,7 @@ class HDcase(Model):
"lines_detail": fields.One2Many("clinic.hd.case.line.detail","hd_case_id","Detail"),
"comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"),
"fee": fields.Float("Fee",required=True),
"fee": fields.Float("HD Fee",required=True),
"amount": fields.Float("Amount",function="get_total",readonly=True,function_multi=True),
"total": fields.Float("Total",function="get_total",readonly=True,function_multi=True),
"reconcile_id": fields.Many2One("account.reconcile","Reconcile Id",readonly=True),
@ -38,6 +38,7 @@ class HDcase(Model):
"pickings": fields.One2Many("stock.picking","related_id","Pickings"),
"payments": fields.One2Many("account.payment","related_id","Payments"),
'visit_id': fields.Many2One("clinic.visit", "Visit"),
'include_fee': fields.Boolean("Include HD Fee"),
}
def _get_number(self,context={}):
@ -224,6 +225,7 @@ class HDcase(Model):
fee=obj.fee or 0
for line in obj.lines_detail:
total+=line.total or 0
fee=0 # XXX
amt=total+fee
vals[obj.id]={
"total": total,
@ -238,5 +240,20 @@ class HDcase(Model):
'form_view_xml': 'clinic_hd_case_form',
'active_id': ids[0],
}
def onchange_product(self,context={}):
data=context['data']
all_total=0.0
for line in data['lines_detail']:
qty=line['qty'] or 0
price=line['price'] or 0.0
total=qty*price
line['total']=total
all_total+=total
fee_amt=data['fee'] or 0.0
fee_amt=0.0 # XXX
data['total']=all_total
data['amount']=all_total+fee_amt
return data
HDcase.register()

View File

@ -34,7 +34,7 @@ class Patient(Model):
'email': fields.Char("Email"),
"weight": fields.Float("Weight (cm)"),
"height": fields.Float("Height (Kg)"),
"card_type": fields.Selection([("identification","Identification"),("passport","Passport")],"Card Type",required=True),
"card_type": fields.Selection([("identification","Identification"),("passport","Passport")],"Card Type"),
'card_no' : fields.Char("Card No."),
'card_exp' : fields.Date("Card Expiry"),
"app_no": fields.Char("Application No."),
@ -65,6 +65,7 @@ class Patient(Model):
"company_id": fields.Many2One("company","Company"),
"visits": fields.One2Many("clinic.visit","patient_id","Visits"),
"hd_cases": fields.One2Many("clinic.hd.case","patient_id","HD Cases"),
"partner_id": fields.Many2One("partner","Contact"),
}
def _get_number(self,context={}):
@ -92,5 +93,23 @@ class Patient(Model):
def void(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({"state":"voided"})
def create(self,vals,**kw):
obj_id=super(Patient,self).create(vals,**kw)
obj=self.browse(obj_id)
partner_id=get_model("partner").create({
'name': obj.name,
'last_name': obj.name,
'type': 'person'
})
obj.write({
'partner_id': partner_id,
})
return obj_id
def delete(self,ids,context={}):
partner_ids=[obj.partner_id.id for obj in self.browse(ids)]
get_model("partner").delete(partner_ids)
super().delete(ids)
Patient.register()