multi department
parent
faf7a867de
commit
f6ff573d3a
|
@ -58,18 +58,6 @@
|
||||||
<related>
|
<related>
|
||||||
<field name="addresses"/>
|
<field name="addresses"/>
|
||||||
<field name="documents"/>
|
<field name="documents"/>
|
||||||
<!--<field name="rotations" nolabel="1">-->
|
|
||||||
<!--<list>-->
|
|
||||||
<!--<field name="level_id" domain="[['type','=',parent.type]]"/>-->
|
|
||||||
<!--<field name="from_company_id"/>-->
|
|
||||||
<!--<field name="to_company_id"/>-->
|
|
||||||
<!--<field name="hire_date"/>-->
|
|
||||||
<!--<field name="resign_date"/>-->
|
|
||||||
<!--<field name="max_cycle"/>-->
|
|
||||||
<!--<field name="wage"/>-->
|
|
||||||
<!--<field name="note"/>-->
|
|
||||||
<!--</list>-->
|
|
||||||
<!--</field>-->
|
|
||||||
<field name="hd_case_staffs" readonly="1" attrs='{"invisible":[["type","=","nurse"]]}'>
|
<field name="hd_case_staffs" readonly="1" attrs='{"invisible":[["type","=","nurse"]]}'>
|
||||||
<list colors='{"#cfc":[["state","=","completed"]],"#f9e37d":[["state","=","in_progress"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]],"#70DB93":[["state","=","paid"]]}'>
|
<list colors='{"#cfc":[["state","=","completed"]],"#f9e37d":[["state","=","in_progress"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]],"#70DB93":[["state","=","paid"]]}'>
|
||||||
<field name="hd_case_id"/>
|
<field name="hd_case_id"/>
|
||||||
|
|
|
@ -80,8 +80,11 @@ class Patient(Model):
|
||||||
|
|
||||||
def _get_department_names(self,ids,context={}):
|
def _get_department_names(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
|
user_id=get_active_user()
|
||||||
|
set_active_user(1)
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
res[obj.id]=','.join([dpt.name for dpt in obj.departments])
|
res[obj.id]=','.join([dpt.name for dpt in obj.departments])
|
||||||
|
set_active_user(user_id)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
|
@ -192,12 +195,18 @@ class Patient(Model):
|
||||||
def _get_departments(self,context={}):
|
def _get_departments(self,context={}):
|
||||||
res=get_model('select.company').get_select()
|
res=get_model('select.company').get_select()
|
||||||
if res:
|
if res:
|
||||||
|
if res.get("department_ids"):
|
||||||
|
return res['department_ids']
|
||||||
|
else:
|
||||||
return [res['department_id']]
|
return [res['department_id']]
|
||||||
return get_model("clinic.department").search([])
|
return get_model("clinic.department").search([])
|
||||||
|
|
||||||
def _get_department(self,context={}):
|
def _get_department(self,context={}):
|
||||||
res=get_model('select.company').get_select()
|
res=get_model('select.company').get_select()
|
||||||
if res:
|
if res:
|
||||||
|
if res.get("department_ids"):
|
||||||
|
return res['department_ids'][0]
|
||||||
|
else:
|
||||||
return res['department_id']
|
return res['department_id']
|
||||||
|
|
||||||
def _get_branch(self,context={}):
|
def _get_branch(self,context={}):
|
||||||
|
@ -207,9 +216,16 @@ class Patient(Model):
|
||||||
|
|
||||||
def _get_default_location(self,context={}):
|
def _get_default_location(self,context={}):
|
||||||
res=get_model('select.company').get_select()
|
res=get_model('select.company').get_select()
|
||||||
|
code=''
|
||||||
if res:
|
if res:
|
||||||
dpt=get_model("clinic.department").browse(res['department_id'])
|
dpt_ids=[]
|
||||||
return dpt.code
|
if res.get("department_ids"):
|
||||||
|
dpt_ids=res['department_ids']
|
||||||
|
else:
|
||||||
|
dpt_ids=res['department_id']
|
||||||
|
dpts=get_model("clinic.department").browse(dpt_ids)
|
||||||
|
code=','.join([dpt.code for dpt in dpts])
|
||||||
|
return code
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
#"number": _get_number,
|
#"number": _get_number,
|
||||||
|
|
|
@ -33,6 +33,9 @@ class ReportCycleItem(Model):
|
||||||
if not branch_id:
|
if not branch_id:
|
||||||
branch_id=res['branch_id']
|
branch_id=res['branch_id']
|
||||||
if not department_id:
|
if not department_id:
|
||||||
|
if res.get("department_ids"):
|
||||||
|
department_id=res['department_ids'][0]
|
||||||
|
else:
|
||||||
department_id=res['department_id']
|
department_id=res['department_id']
|
||||||
res={
|
res={
|
||||||
'date': date,
|
'date': date,
|
||||||
|
|
|
@ -33,12 +33,15 @@ class ReportDiscontinuePatient(Model):
|
||||||
department_id=defaults.get('department_id',None)
|
department_id=defaults.get('department_id',None)
|
||||||
if department_id:
|
if department_id:
|
||||||
department_id=int(department_id)
|
department_id=int(department_id)
|
||||||
select_apt=get_model('select.company').get_select()
|
select_dpt=get_model('select.company').get_select()
|
||||||
if select_apt:
|
if select_dpt:
|
||||||
if not branch_id:
|
if not branch_id:
|
||||||
branch_id=select_apt['branch_id']
|
branch_id=select_dpt['branch_id']
|
||||||
if not department_id:
|
if not department_id:
|
||||||
department_id=select_apt['department_id']
|
if select_dpt.get('department_ids'):
|
||||||
|
department_id=select_dpt['department_ids'][0]
|
||||||
|
else:
|
||||||
|
department_id=select_dpt['department_id']
|
||||||
res={
|
res={
|
||||||
'date': date,
|
'date': date,
|
||||||
'date_from': date_from,
|
'date_from': date_from,
|
||||||
|
|
|
@ -38,6 +38,9 @@ class ReportHDCaseSummary(Model):
|
||||||
def _get_department(self,context={}):
|
def _get_department(self,context={}):
|
||||||
res=get_model('select.company').get_select()
|
res=get_model('select.company').get_select()
|
||||||
if res:
|
if res:
|
||||||
|
if res.get("department_ids"):
|
||||||
|
return res['department_ids'][0]
|
||||||
|
else:
|
||||||
return res['department_id']
|
return res['department_id']
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
|
|
@ -41,6 +41,9 @@ class ReportMedicalSummary(Model):
|
||||||
branch_id=int(branch_id or "0")
|
branch_id=int(branch_id or "0")
|
||||||
department_id=defaults.get('department_id',None)
|
department_id=defaults.get('department_id',None)
|
||||||
if not department_id:
|
if not department_id:
|
||||||
|
if select_dpt.get('department_ids'):
|
||||||
|
department_id=select_dpt['department_ids'][0]
|
||||||
|
else:
|
||||||
department_id=select_dpt['department_id']
|
department_id=select_dpt['department_id']
|
||||||
else:
|
else:
|
||||||
department_id=int(department_id or "0")
|
department_id=int(department_id or "0")
|
||||||
|
|
|
@ -32,12 +32,15 @@ class ReportRecentPatient(Model):
|
||||||
department_id=defaults.get('department_id',None)
|
department_id=defaults.get('department_id',None)
|
||||||
if department_id:
|
if department_id:
|
||||||
department_id=int(department_id)
|
department_id=int(department_id)
|
||||||
select_apt=get_model('select.company').get_select()
|
select_dpt=get_model('select.company').get_select()
|
||||||
if select_apt:
|
if select_dpt:
|
||||||
if not branch_id:
|
if not branch_id:
|
||||||
branch_id=select_apt['branch_id']
|
branch_id=select_dpt['branch_id']
|
||||||
if not department_id:
|
if not department_id:
|
||||||
department_id=select_apt['department_id']
|
if select_dpt.get('department_ids'):
|
||||||
|
department_id=select_dpt['department_ids'][0]
|
||||||
|
else:
|
||||||
|
department_id=select_dpt['department_id']
|
||||||
res={
|
res={
|
||||||
'date': date,
|
'date': date,
|
||||||
'date_from': date_from,
|
'date_from': date_from,
|
||||||
|
|
|
@ -175,6 +175,14 @@ class SelectCompany(Model):
|
||||||
user=get_model("base.user").browse(user_id)
|
user=get_model("base.user").browse(user_id)
|
||||||
dpt=user.department_id
|
dpt=user.department_id
|
||||||
if not dpt:
|
if not dpt:
|
||||||
|
dpts=user.department_profile_id.departments
|
||||||
|
if dpts:
|
||||||
|
res={
|
||||||
|
'department_ids': [dpt.id for dpt in dpts],
|
||||||
|
'branch_id': dpts[0].branch_id.id, #XXX
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
else:
|
||||||
return {}
|
return {}
|
||||||
department_id=dpt.id
|
department_id=dpt.id
|
||||||
branch_id=dpt.branch_id.id
|
branch_id=dpt.branch_id.id
|
||||||
|
|
|
@ -102,8 +102,11 @@ class Staff(Model):
|
||||||
|
|
||||||
def _get_department_names(self,ids,context={}):
|
def _get_department_names(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
|
user_id=get_active_user()
|
||||||
|
set_active_user(1)
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
res[obj.id]=','.join([dpt.name for dpt in obj.departments])
|
res[obj.id]=','.join([dpt.name for dpt in obj.departments])
|
||||||
|
set_active_user(user_id)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
|
@ -189,14 +192,32 @@ class Staff(Model):
|
||||||
def _get_departments(self,context={}):
|
def _get_departments(self,context={}):
|
||||||
res=get_model('select.company').get_select()
|
res=get_model('select.company').get_select()
|
||||||
if res:
|
if res:
|
||||||
|
if res.get("department_ids"):
|
||||||
|
return res['department_ids']
|
||||||
|
else:
|
||||||
return [res['department_id']]
|
return [res['department_id']]
|
||||||
return get_model("clinic.department").search([])
|
return get_model("clinic.department").search([])
|
||||||
|
|
||||||
def _get_default_location(self,context={}):
|
def _get_default_location(self,context={}):
|
||||||
res=get_model('select.company').get_select()
|
res=get_model('select.company').get_select()
|
||||||
|
code=''
|
||||||
if res:
|
if res:
|
||||||
dpt=get_model("clinic.department").browse(res['department_id'])
|
dpt_ids=[]
|
||||||
return dpt.code
|
if res.get("department_ids"):
|
||||||
|
dpt_ids=res['department_ids']
|
||||||
|
else:
|
||||||
|
dpt_ids=res['department_id']
|
||||||
|
dpts=get_model("clinic.department").browse(dpt_ids)
|
||||||
|
code=','.join([dpt.code for dpt in dpts])
|
||||||
|
return code
|
||||||
|
|
||||||
|
def _get_department(self,context={}):
|
||||||
|
res=get_model('select.company').get_select()
|
||||||
|
if res:
|
||||||
|
if res.get("department_ids"):
|
||||||
|
return res['department_ids'][0]
|
||||||
|
else:
|
||||||
|
return res['department_id']
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'active': True,
|
'active': True,
|
||||||
|
@ -207,6 +228,7 @@ class Staff(Model):
|
||||||
"company_id": lambda *a: get_active_company(),
|
"company_id": lambda *a: get_active_company(),
|
||||||
'branch_id': _get_branch,
|
'branch_id': _get_branch,
|
||||||
'departments': _get_departments,
|
'departments': _get_departments,
|
||||||
|
'department_id': _get_department,
|
||||||
'location': _get_default_location,
|
'location': _get_default_location,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ class StaffRotation(Model):
|
||||||
'company_id': fields.Many2One("company","Company"),
|
'company_id': fields.Many2One("company","Company"),
|
||||||
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
|
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
|
||||||
'staff_name': fields.Char("Staff Name", function="_get_all",function_multi=True,store=True), #XXX
|
'staff_name': fields.Char("Staff Name", function="_get_all",function_multi=True,store=True), #XXX
|
||||||
|
'department_id': fields.Many2One("clinic.department", "Department"), #XXX
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
@ -57,14 +58,12 @@ class StaffRotation(Model):
|
||||||
def create(self,vals,**kw):
|
def create(self,vals,**kw):
|
||||||
id=super().create(vals,**kw)
|
id=super().create(vals,**kw)
|
||||||
self.function_store([id])
|
self.function_store([id])
|
||||||
#XXX
|
|
||||||
get_model("clinic.staff").function_store([vals['staff_id']])
|
get_model("clinic.staff").function_store([vals['staff_id']])
|
||||||
return id
|
return id
|
||||||
|
|
||||||
def write(self,ids,vals,**kw):
|
def write(self,ids,vals,**kw):
|
||||||
super().write(ids,vals,**kw)
|
super().write(ids,vals,**kw)
|
||||||
self.function_store(ids)
|
self.function_store(ids)
|
||||||
#XXX
|
|
||||||
staff_ids=[]
|
staff_ids=[]
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
staff_ids.append(obj.staff_id.id)
|
staff_ids.append(obj.staff_id.id)
|
||||||
|
|
|
@ -50,6 +50,9 @@ class VisitBoard(Model):
|
||||||
if not branch_id:
|
if not branch_id:
|
||||||
branch_id=res['branch_id']
|
branch_id=res['branch_id']
|
||||||
if not department_id:
|
if not department_id:
|
||||||
|
if res.get('department_ids'):
|
||||||
|
department_id=res['department_ids'][0]
|
||||||
|
else:
|
||||||
department_id=res['department_id']
|
department_id=res['department_id']
|
||||||
res={
|
res={
|
||||||
'date': date,
|
'date': date,
|
||||||
|
|
Loading…
Reference in New Issue