How to use the odoorpc.fields.Text function in OdooRPC

To help you get started, we’ve selected a few OdooRPC examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github osiell / odoorpc / odoorpc / fields.py View on Github external
TYPES_TO_FIELDS = {
    'binary': Binary,
    'boolean': Boolean,
    'char': Char,
    'date': Date,
    'datetime': Datetime,
    'float': Float,
    'html': Html,
    'integer': Integer,
    'many2many': Many2many,
    'many2one': Many2one,
    'one2many': One2many,
    'reference': Reference,
    'selection': Selection,
    'text': Text,
}


def generate_field(name, data):
    """Generate a well-typed field according to the data dictionary supplied
    (obtained via the `fields_get' method of any models).
    """
    assert 'type' in data
    field = TYPES_TO_FIELDS.get(data['type'], Unknown)(name, data)
    return field
github OCA / odoorpc / odoorpc / fields.py View on Github external
def __get__(self, instance, owner):
        value = instance._values[self.name].get(instance.id)
        if instance.id in instance._values_to_write[self.name]:
            value = instance._values_to_write[self.name][instance.id]
        return value

    def __set__(self, instance, value):
        if value is None:
            value = False
        value = self.check_value(value)
        instance._values_to_write[self.name][instance.id] = value
        super(Text, self).__set__(instance, value)


class Html(Text):
    """Equivalent of the `fields.Html` class."""

    def __init__(self, name, data):
        super(Html, self).__init__(name, data)


class Unknown(BaseField):
    """Represent an unknown field. This should not happen but this kind of
    field only exists to avoid a blocking situation from a RPC point of view.
    """

    def __init__(self, name, data):
        super(Unknown, self).__init__(name, data)

    def __get__(self, instance, owner):
        value = instance._values[self.name][instance.id]
github OCA / odoorpc / odoorpc / fields.py View on Github external
TYPES_TO_FIELDS = {
    'binary': Binary,
    'boolean': Boolean,
    'char': Char,
    'date': Date,
    'datetime': Datetime,
    'float': Float,
    'html': Html,
    'integer': Integer,
    'many2many': Many2many,
    'many2one': Many2one,
    'one2many': One2many,
    'reference': Reference,
    'selection': Selection,
    'text': Text,
}


def generate_field(name, data):
    """Generate a well-typed field according to the data dictionary supplied
    (obtained via the `fields_get' method of any models).
    """
    assert 'type' in data
    field = TYPES_TO_FIELDS.get(data['type'], Unknown)(name, data)
    return field
github OCA / odoorpc / odoorpc / fields.py View on Github external
def __set__(self, instance, value):
        if value is None:
            value = False
        value = self.check_value(value)
        instance._values_to_write[self.name][instance.id] = value
        super(Text, self).__set__(instance, value)
github osiell / odoorpc / odoorpc / fields.py View on Github external
def __init__(self, name, data):
        super(Text, self).__init__(name, data)
github osiell / odoorpc / odoorpc / fields.py View on Github external
def __get__(self, instance, owner):
        value = instance._values[self.name].get(instance.id)
        if instance.id in instance._values_to_write[self.name]:
            value = instance._values_to_write[self.name][instance.id]
        return value

    def __set__(self, instance, value):
        if value is None:
            value = False
        value = self.check_value(value)
        instance._values_to_write[self.name][instance.id] = value
        super(Text, self).__set__(instance, value)


class Html(Text):
    """Equivalent of the `fields.Html` class."""
    def __init__(self, name, data):
        super(Html, self).__init__(name, data)


class Unknown(BaseField):
    """Represent an unknown field. This should not happen but this kind of
    field only exists to avoid a blocking situation from a RPC point of view.
    """
    def __init__(self, name, data):
        super(Unknown, self).__init__(name, data)

    def __get__(self, instance, owner):
        value = instance._values[self.name][instance.id]
        if instance.id in instance._values_to_write[self.name]:
            value = instance._values_to_write[self.name][instance.id]