I want to extend an odoo datatype. First I wanted to create a new datatype from scretch. This wasn't easy since odoo/openerp just don't know how to store that datatype. So now I want to extend it.
from openerp import fields
class MyDataType(fields.Text):
@classmethod
def browse_my_data_type(self, value1, value2):
result = value1 + value2
if len(result) > 0:
return result
else:
return False
I tried to use it. It's possible untill I want to call the browse_my_data_type
method.
from openerp import models, fields, api
import my_new_fields as my_fields
class my_data_type_test(models.Model):
_name = 'my.type.test'
name = fields.Char('Name')
my_data_type = my_fields.MyDataType("My Data Type")
result = fields.Char("Result", compute="_set_result")
@api.one
def _set_result(self):
result = self.my_data_type.browse_my_data_type("valuehere","anotheronehere")
if result:
self.result = result
else:
self.result = ""
I used this code to test the method. Sadly it gives me the error AttributeError: 'unicode' object has no attribute 'browse_my_data_type'
How can I make sure that he knows the method while using it this way? (self.my_data_type.browse_my_data_type("valuehere","anotheronehere"
)