diff --git a/netforce_clinic/layouts/clinic_select_company.xml b/netforce_clinic/layouts/clinic_select_company.xml
index 989d858..0a05383 100644
--- a/netforce_clinic/layouts/clinic_select_company.xml
+++ b/netforce_clinic/layouts/clinic_select_company.xml
@@ -1,5 +1,7 @@
-
+
+
+
diff --git a/netforce_clinic/layouts/clinic_user_form.xml b/netforce_clinic/layouts/clinic_user_form.xml
index d1dddc5..77a1d24 100644
--- a/netforce_clinic/layouts/clinic_user_form.xml
+++ b/netforce_clinic/layouts/clinic_user_form.xml
@@ -1,7 +1,9 @@
+
-
+
+
diff --git a/netforce_clinic/models/base_user.py b/netforce_clinic/models/base_user.py
index bfd9536..8b403d2 100644
--- a/netforce_clinic/models/base_user.py
+++ b/netforce_clinic/models/base_user.py
@@ -7,6 +7,7 @@ class User(Model):
'department_id': fields.Many2One("clinic.department","Current Department"),
'branch_id': fields.Many2One("clinic.branch","Branch"),
'old_profile_id': fields.Many2One('profile', "Old Profile"),
+ 'select_branch': fields.Boolean("Can Change Branch"),
}
User.register()
diff --git a/netforce_clinic/models/select_company.py b/netforce_clinic/models/select_company.py
index af201dd..6f158ba 100644
--- a/netforce_clinic/models/select_company.py
+++ b/netforce_clinic/models/select_company.py
@@ -5,6 +5,8 @@ class SelectCompany(Model):
_inherit="select.company"
_fields={
"department": fields.Selection([],"Department"),
+ "branch": fields.Selection([],"Branch"),
+ "show_branch": fields.Boolean("Show Branch"),
}
def _get_department(self,context={}):
@@ -13,10 +15,30 @@ class SelectCompany(Model):
dpt_name=user.department_id.name or ""
return dpt_name
+ def _get_branch(self,context={}):
+ user_id=get_active_user()
+ user=get_model("base.user").browse(user_id)
+ branch_name=user.branch_id.name or ""
+ return branch_name
+
+ def _get_show_branch(self,context={}):
+ user_id=get_active_user()
+ user=get_model("base.user").browse(user_id)
+ return user.select_branch or False
+
_defaults={
'department': _get_department,
+ 'branch': _get_branch,
+ 'show_branch': _get_show_branch,
}
+ def get_branch(self,context={}):
+ user_id=get_active_user()
+ set_active_user(1)
+ res=get_model("clinic.branch").search_read([],["name"])
+ set_active_user(user_id)
+ return [(r["name"],r["name"]) for r in res]
+
def get_departments(self,context={}):
user_id=get_active_user()
set_active_user(1)
@@ -144,7 +166,13 @@ class SelectCompany(Model):
user=get_model('base.user').browse(user_id)
obj=self.browse(ids)[0]
department_name=''
- if obj.department:
+ if obj.branch:
+ for branch in get_model("clinic.branch").search_browse([["name","=",obj.branch]]):
+ user=get_model("base.user").browse(user_id)
+ user.write({
+ 'branch_id': branch.id,
+ })
+ elif obj.department:
department_name=obj.department
# set to main profile of that user
for dpt in get_model("clinic.department").search_browse([["name","=",obj.department]]):