2014-10-01 16:14:52 +00:00
|
|
|
from netforce.model import Model, fields
|
|
|
|
|
|
|
|
class Nation(Model):
|
|
|
|
_name="clinic.nation"
|
|
|
|
_string="Nationality"
|
2015-03-17 01:49:03 +00:00
|
|
|
_key=['code']
|
2014-10-01 16:14:52 +00:00
|
|
|
|
|
|
|
_fields={
|
2015-03-17 02:04:48 +00:00
|
|
|
"name": fields.Char("Name",required=True,search=True),
|
|
|
|
"code": fields.Char("Code",search=True),
|
2015-03-17 04:59:23 +00:00
|
|
|
'default': fields.Boolean("Default"),
|
2014-10-01 16:14:52 +00:00
|
|
|
}
|
|
|
|
|
2015-03-17 04:59:23 +00:00
|
|
|
def write(self,ids,vals,**kw):
|
|
|
|
default=vals.get('default')
|
|
|
|
if default:
|
|
|
|
for obj in self.search_browse([]):
|
|
|
|
if obj.id not in ids:
|
|
|
|
obj.write({
|
|
|
|
'default': False,
|
|
|
|
})
|
|
|
|
super().write(ids,vals,**kw)
|
|
|
|
|
2014-10-01 16:14:52 +00:00
|
|
|
Nation.register()
|