select department under company
parent
20e44d9173
commit
6a43030468
|
@ -0,0 +1,6 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Department Profiles</field>
|
||||||
|
<field name="view_cls">multi_view</field>
|
||||||
|
<field name="model">clinic.department.profile</field>
|
||||||
|
<field name="menu">gen_menu</field>
|
||||||
|
</action>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<form model="clinic.department.profile">
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="departments"/>
|
||||||
|
</form>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<list model="clinic.department.profile">
|
||||||
|
<field name="name"/>
|
||||||
|
</list>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<inherit inherit="gen_menu">
|
||||||
|
<item string="Users" position="after">
|
||||||
|
<item string="Department Profiles" action="clinic_department_profile"/>
|
||||||
|
</item>
|
||||||
|
</inherit>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<inherit model="base.user" inherit="user_form">
|
||||||
|
<field name="pin_code" position="after">
|
||||||
|
<field name="department_profile_id"/>
|
||||||
|
</field>
|
||||||
|
</inherit>
|
|
@ -9,6 +9,7 @@ from . import fin_setting
|
||||||
from . import cause_chronic
|
from . import cause_chronic
|
||||||
from . import comorbidity
|
from . import comorbidity
|
||||||
from . import department
|
from . import department
|
||||||
|
from . import department_profile
|
||||||
from . import education
|
from . import education
|
||||||
from . import graduation
|
from . import graduation
|
||||||
from . import morbidity
|
from . import morbidity
|
||||||
|
@ -102,4 +103,5 @@ from . import shop
|
||||||
from . import shop_line
|
from . import shop_line
|
||||||
from . import sale_order
|
from . import sale_order
|
||||||
from . import product
|
from . import product
|
||||||
|
from . import base_user
|
||||||
from . import select_company
|
from . import select_company
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
from netforce.model import Model, fields
|
||||||
|
|
||||||
|
class User(Model):
|
||||||
|
_inherit="base.user"
|
||||||
|
_fields={
|
||||||
|
'department_profile_id': fields.Many2One("clinic.department.profile","Department Profile"),
|
||||||
|
}
|
||||||
|
|
||||||
|
User.register()
|
|
@ -0,0 +1,12 @@
|
||||||
|
from netforce.model import Model, fields
|
||||||
|
|
||||||
|
class DepartmentProfile(Model):
|
||||||
|
_name="clinic.department.profile"
|
||||||
|
_string="Department Profile"
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
'name': fields.Char("Name", required=True, search=True),
|
||||||
|
"departments": fields.Many2Many("clinic.department","Departments"),
|
||||||
|
}
|
||||||
|
|
||||||
|
DepartmentProfile.register()
|
|
@ -21,8 +21,16 @@ class SelectCompany(Model):
|
||||||
|
|
||||||
def get_departments(self,context={}):
|
def get_departments(self,context={}):
|
||||||
user_id=get_active_user()
|
user_id=get_active_user()
|
||||||
|
user=get_model('base.user').browse(user_id)
|
||||||
|
dom=[]
|
||||||
|
if user.department_profile_id:
|
||||||
set_active_user(1)
|
set_active_user(1)
|
||||||
res=get_model("clinic.department").search_read([],["name"])
|
dpt_ids=[]
|
||||||
|
for dpt in user.department_profile_id.departments:
|
||||||
|
dpt_ids.append(dpt.id)
|
||||||
|
if dpt_ids:
|
||||||
|
dom.append(['id','in',dpt_ids])
|
||||||
|
res=get_model("clinic.department").search_read(dom,["name"])
|
||||||
set_active_user(user_id)
|
set_active_user(user_id)
|
||||||
return [(r["name"],r["name"]) for r in res]
|
return [(r["name"],r["name"]) for r in res]
|
||||||
|
|
||||||
|
@ -30,14 +38,17 @@ class SelectCompany(Model):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
if obj.department:
|
if obj.department:
|
||||||
user_id=get_active_user()
|
user_id=get_active_user()
|
||||||
|
user=get_model('base.user').browse(user_id)
|
||||||
set_active_user(1)
|
set_active_user(1)
|
||||||
|
staff=None
|
||||||
for dpt in get_model("clinic.department").search_browse([["name","=",obj.department]]):
|
for dpt in get_model("clinic.department").search_browse([["name","=",obj.department]]):
|
||||||
for staff in get_model("clinic.staff").search_browse([['user_id','=',user_id]]):
|
for staff in get_model("clinic.staff").search_browse([['user_id','=',user_id]]):
|
||||||
staff.write({
|
staff.write({
|
||||||
'department_id': dpt.id,
|
'department_id': dpt.id,
|
||||||
'branch_id': dpt.branch_id.id,
|
'branch_id': dpt.branch_id.id,
|
||||||
})
|
})
|
||||||
if staff:
|
if not staff:
|
||||||
|
raise Exception("No staff match with user %s"%user.name)
|
||||||
pf_id=None
|
pf_id=None
|
||||||
if dpt.branch_id.code=='LS':
|
if dpt.branch_id.code=='LS':
|
||||||
for pf in get_model("profile").search_browse([['name','=','Nurse Laksi']]):
|
for pf in get_model("profile").search_browse([['name','=','Nurse Laksi']]):
|
||||||
|
|
Loading…
Reference in New Issue