select contact should show name (code)

conv_bal
watcha.h@almacom.co.th 2015-07-22 08:30:15 +07:00
parent f3e9392de0
commit 0fec2f8db2
4 changed files with 25 additions and 6 deletions

View File

@ -1 +1,3 @@
attr multi_company=True not working
1.print report labor cost
2.
3.

View File

@ -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()

View File

@ -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):

View File

@ -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']