From 19489e8ff57a0227ca2cc9f1e263aa5afcd50230 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 17 Mar 2015 07:56:55 +0700 Subject: [PATCH] show department name --- netforce_clinic/models/__init__.py | 1 + netforce_clinic/models/department.py | 2 +- netforce_clinic/models/hd_case.py | 3 +-- netforce_clinic/models/login.py | 17 +++++++++++++++++ netforce_clinic/models/select_company.py | 8 ++++++++ netforce_clinic/models/shop.py | 2 +- 6 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 netforce_clinic/models/login.py diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 9979dc5..819bdc6 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -120,3 +120,4 @@ from . import base_user from . import select_company from . import name_title from . import compute_labor_cost +from . import login diff --git a/netforce_clinic/models/department.py b/netforce_clinic/models/department.py index 4d35e29..bf51647 100644 --- a/netforce_clinic/models/department.py +++ b/netforce_clinic/models/department.py @@ -88,7 +88,7 @@ class Department(Model): ['clinic.cycle.item','department_id.code','='], ['clinic.sickbed','department_id.code','='], ['clinic.shop','department_id.code','='], - #['clinic.department','code','='], + ['clinic.department','code','='], #XXX ['clinic.dialyzer','department_id.code','='], ['clinic.schedule','department_id.code','='], ] diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 4d0a3b7..d289ab8 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -3,8 +3,7 @@ import time from datetime import datetime, timedelta from netforce.model import Model, fields, get_model 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_company +from netforce.access import get_active_user,set_active_user, get_active_company from . import utils class HDCase(Model): diff --git a/netforce_clinic/models/login.py b/netforce_clinic/models/login.py new file mode 100644 index 0000000..b0f28b6 --- /dev/null +++ b/netforce_clinic/models/login.py @@ -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() diff --git a/netforce_clinic/models/select_company.py b/netforce_clinic/models/select_company.py index 31de54b..9a7edeb 100644 --- a/netforce_clinic/models/select_company.py +++ b/netforce_clinic/models/select_company.py @@ -109,7 +109,9 @@ class SelectCompany(Model): user_id=get_active_user() user=get_model("base.user").browse(user_id) dpt_profile=user.department_profile_id + set_active_user(1) #XXX dpt_codes=[dpt.code for dpt in dpt_profile.departments] + set_active_user(user_id) exist_model=[] for obj in self.browse(ids): for sa in get_model('share.access').search_browse([]): @@ -143,7 +145,9 @@ class SelectCompany(Model): return user=get_model('base.user').browse(user_id) obj=self.browse(ids)[0] + department_name='' if 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]]): user.write({ @@ -166,6 +170,10 @@ class SelectCompany(Model): 'profile_id': pf_id, }) 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 def get_select(self,context={}): diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py index 6db7420..c664886 100644 --- a/netforce_clinic/models/shop.py +++ b/netforce_clinic/models/shop.py @@ -28,7 +28,7 @@ class Shop(Model): _fields={ "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), 'patient_id': fields.Many2One('clinic.patient','Patient',search=True,domain=[['state','=','admit']]), 'contact_id': fields.Many2One('partner','Contact',search=True),