From 0fec2f8db285d887f9fea8532ebb60139c4ca9b7 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Wed, 22 Jul 2015 08:30:15 +0700 Subject: [PATCH] select contact should show name (code) --- netforce_clinic/fixme.txt | 4 +++- netforce_clinic/models/partner.py | 21 +++++++++++++++++++++ netforce_clinic/models/province.py | 1 + netforce_clinic/models/report_shop.py | 5 ----- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/netforce_clinic/fixme.txt b/netforce_clinic/fixme.txt index dd99dd0..382afba 100644 --- a/netforce_clinic/fixme.txt +++ b/netforce_clinic/fixme.txt @@ -1 +1,3 @@ -attr multi_company=True not working +1.print report labor cost +2. +3. diff --git a/netforce_clinic/models/partner.py b/netforce_clinic/models/partner.py index 3d58e55..5c7b9f8 100644 --- a/netforce_clinic/models/partner.py +++ b/netforce_clinic/models/partner.py @@ -9,4 +9,25 @@ class Partner(Model): 'is_staff': fields.Boolean("Is Staff"), } + def name_get(self,ids,context={}): + vals=[] + for obj in self.browse(ids): + name=obj.name or "" + if obj.code: + name=" %s (%s)"%(name,obj.code) + vals.append((obj.id,name)) + return vals + + def name_search(self,name,domain=None,condition=[],context={},**kw): + dom=[["name","ilike","%"+name+"%"]] + if domain: + dom=[dom,domain] + ids1=self.search(dom) + dom=[["code","ilike","%"+name+"%"]] + if domain: + dom=[dom,domain] + ids2=self.search(dom) + ids=list(set(ids1+ids2)) + return self.name_get(ids,context=context) + Partner.register() diff --git a/netforce_clinic/models/province.py b/netforce_clinic/models/province.py index a55cbf4..1a300f0 100644 --- a/netforce_clinic/models/province.py +++ b/netforce_clinic/models/province.py @@ -2,6 +2,7 @@ from netforce.model import Model, fields class Province(Model): _inherit="province" + def _get_sort_name(self,ids,context={}): res={} for obj in self.browse(ids): diff --git a/netforce_clinic/models/report_shop.py b/netforce_clinic/models/report_shop.py index f0522ba..fccc8ff 100644 --- a/netforce_clinic/models/report_shop.py +++ b/netforce_clinic/models/report_shop.py @@ -25,19 +25,14 @@ class ReportShop(Model): weekday, total_day=monthrange(int(year), int(month)) date_from=defaults.get('date_from','%s-%s-01'%(year,month)) date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day)) - #date_from=defaults.get('date',date) - #date_to=defaults.get('date',date) product_id=defaults.get('product_id') - branch_id=defaults.get('branch_id',None) - print('defaults ', defaults) if branch_id: branch_id=int(branch_id) department_id=defaults.get('department_id',None) if department_id: department_id=int(department_id) select_dpt=get_model('select.company').get_select() - print('select_dpt ', select_dpt) if select_dpt: if not branch_id: branch_id=select_dpt['branch_id']