add a new field to the base model, call it 'is_defaul'
_columns = {
...
'is_default': fields.boolean('Default', ),
...
}
create a new method 'set_default_record'
def set_default_record(self, cr, uid, ids, vals):
if 'is_default' in vals:
if vals.get('is_default'):
query = 'update your_module set is_default=False where id<>%s'%(ids[0],)
cr.execute(query)
call this method from the create and the write methods
def create(self, cr, uid, vals, context=None):
context = context or {}
res_id = super(your_module, self).create(cr, uid, vals, context=context)
self.set_default_record(cr, uid, [res_id], vals)
return res_id
def write(self, cr, uid, ids, vals, context=None):
context = context or {}
res = super(your_module, self).write(cr, uid, ids, vals, context=context)
self.set_default_record(cr, uid, ids, vals)
return res
But you can ALWAYS calculate the current fiscal year by using the CURRENT DATE and finding the year it is inside. A new field needs to be updated when the year changes.
Fiscal year is just an example, I needed to create a generic solution for the case of setting a record in a table as a 'Default' record.