odoo-addon-project-task-api 16.0.1.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/project_task_api/CHANGELOG.md +26 -0
- odoo/addons/project_task_api/README.rst +121 -0
- odoo/addons/project_task_api/__init__.py +1 -0
- odoo/addons/project_task_api/__manifest__.py +26 -0
- odoo/addons/project_task_api/data/fastapi_endpoint.xml +10 -0
- odoo/addons/project_task_api/models/__init__.py +3 -0
- odoo/addons/project_task_api/models/fastapi_endpoint.py +40 -0
- odoo/addons/project_task_api/routers/__init__.py +1 -0
- odoo/addons/project_task_api/routers/project_task_router.py +253 -0
- odoo/addons/project_task_api/schemas/__init__.py +2 -0
- odoo/addons/project_task_api/schemas/common.py +6 -0
- odoo/addons/project_task_api/schemas/project_task.py +257 -0
- odoo/addons/project_task_api/static/description/icon.png +0 -0
- odoo/addons/project_task_api/tests/__init__.py +1 -0
- odoo/addons/project_task_api/tests/test_fastapi_endpoint.py +551 -0
- odoo_addon_project_task_api-16.0.1.1.2.dist-info/METADATA +141 -0
- odoo_addon_project_task_api-16.0.1.1.2.dist-info/RECORD +19 -0
- odoo_addon_project_task_api-16.0.1.1.2.dist-info/WHEEL +5 -0
- odoo_addon_project_task_api-16.0.1.1.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
from datetime import date
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
6
|
+
|
|
7
|
+
from .common import PriorityType, KanbanStateType, PositiveInt
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ProjectTaskDocument(BaseModel):
|
|
11
|
+
"""
|
|
12
|
+
Input contract for a file sent along with a task.
|
|
13
|
+
|
|
14
|
+
The content travels base64 encoded, the way it is stored, so the
|
|
15
|
+
whole request stays a JSON body like the rest of the API.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
name: str = Field(..., description="Name of the file, extension included.")
|
|
19
|
+
|
|
20
|
+
content: str = Field(..., description="Content of the file, base64 encoded.")
|
|
21
|
+
|
|
22
|
+
@field_validator("content")
|
|
23
|
+
@classmethod
|
|
24
|
+
def content_is_base64(cls, value):
|
|
25
|
+
"""
|
|
26
|
+
Answer a file that is not base64 while it is still a request, and
|
|
27
|
+
not later on, as a broken attachment nobody can open.
|
|
28
|
+
"""
|
|
29
|
+
try:
|
|
30
|
+
base64.b64decode(value, validate=True)
|
|
31
|
+
except ValueError as error:
|
|
32
|
+
raise ValueError("content is not base64 encoded") from error
|
|
33
|
+
return value
|
|
34
|
+
|
|
35
|
+
model_config = ConfigDict(
|
|
36
|
+
extra="forbid",
|
|
37
|
+
str_strip_whitespace=True,
|
|
38
|
+
json_schema_extra={
|
|
39
|
+
"example": {
|
|
40
|
+
"name": "invoice.pdf",
|
|
41
|
+
"content": "JVBERi0xLjQK",
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ProjectTaskCreatePayload(BaseModel):
|
|
48
|
+
"""
|
|
49
|
+
Output contract for project.task (Odoo ORM response).
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
name: str = Field(..., description="Task title (required in Odoo).")
|
|
53
|
+
|
|
54
|
+
project_code: str = Field(..., description="Project code (required).")
|
|
55
|
+
|
|
56
|
+
description: Optional[str] = Field(None, description="Internal task description.")
|
|
57
|
+
|
|
58
|
+
priority: Optional[PriorityType] = Field(
|
|
59
|
+
None, description="Priority (Odoo: '0' Low → '1' High)."
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
partner_ref: Optional[str] = Field(None, description="Assigned partner REF.")
|
|
63
|
+
|
|
64
|
+
contract_code: Optional[str] = Field(
|
|
65
|
+
None,
|
|
66
|
+
description=(
|
|
67
|
+
"Code of the contract the task is about. When no partner_ref is "
|
|
68
|
+
"given, the partner of the task is the one of this contract."
|
|
69
|
+
),
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
partner_phone: Optional[str] = Field(None, description="Phone number.")
|
|
73
|
+
|
|
74
|
+
partner_email: Optional[str] = Field(None, description="Email address.")
|
|
75
|
+
|
|
76
|
+
stage_id: Optional[int] = Field(None, gt=0, description="Kanban stage ID.")
|
|
77
|
+
|
|
78
|
+
date_deadline: Optional[date] = Field(
|
|
79
|
+
None, description="Deadline date (ISO format)."
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
tag_ids: Optional[List[PositiveInt]] = Field(
|
|
83
|
+
None, description="List of tag IDs associated with the task."
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
properties: Optional[Dict[str, Any]] = Field(
|
|
87
|
+
None,
|
|
88
|
+
description=(
|
|
89
|
+
"Values for the task's properties (Odoo Properties feature), "
|
|
90
|
+
"keyed by property name. Property names must already be defined "
|
|
91
|
+
"on the task's project."
|
|
92
|
+
),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
documents: List[ProjectTaskDocument] = Field(
|
|
96
|
+
default_factory=list,
|
|
97
|
+
description="Files to attach to the task, if any.",
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
model_config = ConfigDict(
|
|
101
|
+
extra="forbid",
|
|
102
|
+
str_strip_whitespace=True,
|
|
103
|
+
json_schema_extra={
|
|
104
|
+
"example": {
|
|
105
|
+
"name": "Implement authentication",
|
|
106
|
+
"project_code": "code",
|
|
107
|
+
"description": "some text",
|
|
108
|
+
"priority": "1",
|
|
109
|
+
"partner_ref": "1234",
|
|
110
|
+
"contract_code": "12345",
|
|
111
|
+
"partner_phone": "123456789",
|
|
112
|
+
"partner_email": "hello@hello.com",
|
|
113
|
+
"tag_ids": [1, 2],
|
|
114
|
+
"date_deadline": "2026-05-01",
|
|
115
|
+
"properties": {"color": "red"},
|
|
116
|
+
"documents": [{"name": "invoice.pdf", "content": "JVBERi0xLjQK"}],
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class ProjectTaskUpdatePayload(BaseModel):
|
|
123
|
+
"""
|
|
124
|
+
Input contract to partially update a project.task record.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
name: Optional[str] = Field(None, description="Task title.")
|
|
128
|
+
|
|
129
|
+
project_code: Optional[str] = Field(None, description="Project code.")
|
|
130
|
+
|
|
131
|
+
description: Optional[str] = Field(None, description="Internal task description.")
|
|
132
|
+
|
|
133
|
+
priority: Optional[PriorityType] = Field(
|
|
134
|
+
None, description="Priority (Odoo: '0' Low → '1' High)."
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
partner_ref: Optional[str] = Field(None, description="Assigned partner REF.")
|
|
138
|
+
|
|
139
|
+
contract_code: Optional[str] = Field(
|
|
140
|
+
None,
|
|
141
|
+
description=(
|
|
142
|
+
"Code of the contract the task is about. When no partner_ref is "
|
|
143
|
+
"given, the partner of the task becomes the one of this contract."
|
|
144
|
+
),
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
partner_phone: Optional[str] = Field(None, description="Phone number.")
|
|
148
|
+
|
|
149
|
+
partner_email: Optional[str] = Field(None, description="Email address.")
|
|
150
|
+
|
|
151
|
+
stage_id: Optional[int] = Field(None, gt=0, description="Kanban stage ID.")
|
|
152
|
+
|
|
153
|
+
date_deadline: Optional[date] = Field(
|
|
154
|
+
None, description="Deadline date (ISO format)."
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
tag_ids: Optional[List[PositiveInt]] = Field(
|
|
158
|
+
None, description="List of tag IDs associated with the task."
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
properties: Optional[Dict[str, Any]] = Field(
|
|
162
|
+
None,
|
|
163
|
+
description=(
|
|
164
|
+
"Values for the task's properties (Odoo Properties feature), "
|
|
165
|
+
"keyed by property name. Property names must already be defined "
|
|
166
|
+
"on the task's project."
|
|
167
|
+
),
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
model_config = ConfigDict(
|
|
171
|
+
extra="forbid",
|
|
172
|
+
str_strip_whitespace=True,
|
|
173
|
+
json_schema_extra={
|
|
174
|
+
"example": {
|
|
175
|
+
"name": "Implement authentication",
|
|
176
|
+
"description": "some text",
|
|
177
|
+
"priority": "1",
|
|
178
|
+
"contract_code": "12345",
|
|
179
|
+
"partner_phone": "123456789",
|
|
180
|
+
"partner_email": "hello@hello.com",
|
|
181
|
+
"tag_ids": [1, 2],
|
|
182
|
+
"date_deadline": "2026-05-01",
|
|
183
|
+
"properties": {"color": "red"},
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class ProjectTaskPresenter(BaseModel):
|
|
190
|
+
"""
|
|
191
|
+
Output contract for project.task (Odoo ORM response).
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
id: int = Field(..., description="Task ID")
|
|
195
|
+
|
|
196
|
+
name: str = Field(..., description="Task title")
|
|
197
|
+
|
|
198
|
+
description: Optional[str] = Field(None, description="Task description")
|
|
199
|
+
|
|
200
|
+
project_id: int = Field(..., description="Project ID")
|
|
201
|
+
|
|
202
|
+
partner_phone: Optional[str] = Field(None, description="Phone number")
|
|
203
|
+
|
|
204
|
+
partner_email: Optional[str] = Field(None, description="Email address")
|
|
205
|
+
|
|
206
|
+
priority: PriorityType = Field(None, description="Priority level")
|
|
207
|
+
|
|
208
|
+
kanban_state: KanbanStateType = Field(None, description="Kanban state")
|
|
209
|
+
|
|
210
|
+
partner_id: Optional[int] = Field(None, description="Partner ID")
|
|
211
|
+
|
|
212
|
+
contract_code: Optional[str] = Field(
|
|
213
|
+
None, description="Code of the contract the task is about"
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
stage_id: Optional[int] = Field(None, description="Stage id")
|
|
217
|
+
|
|
218
|
+
date_deadline: Optional[date] = Field(None, description="Deadline")
|
|
219
|
+
|
|
220
|
+
tag_ids: List[PositiveInt] = Field(
|
|
221
|
+
None, description="List of tag IDs associated with the task."
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
task_properties: Optional[List[Dict[str, Any]]] = Field(
|
|
225
|
+
None,
|
|
226
|
+
description=(
|
|
227
|
+
"Values for the task's properties (Odoo Properties feature), "
|
|
228
|
+
"keyed by property name"
|
|
229
|
+
),
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
sequence: int = Field(None, description="Ordering index")
|
|
233
|
+
|
|
234
|
+
model_config = ConfigDict(
|
|
235
|
+
from_attributes=True,
|
|
236
|
+
extra="ignore",
|
|
237
|
+
json_schema_extra={
|
|
238
|
+
"example": {
|
|
239
|
+
"id": 12,
|
|
240
|
+
"name": "Implement authentication",
|
|
241
|
+
"description": "OAuth2 integration",
|
|
242
|
+
"project_code": "2",
|
|
243
|
+
"priority": "3",
|
|
244
|
+
"kanban_state": "normal",
|
|
245
|
+
"contract_code": "12345",
|
|
246
|
+
"partner_ref": "1234",
|
|
247
|
+
"partner_name": "Emma",
|
|
248
|
+
"partner_phone": "123456789",
|
|
249
|
+
"partner_email": "hello@hello.com",
|
|
250
|
+
"stage": "new",
|
|
251
|
+
"date_deadline": "2026-05-01",
|
|
252
|
+
"tags": [1, 2],
|
|
253
|
+
"sequence": 10,
|
|
254
|
+
"task_properties": {"color": "red"},
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
)
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import test_fastapi_endpoint
|