2014-12-16 09:53:36 +00:00
|
|
|
from netforce.model import Model, fields
|
|
|
|
|
|
|
|
class Partner(Model):
|
|
|
|
_inherit="partner"
|
2016-02-12 04:33:30 +00:00
|
|
|
#_key=["code","name"]
|
|
|
|
_key=["name"]
|
2014-12-16 09:53:36 +00:00
|
|
|
|
|
|
|
_fields={
|
2015-02-13 07:46:39 +00:00
|
|
|
'walkin_cust': fields.Boolean("Walkin Customer"),
|
|
|
|
'is_patient': fields.Boolean("Is Patient"),
|
2015-02-18 16:53:29 +00:00
|
|
|
'is_staff': fields.Boolean("Is Staff"),
|
2014-12-16 09:53:36 +00:00
|
|
|
}
|
|
|
|
|
2016-02-12 04:33:30 +00:00
|
|
|
_sql_constraints=[
|
|
|
|
("contact_uniq","unique (name)","The name of contact must be unique!"),
|
|
|
|
]
|
|
|
|
|
2015-07-22 01:30:15 +00:00
|
|
|
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
|
|
|
|
|
2016-03-08 11:07:50 +00:00
|
|
|
def _name_search(self,name,domain=None,condition=[],context={},**kw):
|
2015-07-22 01:30:15 +00:00
|
|
|
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)
|
|
|
|
|
2014-12-16 09:53:36 +00:00
|
|
|
Partner.register()
|