40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
from netforce.model import Model, fields
|
|
|
|
class Partner(Model):
|
|
_inherit="partner"
|
|
#_key=["code","name"]
|
|
_key=["name"]
|
|
|
|
_fields={
|
|
'walkin_cust': fields.Boolean("Walkin Customer"),
|
|
'is_patient': fields.Boolean("Is Patient"),
|
|
'is_staff': fields.Boolean("Is Staff"),
|
|
}
|
|
|
|
_sql_constraints=[
|
|
("contact_uniq","unique (name)","The name of contact must be unique!"),
|
|
]
|
|
|
|
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()
|