def set_width(self, model, fields): ''' Set width for the current user on the model. fields is a dictionary with key: field name and value: width. ''' ids = self.search([ ('user', '=', Transaction().user), ('model', '=', model), ('field', 'in', fields.keys()), ]) self.delete(ids) for field in fields.keys(): self.create({ 'model': model, 'field': field, 'user': Transaction().user, 'width': fields[field], })
def set_width(cls, model, fields): ''' Set width for the current user on the model. fields is a dictionary with key: field name and value: width. ''' records = cls.search([ ('user', '=', Transaction().user), ('model', '=', model), ('field', 'in', fields.keys()), ]) cls.delete(records) to_create = [] for field in fields.keys(): to_create.append({ 'model': model, 'field': field, 'user': Transaction().user, 'width': fields[field], }) if to_create: cls.create(to_create)
def set_width(cls, model, fields): """ Set width for the current user on the model. fields is a dictionary with key: field name and value: width. """ records = cls.search([("user", "=", Transaction().user), ("model", "=", model), ("field", "in", fields.keys())]) cls.delete(records) to_create = [] for field in fields.keys(): to_create.append({"model": model, "field": field, "user": Transaction().user, "width": fields[field]}) if to_create: cls.create(to_create)