2014-08-21 10:03:45 +00:00
|
|
|
from netforce.model import Model, fields, get_model
|
|
|
|
from netforce.utils import get_data_path
|
|
|
|
import time
|
|
|
|
from netforce.access import get_active_user
|
|
|
|
from netforce.access import get_active_company
|
|
|
|
|
|
|
|
class Dialyzer(Model):
|
|
|
|
_name="clinic.dialyzer"
|
|
|
|
_string="Dialyzer"
|
|
|
|
_audit_log=True
|
|
|
|
_name_field="number"
|
|
|
|
_multi_company=True
|
|
|
|
_fields={
|
|
|
|
"number": fields.Char("Number",required=True,search=True),
|
|
|
|
"detail": fields.Char("Detail",search=True),
|
|
|
|
"date": fields.Date("Create Date",search=True),
|
|
|
|
"use_time": fields.Integer("Use Time"),
|
|
|
|
"max_use_time": fields.Integer("Max Use Time"),
|
|
|
|
"exp_date": fields.Date("Expire Date",search=True),
|
|
|
|
"patient_id": fields.Many2One("clinic.patient","Patient"),
|
2014-10-02 07:36:13 +00:00
|
|
|
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type",required=True),
|
2014-09-11 03:21:52 +00:00
|
|
|
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type",required=True),
|
2014-08-28 11:20:49 +00:00
|
|
|
"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),
|
2014-08-21 10:03:45 +00:00
|
|
|
"comments": fields.One2Many("message","related_id","Comments"),
|
|
|
|
"company_id": fields.Many2One("company","Company"),
|
2014-10-02 07:36:13 +00:00
|
|
|
'product_id': fields.Many2One("product", "Product"),
|
|
|
|
"pickings": fields.One2Many("stock.picking","related_id","Pickings"),
|
2014-08-21 10:03:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def _get_number(self,context={}):
|
|
|
|
while 1:
|
|
|
|
num=get_model("sequence").get_number(name="dialyzer")
|
|
|
|
if not num:
|
|
|
|
return None
|
|
|
|
res=self.search([["number","=",num]])
|
|
|
|
if not res:
|
|
|
|
return num
|
|
|
|
get_model("sequence").increment(name="dialyzer")
|
|
|
|
|
|
|
|
|
|
|
|
_defaults={
|
|
|
|
"state": "draft",
|
|
|
|
"date": lambda *a: time.strftime("%Y-%m-%d"),
|
|
|
|
"number": _get_number,
|
|
|
|
"max_use_time": 10,
|
|
|
|
"use_time": 0,
|
|
|
|
"company_id": lambda *a: get_active_company(),
|
2014-10-02 07:36:13 +00:00
|
|
|
'product_id': 48, # TODO search product with categ name is "Dialyzer"
|
2014-08-21 10:03:45 +00:00
|
|
|
}
|
|
|
|
_order="date desc,number desc"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def void(self,ids,context={}):
|
|
|
|
obj=self.browse(ids)[0]
|
|
|
|
obj.write({"state":"voided"})
|
|
|
|
|
|
|
|
|
|
|
|
Dialyzer.register()
|