|
1 | 1 | # Copyright 2026 Dixmit |
2 | 2 | # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
3 | 3 | import ast |
| 4 | +import base64 |
4 | 5 | import copy |
5 | 6 | import logging |
| 7 | +import os |
6 | 8 |
|
7 | 9 | from odoo import fields, models |
8 | 10 | from odoo.fields import Command |
@@ -52,18 +54,50 @@ def _load_odoo_module_manifest(self, path): |
52 | 54 | manifest.update(ast.literal_eval(f.read())) |
53 | 55 | return manifest |
54 | 56 |
|
| 57 | + def _get_odoo_icon_path(self): |
| 58 | + return [ |
| 59 | + "static/src/img/icon.svg", |
| 60 | + "static/src/img/icon.jpg", |
| 61 | + "static/src/img/icon.png", |
| 62 | + "static/description/icon.svg", |
| 63 | + "static/description/icon.jpg", |
| 64 | + "static/description/icon.png", |
| 65 | + ] |
| 66 | + |
55 | 67 | def _process_rule_odoo_module_prepare_vals( |
56 | 68 | self, repository_branch, module_id, manifest_path |
57 | 69 | ): |
58 | 70 | manifest = self._load_odoo_module_manifest(manifest_path) |
59 | 71 | depends = [] |
60 | 72 | for dependancy in manifest.get("depends", []): |
61 | 73 | depends.append(self.env["vcp.odoo.module"]._get_odoo_module(dependancy)) |
| 74 | + icon = False |
| 75 | + for icon_path in self._get_odoo_icon_path(): |
| 76 | + if os.path.exists(os.path.join(os.path.dirname(manifest_path), icon_path)): |
| 77 | + with open( |
| 78 | + os.path.join(os.path.dirname(manifest_path), icon_path), "rb" |
| 79 | + ) as f: |
| 80 | + icon = base64.b64encode(f.read()) |
| 81 | + break |
| 82 | + python_libs = [] |
| 83 | + for lib in manifest.get("external_dependencies", {}).get("python", []): |
| 84 | + python_libs.append(self.env["vcp.odoo.lib.python"]._get_lib_python(lib)) |
| 85 | + package_bins = [] |
| 86 | + for package_bin in manifest.get("external_dependencies", {}).get("bin", []): |
| 87 | + package_bins.append(self.env["vcp.odoo.bin.package"]._get_bin(package_bin)) |
62 | 88 | return { |
| 89 | + "name": manifest.get("name"), |
63 | 90 | "module_id": module_id, |
64 | 91 | "version": manifest.get( |
65 | 92 | "version", repository_branch.branch_id.name + ".0.0-dev" |
66 | 93 | ), |
| 94 | + "license": manifest.get("license"), |
| 95 | + "summary": manifest.get("summary"), |
| 96 | + "website": manifest.get("website"), |
| 97 | + "auto_install": manifest.get("auto_install", False), |
67 | 98 | "repository_branch_id": repository_branch.id, |
68 | 99 | "depends_on_module_ids": [Command.set(depends)], |
| 100 | + "image_1920": icon, |
| 101 | + "lib_python_ids": [Command.set(python_libs)], |
| 102 | + "bin_package_ids": [Command.set(package_bins)], |
69 | 103 | } |
0 commit comments