stock journal
parent
8c65f98dea
commit
81cedff701
|
@ -7,7 +7,7 @@ class Branch(Model):
|
|||
_fields={
|
||||
"name": fields.Char("Name",required=True,search=True),
|
||||
"parent_id": fields.Many2One("clinic.branch","Parent"),
|
||||
"pick_out_journal_id": fields.Many2One("stock.journal","Goods Issue Journal"),
|
||||
"pick_out_journal_id": fields.Many2One("stock.journal","Stock Journal"),
|
||||
}
|
||||
|
||||
Branch.register()
|
||||
|
|
|
@ -199,9 +199,11 @@ class HDCase(Model):
|
|||
if patient_id:
|
||||
patient=get_model('clinic.patient').browse(patient_id)
|
||||
department=patient.department_id
|
||||
branch=patient.branch_id
|
||||
cycle=patient.cycle_id
|
||||
partner=patient.type_id.contact_id
|
||||
data['department_id']=department.id
|
||||
data['branch_id']=branch.id
|
||||
data['cycle_id']=cycle.id
|
||||
data['patient_type_id']=patient.type_id.id
|
||||
if partner:
|
||||
|
@ -475,6 +477,22 @@ class HDCase(Model):
|
|||
if not ship_address_id:
|
||||
patient.simple_address()
|
||||
#raise Exception("contact %s dont'have address with type shipping"%partner.name)
|
||||
|
||||
# default journal
|
||||
cust_loc_id=None
|
||||
wh_loc_id=None
|
||||
# find location
|
||||
# 1. from department -> branch -> stock journal -> from, to
|
||||
department=obj.department_id
|
||||
if department:
|
||||
branch=department.branch_id
|
||||
if branch:
|
||||
stock_journal=branch.pick_out_journal_id
|
||||
if stock_journal:
|
||||
wh_loc_id=stock_journal.location_from_id.id
|
||||
cust_loc_id=stock_journal.location_to_id.id
|
||||
print("get location from stock journal %s "%(stock_journal.name))
|
||||
|
||||
pick_vals={
|
||||
"type": "out",
|
||||
"ref": obj.number,
|
||||
|
@ -484,11 +502,12 @@ class HDCase(Model):
|
|||
"state": "draft",
|
||||
"lines": [],
|
||||
}
|
||||
res=get_model("stock.location").search([["type","=","customer"]])
|
||||
if not res:
|
||||
raise Exception("Customer location not found")
|
||||
cust_loc_id=res[0]
|
||||
|
||||
if not cust_loc_id:
|
||||
res=get_model("stock.location").search([["type","=","customer"]])
|
||||
if not res:
|
||||
raise Exception("Customer location not found")
|
||||
cust_loc_id=res[0]
|
||||
|
||||
for line in obj.lines:
|
||||
if line.state!='draft':
|
||||
|
@ -499,12 +518,15 @@ class HDCase(Model):
|
|||
if prod.type != 'stock':
|
||||
print("continue ")
|
||||
continue
|
||||
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]
|
||||
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,
|
||||
|
@ -935,6 +957,9 @@ class HDCase(Model):
|
|||
def create(self,vals,**kw):
|
||||
patient_id=vals['patient_id']
|
||||
vals=self.get_staff_line(vals,patient_id)
|
||||
if not vals.get("branch_id"):
|
||||
patient=get_model("clinic.patient").browse(patient_id)
|
||||
vals['branch_id']=patient.branch_id.id
|
||||
new_id=super().create(vals,**kw)
|
||||
return new_id
|
||||
|
||||
|
|
|
@ -131,17 +131,12 @@ class Visit(Model):
|
|||
# get new dialyzer
|
||||
dlz_id=self.new_dlz(patient.id)
|
||||
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
||||
#raise Exception("%s is expired"%dialyzer.number)
|
||||
use_time+=1
|
||||
vals={
|
||||
"description": dialyzer.description or dialyzer.product_id.name or "",
|
||||
"use_time": use_time,
|
||||
"max_use_time": dialyzer.max_use_time,
|
||||
"member_type": dialyzer.member_type,
|
||||
"dialyzer_type": dialyzer.dialyzer_type,
|
||||
"bid_flow_rate": dialyzer.bid_flow_rate,
|
||||
"ultrafittration": dialyzer.ultrafittration,
|
||||
"state": dialyzer.state,
|
||||
'dialyzer_id': dialyzer.id,
|
||||
}
|
||||
return vals
|
||||
|
@ -178,11 +173,6 @@ class Visit(Model):
|
|||
st=get_model("clinic.setting").browse(1)
|
||||
if st.find_dlz:
|
||||
dialyzer=self.get_dlz(obj.id)
|
||||
#XXX
|
||||
del dialyzer['state']
|
||||
del dialyzer['ultrafittration']
|
||||
del dialyzer['bid_flow_rate']
|
||||
del dialyzer['member_type']
|
||||
vals['dialyzers'].append(('create',dialyzer))
|
||||
|
||||
# use exist hd_case (in case set to draft)
|
||||
|
@ -278,11 +268,22 @@ class Visit(Model):
|
|||
if visits:
|
||||
visit=visits[0]
|
||||
doctor=visit.doctor_id
|
||||
department=visit.department_id
|
||||
if not department:
|
||||
department=patient.department_id
|
||||
department_id=None
|
||||
if visit.department_id:
|
||||
department_id=visit.department_id.id
|
||||
elif patient.department_id:
|
||||
department_id=patient.department_id.id
|
||||
|
||||
branch_id=None
|
||||
if visit.branch_id:
|
||||
branch_id=visit.branch_id.id
|
||||
elif patient.branch_id:
|
||||
branch_id=patient.branch_id.id
|
||||
|
||||
data['doctor_id']=doctor.id
|
||||
data['department_id']=department.id
|
||||
data['department_id']=department_id
|
||||
data['branch_id']=branch_id
|
||||
|
||||
if not patient.doctor_id:
|
||||
patient.write({
|
||||
'doctor_id': doctor.id,
|
||||
|
|
Loading…
Reference in New Issue