fix logout

This commit is contained in:
2026-09-06 04:31:16 +07:00
parent 47c8688884
commit 286b207f27
6 changed files with 165 additions and 98 deletions

View File

@@ -4,8 +4,8 @@ class OdooRpcHelper {
static const String _jsonRpcVersion = "2.0";
static const String _method = "call";
/// Builds the correct JSON-RPC payload for any Odoo model method
static Map<String, dynamic> buildExecuteKw({
static Map<String, dynamic> buildLogout({
required String service,
required String db,
required int uid,
required String password,
@@ -21,7 +21,40 @@ class OdooRpcHelper {
"jsonrpc": _jsonRpcVersion,
"method": _method,
"params": {
"service": "object",
"service": service,
"method": "logout",
"args": [
db,
uid,
password,
model,
method,
safeDomain,
kwargs,
],
},
"id": DateTime.now().millisecondsSinceEpoch,
};
}
/// Builds the correct JSON-RPC payload for any Odoo model method
static Map<String, dynamic> buildExecuteKw({
required String service,
required String db,
required int uid,
required String password,
required String model,
required String method,
List<dynamic> domain = const [],
Map<String, dynamic> kwargs = const {},
}) {
// Make sure domain is always a list of lists (even if empty)
final safeDomain = domain.isEmpty ? [[]] : domain;
return {
"jsonrpc": _jsonRpcVersion,
"method": _method,
"params": {
"service": service,
"method": "execute_kw",
"args": [
db,
@@ -57,6 +90,7 @@ class OdooRpcHelper {
if (order != null) kwargs["order"] = order;
return buildExecuteKw(
service: "object",
db: db,
uid: uid,
password: password,
@@ -67,6 +101,37 @@ class OdooRpcHelper {
);
}
static Map<String, dynamic> executeKw({
required String method,
required String db,
required int uid,
required String password,
required String model,
List<dynamic> domain = const [],
List<String> fields = const [],
int? limit,
int? offset,
String? order,
}) {
final kwargs = <String, dynamic>{};
if (fields.isNotEmpty) kwargs["fields"] = fields;
if (limit != null) kwargs["limit"] = limit;
if (offset != null) kwargs["offset"] = offset;
if (order != null) kwargs["order"] = order;
return buildExecuteKw(
service: "object",
db: db,
uid: uid,
password: password,
model: model,
method: method,
domain: domain,
kwargs: kwargs,
);
}
/// Convenience wrapper for create
static Map<String, dynamic> create({
required String db,
@@ -76,6 +141,7 @@ class OdooRpcHelper {
required Map<String, dynamic> values,
}) {
return buildExecuteKw(
service: "object",
db: db,
uid: uid,
password: password,