├── .devcontainer ├── devcontainer.json └── docker-compose.yml ├── .gitignore ├── .mailmap ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── LICENSE ├── README.md ├── addons └── .gitkeep ├── assets └── wkhtmltox_0.12.5-1.stretch_amd64.deb ├── coder.py ├── config.yaml ├── config └── odoo.conf ├── docker-compose.yml ├── docker ├── Dockerfile ├── odoo17 │ └── .gitkeep └── requirements.txt ├── download.sh ├── mcp_server.py ├── nginx └── default.conf ├── odoo-bin └── odoo.conf /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the 2 | // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose 3 | { 4 | "name": "Existing Docker Compose (Extend)", 5 | 6 | // Update the 'dockerComposeFile' list if you have more compose files or use different names. 7 | // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. 8 | "dockerComposeFile": [ 9 | "../docker-compose.yml", 10 | "docker-compose.yml" 11 | ], 12 | 13 | // The 'service' property is the name of the service for the container that VS Code should 14 | // use. Update this value and .devcontainer/docker-compose.yml to the real service name. 15 | "service": "web", 16 | 17 | // The optional 'workspaceFolder' property is the path VS Code should open by default when 18 | // connected. This is typically a file mount in .devcontainer/docker-compose.yml 19 | "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", 20 | "customizations": { 21 | "vscode": { 22 | "extensions": [ 23 | "ms-python.vscode-pylance", 24 | "ms-python.python", 25 | "charliermarsh.ruff" 26 | ] 27 | } 28 | } 29 | 30 | // Features to add to the dev container. More info: https://containers.dev/features. 31 | // "features": {}, 32 | 33 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 34 | , 35 | "forwardPorts": [ 36 | 8000 37 | ], 38 | "features": { 39 | "ghcr.io/devcontainers/features/git:1": {} 40 | } 41 | 42 | // Uncomment the next line if you want start specific services in your Docker Compose config. 43 | // "runServices": [], 44 | 45 | // Uncomment the next line if you want to keep your containers running after VS Code shuts down. 46 | // "shutdownAction": "none", 47 | 48 | // Uncomment the next line to run commands after the container is created. 49 | // "postCreateCommand": "cat /etc/os-release", 50 | 51 | // Configure tool-specific properties. 52 | // "customizations": {}, 53 | 54 | // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. 55 | // "remoteUser": "devcontainer" 56 | } 57 | -------------------------------------------------------------------------------- /.devcontainer/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.3' 2 | services: 3 | # Update this to the name of the service you want to work with in your docker-compose.yml file 4 | web: 5 | # Uncomment if you want to override the service's Dockerfile to one in the .devcontainer 6 | # folder. Note that the path of the Dockerfile and context is relative to the *primary* 7 | # docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile" 8 | # array). The sample below assumes your primary file is in the root of your project. 9 | # 10 | # build: 11 | # context: . 12 | # dockerfile: .devcontainer/Dockerfile 13 | 14 | volumes: 15 | # Update this to wherever you want VS Code to mount the folder of your project 16 | - .:/workspaces:cached 17 | 18 | # Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust. 19 | # cap_add: 20 | # - SYS_PTRACE 21 | # security_opt: 22 | # - seccomp:unconfined 23 | 24 | # Overrides default command so things don't shut down after the process ends. 25 | command: /bin/sh -c "while sleep 1000; do :; done" 26 | 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # General 2 | .DS_Store 3 | .AppleDouble 4 | .LSOverride 5 | 6 | # Icon must end with two \r 7 | Icon 8 | 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear in the root of a volume 14 | .DocumentRevisions-V100 15 | .fseventsd 16 | .Spotlight-V100 17 | .TemporaryItems 18 | .Trashes 19 | .VolumeIcon.icns 20 | .com.apple.timemachine.donotpresent 21 | 22 | # Directories potentially created on remote AFP share 23 | .AppleDB 24 | .AppleDesktop 25 | Network Trash Folder 26 | Temporary Items 27 | .apdisk 28 | addons/* 29 | odoo/* 30 | docker/odoo16/* 31 | docker/odoo17/* 32 | docker/odoo*/* -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | jeffery 2 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Python: odoo-bin", 9 | "type": "python", 10 | "request": "launch", 11 | "program": "odoo-bin", 12 | "args": ["-c", "odoo.conf"], 13 | "console": "integratedTerminal", 14 | // "gevent": true, 15 | // "subProcess": true, 16 | "cwd": "${workspaceFolder}", 17 | 18 | "pathMappings": [ 19 | { 20 | "localRoot": "${workspaceFolder}/addons", 21 | "remoteRoot": "/mnt/extra-addons" 22 | }, 23 | { 24 | "localRoot": "${workspaceFolder}/docker/odoo17/odoo", 25 | "remoteRoot": "/usr/lib/python3/dist-packages/odoo" 26 | } 27 | ], 28 | "justMyCode": false 29 | 30 | }, 31 | 32 | ] 33 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "git.ignoreLimitWarning": true 3 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "run Odoo", 8 | "type": "shell", 9 | "command": "odoo -c odoo.conf", 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # odoo_docker 2 | 3 | ### 介绍 4 | run Odoo in Docker 5 | 6 | ### 安装运行环境 7 | 8 | #### Ubuntu 9 | - 安装 docker 10 | 11 | ref. https://docs.docker.com/engine/install/ubuntu/ 12 | 13 | - 安装 docker compose 14 | 15 | #### MAC 16 | - 安装 docker for desktop 17 | 18 | ref. https://docs.docker.com/desktop/mac/install/ 19 | 20 | - 安装 docker compose 21 | 22 | 23 | #### Windows 24 | - 安装 docker for desktop 25 | 26 | ref. https://docs.docker.com/desktop/windows/install/ 27 | 28 | - 安装 docker compose 29 | 30 | 31 | ### 运行odoo 32 | 33 | 1. 克隆本仓库到本地目录,例如 `odoo-docker` 34 | 1. 执行下面的命令运行 Odoo 35 | 36 | ```bash 37 | 38 | cd odoo-docker 39 | bash download.sh 40 | docker-compose up --build -d 41 | 42 | ``` 43 | 3. docker将会拉取相关的镜像,然后运行项目 44 | 4. 浏览器打开 http://localhost:8000 45 | 46 | 47 | 48 | ### FAQ 49 | 50 | 1. #### Docker 报错 `Get https://registry-1.docker.io/v2/: unable to connect to HTTP proxy 127.0.0.1:1080` , 此时你需要使用 Docker 镜像注册中心 51 | 52 | 调整 docker 配置增加中国本地注册器镜像, 53 | ``` 54 | { 55 | "registry-mirrors": [ 56 | "https://registry.docker-cn.com", 57 | "https://docker.mirrors.ustc.edu.cn" 58 | ] 59 | } 60 | ``` 61 | 62 | 63 | -------------------------------------------------------------------------------- /addons/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffery9/odoo-devcontainer/1b561bc036031f473aa9de1ce6b23f3dbd351172/addons/.gitkeep -------------------------------------------------------------------------------- /assets/wkhtmltox_0.12.5-1.stretch_amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffery9/odoo-devcontainer/1b561bc036031f473aa9de1ce6b23f3dbd351172/assets/wkhtmltox_0.12.5-1.stretch_amd64.deb -------------------------------------------------------------------------------- /coder.py: -------------------------------------------------------------------------------- 1 | import yaml 2 | import os 3 | import subprocess 4 | import requests 5 | import json 6 | from langgraph import Graph, Node 7 | 8 | # Qwen API 配置 9 | QWEN_API_URL = "https://api.qwen.com/v1/chat" # 替换为实际 API 地址 10 | QWEN_API_KEY = os.getenv("QWEN_API_KEY", "your_api_key_here") # 使用环境变量存储密钥 11 | 12 | # 调用 Qwen API 13 | def call_qwen(prompt): 14 | headers = { 15 | "Authorization": f"Bearer {QWEN_API_KEY}", 16 | "Content-Type": "application/json" 17 | } 18 | data = { 19 | "prompt": prompt, 20 | "max_tokens": 500 21 | } 22 | try: 23 | response = requests.post(QWEN_API_URL, headers=headers, json=data) 24 | response.raise_for_status() # 检查 HTTP 错误 25 | return response.json()["response"] 26 | except requests.exceptions.RequestException as e: 27 | raise Exception(f"Error calling Qwen API: {str(e)}") 28 | 29 | # 辅助函数:安全加载 YAML 文件 30 | def load_yaml(file_path): 31 | try: 32 | with open(file_path, "r") as file: 33 | return yaml.safe_load(file) 34 | except Exception as e: 35 | raise Exception(f"Error loading YAML file: {str(e)}") 36 | 37 | # 辅助函数:写入文件 38 | def write_file(file_path, content): 39 | try: 40 | with open(file_path, "w") as file: 41 | file.write(content) 42 | except Exception as e: 43 | raise Exception(f"Error writing to file: {str(e)}") 44 | 45 | # 定义 LangGraph 46 | graph = Graph() 47 | 48 | # Step 1: 解析环境配置模块 49 | def parse_environment_config(state): 50 | config_file = state["config_file"] # 假设用户提供了 YAML 配置文件路径 51 | config = load_yaml(config_file) 52 | odoo_version = config.get("odoo_version", "16.0") 53 | base_modules = config.get("base_modules", []) 54 | compose_dir = config.get("compose_directory", "./test_env") 55 | test_database_name = config.get("test_database_name", "test_db") # 从配置中读取测试数据库名称 56 | return { 57 | "odoo_version": odoo_version, 58 | "base_modules": base_modules, 59 | "compose_directory": compose_dir, 60 | "test_database_name": test_database_name 61 | } 62 | 63 | graph.add_node("ParseEnvironmentConfig", parse_environment_config) 64 | 65 | # Step 2: 动态生成或更新 Docker Compose 文件 66 | def generate_or_update_docker_compose_files(state): 67 | odoo_version = state["odoo_version"] 68 | base_modules = state["base_modules"] 69 | compose_dir = state["compose_directory"] 70 | compose_file_path = os.path.join(compose_dir, "docker-compose.yml") 71 | os.makedirs(compose_dir, exist_ok=True) 72 | 73 | if os.path.exists(compose_file_path): 74 | existing_compose = load_yaml(compose_file_path) 75 | current_odoo_version = existing_compose["services"]["web"]["image"].split(":")[1] 76 | if current_odoo_version != odoo_version: 77 | print(f"Updating Odoo version from {current_odoo_version} to {odoo_version}") 78 | existing_compose["services"]["web"]["image"] = f"odoo:{odoo_version}" 79 | write_file(compose_file_path, yaml.dump(existing_compose, default_flow_style=False)) 80 | else: 81 | print(f"Using existing Odoo version: {odoo_version}") 82 | else: 83 | docker_compose_content = f""" 84 | version: '3.8' 85 | services: 86 | web: 87 | image: odoo:{odoo_version} 88 | depends_on: 89 | - db 90 | ports: 91 | - "8069:8069" 92 | environment: 93 | - HOST=db 94 | - USER=odoo 95 | - PASSWORD=odoo 96 | volumes: 97 | - ./addons:/mnt/extra-addons 98 | - ./tests:/mnt/tests 99 | command: -- --dev=all 100 | db: 101 | image: postgres:13 102 | environment: 103 | - POSTGRES_DB=postgres 104 | - POSTGRES_PASSWORD=odoo 105 | - POSTGRES_USER=odoo 106 | volumes: 107 | - ./data:/var/lib/postgresql/data 108 | """ 109 | write_file(compose_file_path, docker_compose_content) 110 | 111 | env_content = f""" 112 | ODOO_VERSION={odoo_version} 113 | BASE_MODULES={",".join(base_modules)} 114 | """ 115 | write_file(os.path.join(compose_dir, ".env"), env_content) 116 | return {"compose_directory": compose_dir} 117 | 118 | graph.add_node("GenerateOrUpdateDockerComposeFiles", generate_or_update_docker_compose_files) 119 | 120 | # Step 3: 启动或更新测试环境 121 | def start_or_update_test_environment(state): 122 | compose_dir = state["compose_directory"] 123 | compose_file_path = os.path.join(compose_dir, "docker-compose.yml") 124 | try: 125 | if os.path.exists(compose_file_path): 126 | print("Pulling latest images and updating containers...") 127 | subprocess.run(["docker-compose", "pull"], cwd=compose_dir, check=True) 128 | subprocess.run(["docker-compose", "up", "-d"], cwd=compose_dir, check=True) 129 | return {"environment_status": "updated"} 130 | else: 131 | print("Starting new test environment...") 132 | subprocess.run(["docker-compose", "up", "-d"], cwd=compose_dir, check=True) 133 | return {"environment_status": "started"} 134 | except subprocess.CalledProcessError as e: 135 | return {"environment_status": "failed", "error": str(e)} 136 | 137 | graph.add_node("StartOrUpdateTestEnvironment", start_or_update_test_environment) 138 | 139 | # Step 4: 分析现有功能并保存分析结果 140 | def analyze_existing_features(state): 141 | compose_directory = state["compose_directory"] 142 | analysis_file = os.path.join(compose_directory, "feature_analysis.json") 143 | 144 | # 加载已有的功能分析结果(如果存在) 145 | if os.path.exists(analysis_file): 146 | with open(analysis_file, "r") as file: 147 | feature_analysis = json.load(file) 148 | else: 149 | feature_analysis = {} 150 | 151 | # 调用 LLM 分析现有功能 152 | prompt = f""" 153 | You are an AI agent following the Odoo Framework, Odoo App, and Business Flow. 154 | Your task is to analyze the existing features of the system. 155 | Current Feature Analysis: {feature_analysis} 156 | Instructions: 157 | - Identify all models in the system. 158 | - For each model, extract the following information: 159 | - Fields: List all fields (e.g., name, price, image). 160 | - Related Models: List related models (e.g., Many2one, One2many relationships). 161 | - Business Rules: Describe any constraints or validation rules (e.g., price must be positive). 162 | - Business Logic: Explain the functionality (e.g., sorting products by price). 163 | - Organize the analysis result by model and include business rules and logic. 164 | Output: 165 | - Return the updated feature analysis as a dictionary with the following structure: 166 | {{ 167 | "models": {{ 168 | "model_name_1": {{ 169 | "fields": [list of fields], 170 | "related_models": [list of related models], 171 | "business_rules": [list of business rules], 172 | "business_logic": [description of business logic] 173 | }} 174 | }} 175 | }} 176 | """ 177 | result = call_qwen(prompt) 178 | 179 | # 保存更新后的功能分析结果 180 | with open(analysis_file, "w") as file: 181 | json.dump(result, file, indent=4) 182 | return {"feature_analysis": result["models"]} 183 | 184 | graph.add_node("AnalyzeExistingFeatures", analyze_existing_features) 185 | 186 | # Step 5: 汇聚环境准备结果 187 | def join_environment_preparation(state): 188 | return { 189 | "compose_directory": state["GenerateOrUpdateDockerComposeFiles"]["compose_directory"], 190 | "environment_status": state["StartOrUpdateTestEnvironment"]["environment_status"], 191 | "feature_analysis": state["AnalyzeExistingFeatures"] 192 | } 193 | 194 | graph.add_node("JoinEnvironmentPreparation", join_environment_preparation) 195 | 196 | # Step 6: 解析需求并生成 BDD 测试用例 197 | def parse_requirements(state): 198 | user_story = state["user_story"] 199 | acceptance_criteria = state["acceptance_criteria"] 200 | module_name = state["module_name"] # 新增字段 201 | feature_analysis = state["feature_analysis"] 202 | 203 | relevant_analysis = { 204 | model: details for model, details in feature_analysis.items() 205 | if model.lower() in user_story.lower() 206 | } 207 | 208 | prompt = f""" 209 | You are an AI agent following the Odoo Framework, Odoo App, and Business Flow. 210 | Your task is to analyze the user story and acceptance criteria. 211 | ### User Story: 212 | {user_story} 213 | ### Acceptance Criteria: 214 | {acceptance_criteria} 215 | ### Relevant Feature Analysis: 216 | {relevant_analysis} 217 | Instructions: 218 | - Extract the following information: 219 | - Models: List all models and their fields. 220 | - Views: Describe the UI components (e.g., form view, tree view). 221 | - Business Rules: Include any constraints or validation rules. 222 | - Business Logic: Explain the functionality. 223 | - Convert acceptance criteria into BDD test cases using Gherkin syntax. 224 | Output: 225 | - Return the extracted requirements and BDD test cases as a dictionary with the following structure: 226 | {{ 227 | "requirements": {{ 228 | "models": [list of models and fields], 229 | "views": [list of views and their descriptions], 230 | "business_rules": [list of business rules], 231 | "business_logic": [description of business logic] 232 | }}, 233 | "bdd_test_cases": {{ 234 | "test_case_1.feature": "Gherkin syntax for test case 1", 235 | "test_case_2.feature": "Gherkin syntax for test case 2" 236 | }} 237 | }} 238 | """ 239 | result = call_qwen(prompt) 240 | return { 241 | "requirements": result["requirements"], 242 | "bdd_test_cases": result["bdd_test_cases"], 243 | "module_name": module_name 244 | } 245 | 246 | graph.add_node("ParseRequirements", parse_requirements) 247 | 248 | # Step 7: 根据 BDD 测试用例生成测试代码 249 | def generate_test_code(state): 250 | bdd_test_cases = state["bdd_test_cases"] 251 | compose_directory = state["compose_directory"] 252 | module_name = state["module_name"] 253 | 254 | prompt = f""" 255 | You are an AI agent following the Odoo Framework, Odoo App, and Business Flow. 256 | Your task is to generate Python test code based on the given BDD test cases. 257 | BDD Test Cases: 258 | {bdd_test_cases} 259 | Instructions: 260 | - Write Python test code using the Odoo testing framework. 261 | - Ensure the test code covers all scenarios described in the BDD test cases. 262 | Output: 263 | - Return the generated test code as a dictionary with filenames as keys and code as values. 264 | """ 265 | result = call_qwen(prompt) 266 | tests_dir = os.path.join(compose_directory, "tests", module_name) # 使用 module 名称作为子目录 267 | os.makedirs(tests_dir, exist_ok=True) 268 | for filename, content in result.items(): 269 | write_file(os.path.join(tests_dir, filename), content) 270 | return {"test_code_generated": True, "module_name": module_name} 271 | 272 | graph.add_node("GenerateTestCode", generate_test_code) 273 | 274 | # Step 8: 根据需求分析生成业务代码 275 | def generate_business_code(state): 276 | requirements = state["requirements"] 277 | compose_directory = state["compose_directory"] 278 | module_name = state["module_name"] 279 | 280 | prompt = f""" 281 | You are an AI agent following the Odoo Framework, Odoo App, and Business Flow. 282 | Your task is to generate business code based on the given requirements. 283 | Requirements: 284 | - Models: {requirements["models"]} 285 | - Views: {requirements["views"]} 286 | - Business Rules: {requirements["business_rules"]} 287 | - Business Logic: {requirements["business_logic"]} 288 | Instructions: 289 | - Generate Python code for models. 290 | - Design XML views. 291 | - Implement business rules and logic. 292 | - Ensure the code satisfies the requirements. 293 | Output: 294 | - Return the generated business code as a dictionary with filenames as keys and code as values. 295 | """ 296 | result = call_qwen(prompt) 297 | addons_dir = os.path.join(compose_directory, "addons", module_name) # 使用 module 名称作为子目录 298 | os.makedirs(addons_dir, exist_ok=True) 299 | for filename, content in result.items(): 300 | write_file(os.path.join(addons_dir, filename), content) 301 | return {"business_code_generated": True, "module_name": module_name} 302 | 303 | graph.add_node("GenerateBusinessCode", generate_business_code) 304 | 305 | # Step 9: 运行测试代码 306 | def run_tests(state): 307 | compose_directory = state["compose_directory"] 308 | test_database_name = state.get("test_database_name") 309 | module_name = state.get("module_name") 310 | if not test_database_name or not module_name: 311 | return {"test_results": "failed", "error": "Missing test_database_name or module_name in state."} 312 | 313 | try: 314 | print(f"Installing module '{module_name}' and running tests on database '{test_database_name}'...") 315 | install_command = [ 316 | "docker-compose", "exec", "web", 317 | "odoo-bin", "-d", test_database_name, "-i", module_name 318 | ] 319 | subprocess.run(install_command, cwd=compose_directory, check=True) 320 | 321 | test_command = [ 322 | "docker-compose", "exec", "web", 323 | "odoo-bin", "-d", test_database_name, "--test-enable" 324 | ] 325 | result = subprocess.run( 326 | test_command, 327 | cwd=compose_directory, 328 | capture_output=True, 329 | text=True 330 | ) 331 | if result.returncode == 0: 332 | return {"test_results": "All tests passed!"} 333 | else: 334 | return {"test_results": "Some tests failed.", "error": result.stderr} 335 | except subprocess.CalledProcessError as e: 336 | return {"test_results": "Some tests failed.", "error": str(e)} 337 | 338 | graph.add_node("RunTests", run_tests) 339 | 340 | # Step 10: 修复代码 341 | def fix_code(state): 342 | error_log = state["test_results"]["error"] 343 | module_name = state["module_name"] 344 | 345 | prompt = f""" 346 | You are an AI agent following the Odoo Framework, Odoo App, and Business Flow. 347 | Your task is to analyze the error log and suggest fixes. 348 | Error Log: {error_log} 349 | Instructions: 350 | - Identify the root cause of the error. 351 | - Suggest a fix for the issue. 352 | - Validate the fix against the original requirements. 353 | - Apply the fix and update the code. 354 | Output: 355 | - Return the fixed code as a dictionary with filenames as keys and code as values. 356 | """ 357 | fixed_code = call_qwen(prompt) 358 | addons_dir = os.path.join(state["compose_directory"], "addons", module_name) 359 | for filename, content in fixed_code.items(): 360 | write_file(os.path.join(addons_dir, filename), content) 361 | return {"fixed_code": True, "module_name": module_name} 362 | 363 | graph.add_node("FixCode", fix_code) 364 | 365 | # Step 11: 重启容器以加载新代码 366 | def restart_containers(state): 367 | compose_directory = state["compose_directory"] 368 | try: 369 | print("Restarting containers to apply new code...") 370 | subprocess.run(["docker-compose", "restart"], cwd=compose_directory, check=True) 371 | return {"restart_status": "success"} 372 | except subprocess.CalledProcessError as e: 373 | return {"restart_status": "failed", "error": str(e)} 374 | 375 | graph.add_node("RestartContainers", restart_containers) 376 | 377 | # 定义节点之间的连接 378 | graph.add_edge("ParseEnvironmentConfig", "GenerateOrUpdateDockerComposeFiles") 379 | graph.add_edge("ParseEnvironmentConfig", "StartOrUpdateTestEnvironment") 380 | graph.add_edge("ParseEnvironmentConfig", "AnalyzeExistingFeatures") 381 | 382 | graph.add_edge("GenerateOrUpdateDockerComposeFiles", "JoinEnvironmentPreparation") 383 | graph.add_edge("StartOrUpdateTestEnvironment", "JoinEnvironmentPreparation") 384 | graph.add_edge("AnalyzeExistingFeatures", "JoinEnvironmentPreparation") 385 | 386 | graph.add_edge("JoinEnvironmentPreparation", "ParseRequirements") 387 | graph.add_edge("ParseRequirements", "GenerateTestCode") 388 | graph.add_edge("ParseRequirements", "GenerateBusinessCode") 389 | graph.add_edge("GenerateTestCode", "RunTests") 390 | graph.add_edge("GenerateBusinessCode", "RunTests") 391 | 392 | graph.add_conditional_edge( 393 | "RunTests", 394 | lambda state: "FixCode" if "error" in state["test_results"] else "RestartContainers" 395 | ) 396 | graph.add_edge("FixCode", "GenerateBusinessCode") 397 | 398 | # 执行 LangGraph 399 | def run_langgraph(user_story, acceptance_criteria, module_name, config_file): 400 | initial_state = { 401 | "config_file": config_file, 402 | "user_story": user_story, 403 | "acceptance_criteria": acceptance_criteria, 404 | "module_name": module_name 405 | } 406 | return graph.run(initial_state) 407 | 408 | # 支持批量处理 409 | def batch_process(stories_and_criteria, config_file): 410 | results = [] 411 | for item in stories_and_criteria: 412 | user_story = item.get("user_story") 413 | acceptance_criteria = item.get("acceptance_criteria") 414 | module_name = item.get("module") # 获取模块名称 415 | print(f"Processing user story: {user_story}") 416 | result = run_langgraph(user_story, acceptance_criteria, module_name, config_file) 417 | results.append({ 418 | "user_story": user_story, 419 | "acceptance_criteria": acceptance_criteria, 420 | "module_name": module_name, 421 | "result": result 422 | }) 423 | return results 424 | 425 | # 后端入口点 426 | if __name__ == "__main__": 427 | # 示例输入 428 | stories_and_criteria = [ 429 | { 430 | "user_story": "As a user, I want to see a list of products.", 431 | "acceptance_criteria": [ 432 | "The product list should display name, price, and image.", 433 | "The product list should be sortable by price." 434 | ], 435 | "module": "product_list_module" # 模块名称 436 | }, 437 | { 438 | "user_story": "As a user, I want to add products to my cart.", 439 | "acceptance_criteria": [ 440 | "The user can select a product and add it to the cart.", 441 | "The cart should display the total price." 442 | ], 443 | "module": "shopping_cart_module" # 模块名称 444 | } 445 | ] 446 | config_file = "./config.yaml" 447 | # 批量处理 448 | results = batch_process(stories_and_criteria, config_file) 449 | print("Batch Processing Results:") 450 | for idx, result in enumerate(results): 451 | print(f"Result {idx + 1}:") 452 | print(result) -------------------------------------------------------------------------------- /config.yaml: -------------------------------------------------------------------------------- 1 | odoo: 2 | docker_compose_path: docker-compose.yml 3 | odoo_service_name: web 4 | odoo_module_path: addons/myaddons 5 | odoo_test_module: base 6 | 7 | mcp: 8 | mcp_server_port: 8080 9 | -------------------------------------------------------------------------------- /config/odoo.conf: -------------------------------------------------------------------------------- 1 | [options] 2 | addons_path = /mnt/extra-addons 3 | admin_passwd = 1234 4 | csv_internal_sep = , 5 | data_dir = /var/lib/odoo 6 | db_host = db 7 | db_maxconn = 64 8 | db_maxconn_gevent = False 9 | db_name = False 10 | db_password = odoo 11 | db_port = False 12 | db_sslmode = prefer 13 | db_template = template0 14 | db_user = odoo 15 | dbfilter = 16 | demo = {} 17 | email_from = False 18 | from_filter = False 19 | geoip_city_db = /usr/share/GeoIP/GeoLite2-City.mmdb 20 | geoip_country_db = /usr/share/GeoIP/GeoLite2-Country.mmdb 21 | gevent_port = 8072 22 | http_enable = True 23 | http_interface = 24 | http_port = 8069 25 | import_partial = 26 | limit_memory_hard = 2684354560 27 | limit_memory_soft = 2147483648 28 | limit_request = 65536 29 | limit_time_cpu = 60 30 | limit_time_real = 120 31 | limit_time_real_cron = -1 32 | list_db = True 33 | log_db = False 34 | log_db_level = warning 35 | log_handler = :INFO 36 | log_level = info 37 | logfile = 38 | max_cron_threads = 2 39 | osv_memory_count_limit = 0 40 | pg_path = 41 | pidfile = 42 | proxy_mode = False 43 | reportgz = False 44 | screencasts = 45 | screenshots = /tmp/odoo_tests 46 | server_wide_modules = base,web 47 | smtp_password = False 48 | smtp_port = 25 49 | smtp_server = localhost 50 | smtp_ssl = False 51 | smtp_ssl_certificate_filename = False 52 | smtp_ssl_private_key_filename = False 53 | smtp_user = False 54 | syslog = False 55 | test_enable = False 56 | test_file = 57 | test_tags = None 58 | transient_age_limit = 1.0 59 | translate_modules = ['all'] 60 | unaccent = False 61 | upgrade_path = 62 | websocket_keep_alive_timeout = 3600 63 | websocket_rate_limit_burst = 10 64 | websocket_rate_limit_delay = 0.2 65 | without_demo = False 66 | workers = 0 67 | x_sendfile = False -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.3' 2 | 3 | services: 4 | # Web Application Service Definition 5 | # -------- 6 | # 7 | # All of the information needed to start up an odoo web 8 | # application container. 9 | web: 10 | image: odoo:18.0 11 | # build: ./docker 12 | 13 | depends_on: 14 | - db 15 | 16 | restart: "no" 17 | 18 | # Port Mapping 19 | # -------- 20 | # 21 | # Here we are mapping a port on the host machine (on the left) 22 | # to a port inside of the container (on the right.) The default 23 | # port on Odoo is 8069, so Odoo is running on that port inside 24 | # of the container. But we are going to access it locally on 25 | # our machine from localhost:9000. 26 | # ports: 27 | # - 8069:8069 28 | 29 | # Data Volumes 30 | # -------- 31 | # 32 | # This defines files that we are mapping from the host machine 33 | # into the container. 34 | # 35 | # Right now, we are using it to map a configuration file into 36 | # the container and any extra odoo modules. 37 | volumes: 38 | - ./config:/etc/odoo 39 | - ./addons:/mnt/extra-addons 40 | - odoo:/var/lib/odoo 41 | 42 | # Odoo Environment Variables 43 | # -------- 44 | # 45 | # The odoo image uses a few different environment 46 | # variables when running to connect to the postgres 47 | # database. 48 | # 49 | # Make sure that they are the same as the database user 50 | # defined in the db container environment variables. 51 | environment: 52 | - HOST=db 53 | - USER=odoo 54 | - PASSWORD=odoo 55 | 56 | # Database Container Service Definition 57 | # -------- 58 | # 59 | # All of the information needed to start up a postgresql 60 | # container. 61 | db: 62 | image: postgres:14 63 | restart: "no" 64 | 65 | volumes: 66 | - postgresql:/var/lib/postgresql/data 67 | 68 | # Database Environment Variables 69 | # -------- 70 | # 71 | # The postgresql image uses a few different environment 72 | # variables when running to create the database. Set the 73 | # username and password of the database user here. 74 | # 75 | # Make sure that they are the same as the database user 76 | # defined in the web container environment variables. 77 | environment: 78 | - POSTGRES_PASSWORD=odoo 79 | - POSTGRES_USER=odoo 80 | - POSTGRES_DB=postgres # Leave this set to postgres 81 | 82 | nginx: 83 | image: nginx 84 | restart: "no" 85 | volumes: 86 | - ./nginx:/etc/nginx/conf.d 87 | ports: 88 | - 8000:80 89 | environment: 90 | - NGINX_PORT=80 91 | depends_on: 92 | - web 93 | - pgadmin 94 | 95 | pgadmin: 96 | image: dpage/pgadmin4 97 | restart: "no" 98 | depends_on: 99 | - db 100 | environment: 101 | PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-admin@g.cn} 102 | PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin} 103 | volumes: 104 | - pgadmin:/root/.pgadmin 105 | # ports: 106 | # - "${PGADMIN_PORT:-5050}:80" 107 | 108 | volumes: 109 | pgadmin: 110 | postgresql: 111 | odoo: 112 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM odoo:18.0 2 | USER root 3 | 4 | RUN set -x;\ 5 | sed -i "s/deb.ubuntu.com/mirrors.aliyun.com/" /etc/apt/sources.list && \ 6 | sed -i "s/archive.ubuntu.com/mirrors.aliyun.com/" /etc/apt/sources.list && \ 7 | sed -i "s/security.ubuntu.com/mirrors.aliyun.com/" /etc/apt/sources.list 8 | 9 | RUN set -x; \ 10 | apt-get update \ 11 | && apt-get install -y procps sudo git git-lfs \ 12 | && rm -rf /var/lib/apt/lists/* 13 | 14 | # override odoo source codes 15 | # COPY odoo18/odoo /usr/lib/python3/dist-packages/odoo 16 | 17 | RUN set -x; \ 18 | pip3 install -i https://mirrors.aliyun.com/pypi/simple --upgrade pip 19 | 20 | COPY requirements.txt ./ 21 | RUN set -x; \ 22 | pip3 install -i https://mirrors.aliyun.com/pypi/simple -r ./requirements.txt 23 | 24 | RUN usermod -aG sudo odoo 25 | RUN usermod -s /bin/bash odoo 26 | RUN echo "odoo:odoo" | chpasswd 27 | # Set default user when running the container 28 | USER odoo 29 | -------------------------------------------------------------------------------- /docker/odoo17/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffery9/odoo-devcontainer/1b561bc036031f473aa9de1ce6b23f3dbd351172/docker/odoo17/.gitkeep -------------------------------------------------------------------------------- /docker/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffery9/odoo-devcontainer/1b561bc036031f473aa9de1ce6b23f3dbd351172/docker/requirements.txt -------------------------------------------------------------------------------- /download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wget https://nightly.odoo.com/18.0/nightly/src/odoo_18.0.latest.zip 4 | unzip -oqq odoo_18.0.latest.zip -d docker/ && mv docker/odoo-18* docker/odoo18 5 | -------------------------------------------------------------------------------- /mcp_server.py: -------------------------------------------------------------------------------- 1 | from mcp.server.fastmcp import FastMCP 2 | import subprocess 3 | import os 4 | import asyncio 5 | import yaml 6 | from flask import Response 7 | import time 8 | import shutil 9 | import zipfile 10 | import io 11 | import base64 12 | 13 | import logging 14 | 15 | # 读取 YAML 配置文件 16 | with open('config.yaml', 'r') as file: 17 | config = yaml.safe_load(file) 18 | 19 | DOCKER_COMPOSE_PATH = config['odoo']['docker_compose_path'] 20 | ODOO_SERVICE_NAME = config['odoo']['odoo_service_name'] 21 | ODOO_MODULE_PATH = config['odoo']['odoo_module_path'] 22 | ODOO_TEST_MODULE = config['odoo']['odoo_test_module'] 23 | MCP_SERVER_PORT = config['mcp']['mcp_server_port'] 24 | 25 | try: 26 | mcp = FastMCP("OdooMCP", port=MCP_SERVER_PORT) 27 | logging.info(f"MCP Server running on port {MCP_SERVER_PORT}") 28 | except Exception as e: 29 | logging.error(f"Failed to start MCP Server: {e}") 30 | exit(1) 31 | 32 | def generate_prompt(user_story: str, acceptance_criteria: list) -> str: 33 | """根据用户故事和验收条件动态生成提示词""" 34 | 35 | # 将验收条件转化为列表形式 36 | criteria = "\n".join([f"{i+1}. {criterion}" for i, criterion in enumerate(acceptance_criteria)]) 37 | 38 | prompt_template = """ 39 | 任务:你是一位精通 Odoo 开发的 AI 助手,负责根据产品负责人提供的用户故事和验收条件,生成符合要求的 Odoo 代码,并编写完整的 Odoo 测试用例。 40 | 41 | 用户故事: 42 | {user_story} 43 | 44 | 验收条件: 45 | {acceptance_criteria} 46 | 47 | 步骤: 48 | 49 | 1. **分析用户故事和验收条件:** 50 | * 仔细阅读并理解产品负责人提供的用户故事和验收条件。 51 | * 明确需求的具体功能、业务逻辑和预期行为。 52 | 53 | 2. **生成 Odoo 后端代码:** 54 | * 根据分析结果,编写符合 Odoo 开发规范的模型、视图、报表等后端代码。 55 | * 包括业务模型的创建、数据字段的定义,视图(如表单视图、树形视图)和报表的开发。 56 | 57 | 3. **开发 Web 端功能:** 58 | * 为前端功能开发提供支持,例如: 59 | - 创建自定义的 Web 控制器(如 REST API、Web 表单处理)。 60 | - 开发动态的 **Web 表单**,并将其与后端模型进行绑定。 61 | - 定义 Odoo Web 客户端所需的 **JavaScript** 交互功能,如表单验证、动态加载等。 62 | - 设计和实现自定义的菜单项和页面视图。 63 | 64 | 4. **编写 Odoo 测试用例:** 65 | * 基于验收条件,编写完整、细致的测试用例。 66 | * 测试用例应覆盖所有可能的场景,包括正常情况、边界情况和异常情况。 67 | * 测试用例应符合 Odoo 的测试框架(unittest),并以 `test_` 开头。 68 | 69 | 5. **执行测试用例:** 70 | * 使用 MCP 自动化测试工具在 Odoo 测试环境中运行测试用例。 71 | * 记录测试结果,包括通过的测试用例和失败的测试用例。 72 | 73 | 6. **代码改进和测试用例调整:** 74 | * 如果测试用例未能全部通过,则分析失败原因,并对代码进行改进。 75 | * 根据代码的修改,相应地调整测试用例。 76 | * 重复步骤 4 和 5,直到所有测试用例均通过。 77 | 78 | 7. **输出结果:** 79 | * 提供最终的 Odoo 后端代码和 Web 端功能代码。 80 | * 提供测试结果报告,包括通过的测试用例和失败的测试用例(如果存在)。 81 | * 给出代码的改进说明。 82 | 83 | 要求: 84 | 85 | * 代码必须符合 Odoo 开发规范。 86 | * 测试用例必须覆盖所有验收条件。 87 | * 通过所有测试用例意味着代码符合需求。 88 | * 使用 python unittest 标准库进行编写测试用例。 89 | 90 | """ # 返回根据用户故事和验收条件动态生成的提示词 91 | return prompt_template.format(user_story=user_story, acceptance_criteria=criteria) 92 | 93 | @mcp.tool() 94 | def generate_code(user_story: str, acceptance_criteria: list) -> str: 95 | """根据用户故事和验收条件,采取 reAct 模式生成 Odoo 代码的提示词""" 96 | # 动态生成提示词 97 | prompt = generate_prompt(user_story, acceptance_criteria) 98 | 99 | return prompt 100 | 101 | @mcp.tool() 102 | def deploy_code(zip_content: str) -> str: 103 | """接收 ZIP 压缩包内容,解压并部署到 Docker 容器""" 104 | try: 105 | # 1. 解析 ZIP 数据(Base64 解码) 106 | zip_bytes = base64.b64decode(zip_content) 107 | zip_stream = io.BytesIO(zip_bytes) 108 | 109 | # 2. 确保目标目录干净 110 | generated_dir = os.path.join(os.getcwd(), ODOO_TEST_MODULE) 111 | if os.path.exists(generated_dir): 112 | shutil.rmtree(generated_dir) 113 | os.makedirs(generated_dir, exist_ok=True) 114 | 115 | # 3. 解压 ZIP 到指定目录 116 | with zipfile.ZipFile(zip_stream, 'r') as zip_ref: 117 | zip_ref.extractall(generated_dir) 118 | 119 | logging.info(f"Extracted module '{ODOO_TEST_MODULE}' to {generated_dir}") 120 | 121 | # 4. 复制解压后的模块到 Odoo 模块路径 122 | odoo_module_dest = os.path.join(ODOO_MODULE_PATH, ODOO_TEST_MODULE) 123 | if os.path.exists(odoo_module_dest): 124 | shutil.rmtree(odoo_module_dest) 125 | shutil.copytree(generated_dir, odoo_module_dest) 126 | 127 | logging.info(f"Copied module to Odoo path: {odoo_module_dest}") 128 | 129 | # 5. 重启 Odoo 容器 130 | subprocess.run(['docker-compose', '-f', DOCKER_COMPOSE_PATH, 'restart', ODOO_SERVICE_NAME], check=True) 131 | 132 | return f"Module '{ODOO_TEST_MODULE}' deployed successfully" 133 | except zipfile.BadZipFile: 134 | return "Error: Invalid ZIP file format" 135 | except subprocess.CalledProcessError as e: 136 | logging.error(f"Deployment failed: {e.stderr}") 137 | return f"Error: {e.stderr}" 138 | except Exception as e: 139 | logging.error(f"Unexpected error: {e}") 140 | return f"Unexpected error: {e}" 141 | 142 | @mcp.tool() 143 | def start_instance() -> str: 144 | """启动 Odoo Docker 实例""" 145 | try: 146 | subprocess.run(['docker-compose', '-f', DOCKER_COMPOSE_PATH, 'up', '-d', ODOO_SERVICE_NAME]) 147 | return "Odoo instance started successfully" 148 | except Exception as e: 149 | return f"Error: {e}" 150 | 151 | @mcp.tool() 152 | def stop_instance() -> str: 153 | """停止 Odoo Docker 实例""" 154 | try: 155 | subprocess.run(['docker-compose', '-f', DOCKER_COMPOSE_PATH, 'down']) 156 | return "Odoo instance stopped successfully" 157 | except Exception as e: 158 | return f"Error: {e}" 159 | 160 | @mcp.tool() 161 | def update_container() -> str: 162 | """更新 Odoo Docker 容器""" 163 | try: 164 | logging.info("Pulling the latest Odoo image...") 165 | subprocess.run(["docker-compose", "-f", DOCKER_COMPOSE_PATH, "pull"], check=True) 166 | 167 | logging.info("Rebuilding and restarting the Odoo container...") 168 | subprocess.run(["docker-compose", "-f", DOCKER_COMPOSE_PATH, "up", "--build", "-d"], check=True) 169 | 170 | logging.info("Removing unused Docker images...") 171 | subprocess.run(["docker", "image", "prune", "-f"], check=True) 172 | 173 | return "Odoo container updated successfully" 174 | except subprocess.CalledProcessError as e: 175 | logging.error(f"Container update failed: {e.stderr}") 176 | return f"Error updating container: {e.stderr}" 177 | except Exception as e: 178 | logging.error(f"Unexpected error: {e}") 179 | return f"Unexpected error: {e}" 180 | 181 | 182 | @mcp.tool() 183 | def install_module(module_name: str) -> str: 184 | """在 Odoo Docker 容器中安装指定模块""" 185 | try: 186 | logging.info(f"Installing module: {module_name}") 187 | 188 | # 进入 Odoo 容器并安装模块 189 | result = subprocess.run( 190 | [ 191 | "docker-compose", "-f", DOCKER_COMPOSE_PATH, "exec", 192 | ODOO_SERVICE_NAME, "odoo", "-u", module_name, "--stop-after-init" 193 | ], 194 | capture_output=True, text=True, check=True 195 | ) 196 | 197 | return f"Module '{module_name}' installed successfully\n{result.stdout}" 198 | except subprocess.CalledProcessError as e: 199 | logging.error(f"Module installation failed: {e.stderr}") 200 | return f"Error installing module '{module_name}': {e.stderr}" 201 | except Exception as e: 202 | logging.error(f"Unexpected error: {e}") 203 | return f"Unexpected error: {e}" 204 | 205 | @mcp.tool() 206 | def run_all_tests() -> str: 207 | """在 Odoo Docker 容器中运行测试用例""" 208 | try: 209 | result = subprocess.run(['docker-compose', '-f', DOCKER_COMPOSE_PATH, 'exec', ODOO_SERVICE_NAME, 'odoo', '-i', ODOO_TEST_MODULE, '--test-enable'], capture_output=True, text=True) 210 | return result.stdout 211 | except Exception as e: 212 | return f"Error: {e}" 213 | 214 | @mcp.tool() 215 | def run_tests(module_name: str) -> str: 216 | """在 Odoo Docker 容器中运行指定模块的测试用例""" 217 | try: 218 | logging.info(f"Running tests for module: {module_name}") 219 | 220 | # 在 Odoo 容器中运行测试 221 | result = subprocess.run( 222 | [ 223 | "docker-compose", "-f", DOCKER_COMPOSE_PATH, "exec", 224 | ODOO_SERVICE_NAME, "odoo", "-i", module_name, "--test-enable", "--stop-after-init" 225 | ], 226 | capture_output=True, text=True, check=True 227 | ) 228 | 229 | return f"Tests for module '{module_name}' completed successfully:\n{result.stdout}" 230 | except subprocess.CalledProcessError as e: 231 | logging.error(f"Module test failed: {e.stderr}") 232 | return f"Error running tests for '{module_name}': {e.stderr}" 233 | except Exception as e: 234 | logging.error(f"Unexpected error: {e}") 235 | return f"Unexpected error: {e}" 236 | 237 | 238 | if __name__ == "__main__": 239 | mcp.run() -------------------------------------------------------------------------------- /nginx/default.conf: -------------------------------------------------------------------------------- 1 | upstream odoo { 2 | server web:8069; 3 | } 4 | upstream odoochat { 5 | server web:8072; 6 | } 7 | 8 | server { 9 | listen 80; 10 | server_name localhost; 11 | error_page 500 502 503 504 /50x.html; 12 | location = /50x.html { 13 | root /usr/share/nginx/html; 14 | } 15 | proxy_redirect off; 16 | 17 | proxy_set_header Host $http_host; 18 | proxy_set_header X-Forwarded-Host $http_host; 19 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 20 | proxy_set_header X-Forwarded-Proto $scheme; 21 | proxy_set_header X-Real-IP $remote_addr; 22 | 23 | 24 | location /pgadmin4/ { 25 | proxy_set_header X-Script-Name /pgadmin4; 26 | proxy_set_header Host $http_host; 27 | proxy_pass http://pgadmin:80/; 28 | proxy_redirect off; 29 | } 30 | 31 | location /longpolling { 32 | proxy_pass http://odoochat; 33 | } 34 | 35 | location / { 36 | proxy_pass http://odoo; 37 | } 38 | 39 | gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript; 40 | gzip on; 41 | 42 | } 43 | 44 | -------------------------------------------------------------------------------- /odoo-bin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # set server timezone in UTC before time module imported 4 | __import__('os').environ['TZ'] = 'UTC' 5 | import odoo 6 | 7 | if __name__ == "__main__": 8 | odoo.cli.main() 9 | -------------------------------------------------------------------------------- /odoo.conf: -------------------------------------------------------------------------------- 1 | [options] 2 | addons_path = /mnt/extra-addons 3 | admin_passwd = 1234 4 | csv_internal_sep = , 5 | data_dir = /var/lib/odoo 6 | db_host = db 7 | db_maxconn = 64 8 | db_name = False 9 | db_password = odoo 10 | db_port = 5432 11 | db_sslmode = prefer 12 | db_template = template0 13 | db_user = odoo 14 | dbfilter = 15 | demo = {} 16 | email_from = False 17 | geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb 18 | http_enable = True 19 | http_interface = 20 | http_port = 8069 21 | import_partial = 22 | limit_memory_hard = 2684354560 23 | limit_memory_soft = 2147483648 24 | limit_request = 8192 25 | limit_time_cpu = 300 26 | limit_time_real = 600 27 | limit_time_real_cron = -1 28 | list_db = True 29 | log_db = False 30 | log_db_level = warning 31 | log_handler = :INFO 32 | log_level = debug 33 | logfile = 34 | longpolling_port = 8072 35 | max_cron_threads = 0 36 | osv_memory_age_limit = False 37 | osv_memory_count_limit = False 38 | pg_path = 39 | pidfile = 40 | proxy_mode = True 41 | reportgz = False 42 | screencasts = 43 | screenshots = /tmp/odoo_tests 44 | server_wide_modules = base,web 45 | smtp_password = False 46 | smtp_port = 25 47 | smtp_server = localhost 48 | smtp_ssl = False 49 | smtp_user = False 50 | syslog = False 51 | test_enable = False 52 | test_file = 53 | test_tags = None 54 | transient_age_limit = 1.0 55 | translate_modules = ['all'] 56 | unaccent = False 57 | upgrade_path = 58 | without_demo = False 59 | workers = 0 --------------------------------------------------------------------------------