OdooRepository<R extends OdooRecord> class

Base class of Odoo repository logic with RPC calls and local caching. It sends stream events on record changes. On read operation at first cached value is returned then async RPC call is issued. When RPC response arrives stream gets update with fresh value.

Constructors

OdooRepository(OdooEnvironment env)
Instantiates OdooRepository with given OdooDatabase info.

Properties

cacheKeySignature String
Gets unique part of a key for caching records of modelName of database per user
no setter
canLoadMore bool
True if local cache contains less records that remote db.
no setter
currentNextId int?
getter/setter pair
domain List
getter/setter pair
env OdooEnvironment
Holds list of all repositories
latefinal
hashCode int
The hash code for this object.
no setterinherited
isAuthenticated bool
no setter
isLoadingMore bool
Shows if cacheMoreRecords is running right now. Prevents loading more records before current request is finished.
getter/setter pair
latestRecords List<R>
Holds current Odoo records
getter/setter pair
limit int
fetch limit
getter/setter pair
modelName String
Odoo ORM model name. E.g. 'res.partner' Must be overridden to set real model name.
getter/setter pair
newIdMapping Map<int, int>
Gets mapping from cache
no setter
newIdMappingKey String
Unique key per odoo instance
no setter
newIdMappingPrefix String
newIdMapping for all Odoo instances starts with
final
nextId int
Returns next available id
no setter
offset int
getter/setter pair
order String
Allows to change default order when fetching data.
getter/setter pair
recordCacheKeyPrefix String
Returns prefix that is used caching records of modelName of database
no setter
recordIdsCacheKey String
Returns cache key to store record ids of current model. Unique per url+db+user+model.
no setter
records List<R>
Get records from local cache and trigger remote fetch if not throttling
no setter
recordStream Stream<List<R>>
Returns stream of record changed events
no setter
recordStreamActive bool
Tells whether we should send record change events to a stream. Activates when there is at least one listener.
getter/setter pair
recordStreamController StreamController<List<R>>
Record change events stream controller
getter/setter pair
remoteRecordsCount int
holds total number of records in remote database.
getter/setter pair
rpcCallKeyPrefix String
Returns cache key prefix to store call with unique key name
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
throttleDuration int
getter/setter pair
timestamp32 int
no setter

Methods

buildRpcCall(String method, int recordId, dynamic args, Map<String, dynamic> kwargs) OdooRpcCall
Helps to builds rpc call instance.
cacheDelete(R? record) Future<void>
Deletes record from cache
cacheGet(int id) → R?
Gets record from cache by record's id (odoo id).
cacheMoreRecords() Future<void>
Fetches more records from remote and adds them to list of cached records. Supposed to be used with list views.
cachePut(R record) Future<void>
Stores record in cache
clearCaches() Future<void>
Deletes all cached records
clearRecords() → void
Sends empty list of records to a stream
create(R record) Future<R>
Create new record in cache and schedule rpc call Must use call queue via execute() method to issue calls sequentially comparing to other repositories(models)
createRecordFromJson(Map<String, dynamic> json) → R
Must be overridden to create real record from json
execute({required int recordId, required String method, dynamic args = const [], Map<String, dynamic> kwargs = const {}, bool awaited = false}) Future
Executes method on recordId of current modelName. It places call to queue that is processed either immediately if network is online or when network state will be changed to online.
fetchRecords() Future<void>
Fetch records from remote and push to the stream
getrecordCacheKey(int id) String
Returns cache key name by record id
newIdToId(int newId) int
Converts newId created in offline mode to id from odoo database.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
To be implemented in concrete class
searchRead() Future<List>
Get records from remote. Must set remoteRecordsCount Read operation is issued without call queue as it is idempotent. Many repositories can call own searchRead concurrently.
setNewIdMapping({required int newId, required int realId}) Future<void>
Stores mapping to cache
startSteam() → void
Enables stream of records fetched
stopStream() → void
Disables stream of records fetched
toString() String
A string representation of this object.
inherited
Unlink record on remote db /// Must use call queue via execute() method to issue calls sequentially comparing to other repositories(models)
write(R newRecord) Future<void>
Update record in cache and schedule rpc call /// Must use call queue via execute() method to issue calls sequentially comparing to other repositories(models)

Operators

operator ==(Object other) bool
The equality operator.
inherited