21 lines
548 B
Python
21 lines
548 B
Python
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):
|
|
sname=''
|
|
if obj.name:
|
|
sname=obj.name[0:1]
|
|
res[obj.id]=sname
|
|
return res
|
|
|
|
_fields={
|
|
"name": fields.Char("Name",required=True,search=True,translate=True),
|
|
"sort_name": fields.Char("Sort Name",function="_get_sort_name",store=True),
|
|
}
|
|
_order="sort_name asc"
|
|
|
|
Province.register()
|