show department name

conv_bal
watcha.h 2015-03-17 07:56:55 +07:00
parent 3f9379d562
commit 19489e8ff5
6 changed files with 29 additions and 4 deletions

View File

@ -120,3 +120,4 @@ from . import base_user
from . import select_company from . import select_company
from . import name_title from . import name_title
from . import compute_labor_cost from . import compute_labor_cost
from . import login

View File

@ -88,7 +88,7 @@ class Department(Model):
['clinic.cycle.item','department_id.code','='], ['clinic.cycle.item','department_id.code','='],
['clinic.sickbed','department_id.code','='], ['clinic.sickbed','department_id.code','='],
['clinic.shop','department_id.code','='], ['clinic.shop','department_id.code','='],
#['clinic.department','code','='], ['clinic.department','code','='], #XXX
['clinic.dialyzer','department_id.code','='], ['clinic.dialyzer','department_id.code','='],
['clinic.schedule','department_id.code','='], ['clinic.schedule','department_id.code','='],
] ]

View File

@ -3,8 +3,7 @@ import time
from datetime import datetime, timedelta from datetime import datetime, timedelta
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.utils import get_data_path, get_file_path from netforce.utils import get_data_path, get_file_path
from netforce.access import get_active_user,set_active_user from netforce.access import get_active_user,set_active_user, get_active_company
from netforce.access import get_active_company
from . import utils from . import utils
class HDCase(Model): class HDCase(Model):

View File

@ -0,0 +1,17 @@
from netforce.model import Model, get_model
from netforce.access import get_active_user
class Login(Model):
_inherit="login"
def login(self,context={}):
res=super().login(context=context)
cookies=res['cookies']
user_id=get_active_user()
user=get_model('base.user').browse(user_id)
department=user.department_id
if department:
cookies['company_name']='%s (%s)'%(cookies['company_name'], department.name or "")
return res
Login.register()

View File

@ -109,7 +109,9 @@ class SelectCompany(Model):
user_id=get_active_user() user_id=get_active_user()
user=get_model("base.user").browse(user_id) user=get_model("base.user").browse(user_id)
dpt_profile=user.department_profile_id dpt_profile=user.department_profile_id
set_active_user(1) #XXX
dpt_codes=[dpt.code for dpt in dpt_profile.departments] dpt_codes=[dpt.code for dpt in dpt_profile.departments]
set_active_user(user_id)
exist_model=[] exist_model=[]
for obj in self.browse(ids): for obj in self.browse(ids):
for sa in get_model('share.access').search_browse([]): for sa in get_model('share.access').search_browse([]):
@ -143,7 +145,9 @@ class SelectCompany(Model):
return return
user=get_model('base.user').browse(user_id) user=get_model('base.user').browse(user_id)
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
department_name=''
if obj.department: if obj.department:
department_name=obj.department
# set to main profile of that user # set to main profile of that user
for dpt in get_model("clinic.department").search_browse([["name","=",obj.department]]): for dpt in get_model("clinic.department").search_browse([["name","=",obj.department]]):
user.write({ user.write({
@ -166,6 +170,10 @@ class SelectCompany(Model):
'profile_id': pf_id, 'profile_id': pf_id,
}) })
res=super().select(ids,context) res=super().select(ids,context)
if department_name:
cookies=res.get("cookies")
if cookies:
cookies['company_name']='%s (%s)'%(cookies['company_name'], department_name)
return res return res
def get_select(self,context={}): def get_select(self,context={}):

View File

@ -28,7 +28,7 @@ class Shop(Model):
_fields={ _fields={
"number": fields.Char("Number",required=True,search=True), "number": fields.Char("Number",required=True,search=True),
"ref": fields.Char("Ref",search=True), "ref": fields.Char("Customer Name",search=True),
'date': fields.Date("Date",search=True), 'date': fields.Date("Date",search=True),
'patient_id': fields.Many2One('clinic.patient','Patient',search=True,domain=[['state','=','admit']]), 'patient_id': fields.Many2One('clinic.patient','Patient',search=True,domain=[['state','=','admit']]),
'contact_id': fields.Many2One('partner','Contact',search=True), 'contact_id': fields.Many2One('partner','Contact',search=True),