How to use the odoorpc.models.IncrementalRecords 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
def check_value(self, value):
        if value:
            if not isinstance(value, list) \
                    and not isinstance(value, Model) \
                    and not isinstance(value, IncrementalRecords):
                raise ValueError(
                    "The value supplied has to be a list, a recordset "
                    "or 'False'")
        return super(Many2many, self).check_value(value)
github OCA / odoorpc / odoorpc / models.py View on Github external
except TypeError:
            records = [records]
        parent = self._from_record[0]
        field = self._from_record[1]
        updated_values = parent._values_to_write[field.name]
        values = []
        if updated_values.get(parent.id):
            values = updated_values[parent.id][:]  # Copy
        from odoorpc import fields

        for id_ in fields.records2ids(records):
            if (3, id_) in values:
                values.remove((3, id_))
            if (4, id_) not in values:
                values.append((4, id_))
        return IncrementalRecords(values)
github OCA / odoorpc / odoorpc / fields.py View on Github external
def check_value(self, value):
        if value:
            if (
                not isinstance(value, list)
                and not isinstance(value, Model)
                and not isinstance(value, IncrementalRecords)
            ):
                raise ValueError(
                    "The value supplied has to be a list, a recordset "
                    "or 'False'"
                )
        return super(Many2many, self).check_value(value)
github osiell / odoorpc / odoorpc / fields.py View on Github external
def __set__(self, instance, value):
        value = self.check_value(value)
        if isinstance(value, IncrementalRecords):
            value = value.tuples
        else:
            if value and not odoo_tuple_in(value):
                value = [(6, 0, records2ids(value))]
            elif not value:
                value = [(5, )]
        instance._values_to_write[self.name][instance.id] = value
        super(Many2many, self).__set__(instance, value)
github osiell / odoorpc / odoorpc / models.py View on Github external
list(records)
        except TypeError:
            records = [records]
        parent = self._from_record[0]
        field = self._from_record[1]
        updated_values = parent._values_to_write[field.name]
        values = []
        if updated_values.get(parent.id):
            values = updated_values[parent.id][:]  # Copy
        from odoorpc import fields
        for id_ in fields.records2ids(records):
            if (3, id_) in values:
                values.remove((3, id_))
            if (4, id_) not in values:
                values.append((4, id_))
        return IncrementalRecords(values)