clinic/netforce_clinic/models/name_title.py

28 lines
722 B
Python

from netforce.model import Model, fields
class NameTitle(Model):
_name="clinic.name.title"
_string="Title"
_key=["name"]
_fields={
"name": fields.Char("Name",required=True,search=True),
'description': fields.Text("Description"),
}
_order="name"
def name_search(self,name,domain=None,condition=[],context={},**kw):
dom=[["name","ilike","%"+name+"%"]]
if domain:
dom=[dom,domain]
ids1=self.search(dom)
dom=[["description","ilike","%"+name+"%"]]
if domain:
dom=[dom,domain]
ids2=self.search(dom)
ids=list(set(ids1+ids2))
return self.name_get(ids,context=context)
NameTitle.register()