conv_bal
watcha.h 2014-10-02 17:10:57 +07:00
parent 35ce36852c
commit 13d03040a4
3 changed files with 75 additions and 33 deletions

View File

@ -5,21 +5,24 @@
<item string="Drop"/> <item string="Drop"/>
</button> </button>
</head> </head>
<field name="number"/> <group span="6" columns="1">
<field name="detail"/> <field name="number"/>
<field name="use_time"/> <field name="patient_id"/>
<field name="max_use_time"/> <field name="date"/>
<field name="date"/> <field name="member_type"/>
<field name="exp_date"/> <field name="bid_flow_rate"/>
<field name="member_type"/> <field name="ultrafittration"/>
<field name="bid_flow_rate"/> </group>
<field name="dialyzer_type"/> <group span="6" columns="1">
<field name="ultrafittration"/> <field name="product_id"/>
<field name="patient_id"/> <field name="dialyzer_type"/>
<field name="product_id"/> <field name="use_time"/>
<field name="state"/> <field name="max_use_time"/>
<field name="exp_date"/>
<field name="description"/>
</group>
<foot> <foot>
<button string="Confirm" type="success" method="confirmed"/> <button string="Confirm" type="success" method="confirm"/>
</foot> </foot>
<related> <related>
<field name="pickings" click_action="view_picking"/> <field name="pickings" click_action="view_picking"/>

View File

@ -1,6 +1,5 @@
<list model="clinic.dialyzer"> <list model="clinic.dialyzer">
<field name="number"/> <field name="number"/>
<field name="detail"/>
<field name="use_time"/> <field name="use_time"/>
<field name="max_use_time"/> <field name="max_use_time"/>
<field name="date"/> <field name="date"/>

View File

@ -1,8 +1,7 @@
from netforce.model import Model, fields, get_model
from netforce.utils import get_data_path
import time import time
from netforce.access import get_active_user
from netforce.access import get_active_company from netforce.model import Model, fields, get_model
from netforce.access import get_active_company, get_active_user, set_active_user
class Dialyzer(Model): class Dialyzer(Model):
_name="clinic.dialyzer" _name="clinic.dialyzer"
@ -12,36 +11,39 @@ class Dialyzer(Model):
_multi_company=True _multi_company=True
_fields={ _fields={
"number": fields.Char("Number",required=True,search=True), "number": fields.Char("Number",required=True,search=True),
"detail": fields.Char("Detail",search=True), "description": fields.Text("Description",search=True),
"date": fields.Date("Create Date",search=True), "date": fields.Date("Create Date",search=True),
"use_time": fields.Integer("Use Time"), "use_time": fields.Integer("Use Time"),
"max_use_time": fields.Integer("Max Use Time"), "max_use_time": fields.Integer("Max Use Time"),
"exp_date": fields.Date("Expire Date",search=True), "exp_date": fields.Date("Expiry Date",search=True),
"patient_id": fields.Many2One("clinic.patient","Patient"), "patient_id": fields.Many2One("clinic.patient","Patient"),
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type",required=True), "member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type",required=True), "dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",required=True,search=True), "bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",search=True),
"ultrafittration": fields.Float("Ultrafittration Kg.",required=True,search=True), "ultrafittration": fields.Float("Ultrafittration Kg.",search=True),
"state": fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status",required=True), "state": fields.Selection([("new","New"),("active","Active"),("drop","Drop"),('cancelled','Cancelled')],"Status"),
"comments": fields.One2Many("message","related_id","Comments"), "comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"), "company_id": fields.Many2One("company","Company"),
'product_id': fields.Many2One("product", "Product"), 'product_id': fields.Many2One("product", "Product",required=True),
"pickings": fields.One2Many("stock.picking","related_id","Pickings"), "pickings": fields.One2Many("stock.picking","related_id","Pickings"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
while 1: while 1:
num=get_model("sequence").get_number(name="dialyzer") seq_id=get_model("sequence").find_sequence(name="Clinic Dializer")
num=get_model("sequence").get_next_number(seq_id,context=context)
if not num: if not num:
return None return None
user_id=get_active_user()
set_active_user(1)
res=self.search([["number","=",num]]) res=self.search([["number","=",num]])
set_active_user(user_id)
if not res: if not res:
return num return num
get_model("sequence").increment(name="dialyzer") get_model("sequence").increment_number(seq_id,context=context)
_defaults={ _defaults={
"state": "draft", "state": "new",
"date": lambda *a: time.strftime("%Y-%m-%d"), "date": lambda *a: time.strftime("%Y-%m-%d"),
"number": _get_number, "number": _get_number,
"max_use_time": 10, "max_use_time": 10,
@ -51,11 +53,49 @@ class Dialyzer(Model):
} }
_order="date desc,number desc" _order="date desc,number desc"
def void(self,ids,context={}): def void(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
obj.write({"state":"voided"}) obj.write({"state":"voided"})
def confirm(self,ids,context={}):
id=ids[0]
obj=self.browse(id)
prod=obj.product_id
ship_address_id=0 #TODO contract address
pick_vals={
"type": "out",
"ref": obj.number,
"related_id": "clinic.dialyzer,%s"%obj.id,
"partner_id": obj.patient_id.partner_id.id,
"ship_address_id": ship_address_id,
"lines": [],
"state": "draft",
}
res=get_model("stock.location").search([["type","=","customer"]])
if not res:
raise Exception("Customer location not found")
cust_loc_id=res[0]
wh_loc_id=prod.location_id.id
if not wh_loc_id:
res=get_model("stock.location").search([["type","=","internal"]])
if not res:
raise Exception("Warehouse not found")
wh_loc_id=res[0]
line_vals={
"product_id": prod.id,
"qty": 1,
"uom_id": prod.uom_id.id,
"location_from_id": wh_loc_id,
"location_to_id": cust_loc_id,
}
pick_vals["lines"].append(("create",line_vals))
if not pick_vals["lines"]:
return {
"flash": "Nothing left to deliver",
}
pick_id=get_model("stock.picking").create(pick_vals,context={"pick_type": "out"})
pick=get_model("stock.picking").browse(pick_id)
print("Done!")
Dialyzer.register() Dialyzer.register()