Hi Girish,
Yes you can. You would need to create a new Class in order to create your own view type. Here is an example of how the integer field type is made in Odoo:
class Integer(Field):
type = 'integer'
column_type = ('int4', 'int4')
_slots = {
'group_operator': 'sum',
}
def convert_to_column(self, value, record, values=None, validate=True):
return int(value or 0)
def convert_to_cache(self, value, record, validate=True):
if isinstance(value, dict):
# special case, when an integer field is used as inverse for a one2many
return value.get('id', False)
return int(value or 0)
def convert_to_read(self, value, record, use_name_get=True):
# Integer values greater than 2^31-1 are not supported in pure XMLRPC,
# so we have to pass them as floats :-(
if value and value > MAXINT:
return float(value)
return value
def _update(self, records, value):
# special case, when an integer field is used as inverse for a one2many
cache = records.env.cache
for record in records:
cache.set(record, self, value.id or 0)
def convert_to_export(self, value, record):
if value or value == 0:
return value if record._context.get('export_raw_data') else ustr(value)
return ''
After you've built the class and the field type you'll need to create your own field widgets and logic to convert values to the output you'd like.
Make sure you test your own field type thoroughly though as you're in the core of both Odoo and postgreSQL. You'll need to test a lot of cases before putting this into production.
Regards,
Yenthe