Skip to content

Commit 57e9e3d

Browse files
committed
feat: add url for direct access to created and updated records
1 parent 69d35e6 commit 57e9e3d

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [0.2.2] - 2025-08-04
99

10+
### Added
11+
- **Direct Record URLs**: Added `url` field to `create_record` and `update_record` responses for direct access to records in Odoo
12+
1013
### Changed
1114
- **Minimal Response Fields**: Reduced `create_record` and `update_record` tool responses to return only essential fields (id, name, display_name) to minimize LLM context usage
1215

mcp_server_odoo/tools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,14 @@ async def _handle_create_record_tool(
783783
# Process dates in the minimal record
784784
record = self._process_record_dates(records[0], model)
785785

786+
# Generate direct URL to the record in Odoo
787+
base_url = self.config.url.rstrip("/")
788+
record_url = f"{base_url}/web#id={record_id}&model={model}&view_type=form"
789+
786790
return {
787791
"success": True,
788792
"record": record,
793+
"url": record_url,
789794
"message": f"Successfully created {model} record with ID {record_id}",
790795
}
791796

@@ -841,9 +846,14 @@ async def _handle_update_record_tool(
841846
# Process dates in the minimal record
842847
record = self._process_record_dates(records[0], model)
843848

849+
# Generate direct URL to the record in Odoo
850+
base_url = self.config.url.rstrip("/")
851+
record_url = f"{base_url}/web#id={record_id}&model={model}&view_type=form"
852+
844853
return {
845854
"success": success,
846855
"record": record,
856+
"url": record_url,
847857
"message": f"Successfully updated {model} record with ID {record_id}",
848858
}
849859

tests/test_write_tools.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def mock_config(self):
3939
config = Mock()
4040
config.default_limit = 10
4141
config.max_limit = 100
42+
config.url = "http://localhost:8069"
4243
return config
4344

4445
@pytest.fixture
@@ -68,6 +69,10 @@ async def test_create_record_success(self, tool_handler, mock_connection):
6869
# Verify
6970
assert result["success"] is True
7071
assert result["record"] == essential_record
72+
assert (
73+
result["url"]
74+
== f"http://localhost:8069/web#id={created_id}&model={model}&view_type=form"
75+
)
7176
assert "Successfully created" in result["message"]
7277
mock_connection.create.assert_called_once_with(model, values)
7378
mock_connection.read.assert_called_once_with(
@@ -111,6 +116,10 @@ async def test_update_record_success(self, tool_handler, mock_connection):
111116
# Verify
112117
assert result["success"] is True
113118
assert result["record"] == updated_record
119+
assert (
120+
result["url"]
121+
== f"http://localhost:8069/web#id={record_id}&model={model}&view_type=form"
122+
)
114123
assert "Successfully updated" in result["message"]
115124
mock_connection.write.assert_called_once_with(model, [record_id], values)
116125
# Verify both read calls with correct parameters

0 commit comments

Comments
 (0)