Skip to content

Commit 59cd936

Browse files
committed
[IMP] vcp_odoo: add more fields
1 parent 20b27bf commit 59cd936

4 files changed

Lines changed: 106 additions & 2 deletions

File tree

vcp_odoo/models/vcp_odoo_module_version.py

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Copyright 2026 Dixmit
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33

4-
from odoo import fields, models
4+
from odoo import fields, models, tools
55

66

77
class VcpOdooModuleVersion(models.Model):
88
_name = "vcp.odoo.module.version"
9-
_description = "Odoo Module Version" # TODO
9+
_description = "Odoo Module on an specific repository branch"
1010

11+
name = fields.Char(required=True)
1112
module_id = fields.Many2one(
1213
"vcp.odoo.module",
1314
required=True,
@@ -20,3 +21,45 @@ class VcpOdooModuleVersion(models.Model):
2021
depends_on_module_ids = fields.Many2many(
2122
"vcp.odoo.module",
2223
)
24+
auto_install = fields.Boolean()
25+
license = fields.Char(string="License (Manifest)", readonly=True)
26+
summary = fields.Char(string="Summary (Manifest)", readonly=True)
27+
website = fields.Char(string="Website (Manifest)", readonly=True)
28+
image_1920 = fields.Image(max_width=1920, max_height=1920, readonly=True)
29+
image_128 = fields.Image(
30+
related="image_1920", readonly=True, max_width=128, max_height=128
31+
)
32+
lib_python_ids = fields.Many2many(
33+
"vcp.odoo.lib.python",
34+
string="Python Libraries",
35+
)
36+
bin_package_ids = fields.Many2many(
37+
"vcp.odoo.bin.package",
38+
string="Python Binaries",
39+
)
40+
41+
42+
class VcpOdooLibPython(models.Model):
43+
_name = "vcp.odoo.lib.python"
44+
45+
name = fields.Char(required=True)
46+
47+
@tools.ormcache("name")
48+
def _get_lib_python(self, name):
49+
lib = self.search([("name", "=", name)], limit=1)
50+
if not lib:
51+
lib = self.create({"name": name})
52+
return lib.id
53+
54+
55+
class VcpOdooBinPackage(models.Model):
56+
_name = "vcp.odoo.bin.package"
57+
58+
name = fields.Char(required=True)
59+
60+
@tools.ormcache("name")
61+
def _get_bin(self, name):
62+
bin_src = self.search([("name", "=", name)], limit=1)
63+
if not bin_src:
64+
bin_src = self.create({"name": name})
65+
return bin_src.id

vcp_odoo/models/vcp_rule.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Copyright 2026 Dixmit
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33
import ast
4+
import base64
45
import copy
56
import logging
7+
import os
68

79
from odoo import fields, models
810
from odoo.fields import Command
@@ -52,18 +54,50 @@ def _load_odoo_module_manifest(self, path):
5254
manifest.update(ast.literal_eval(f.read()))
5355
return manifest
5456

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+
5567
def _process_rule_odoo_module_prepare_vals(
5668
self, repository_branch, module_id, manifest_path
5769
):
5870
manifest = self._load_odoo_module_manifest(manifest_path)
5971
depends = []
6072
for dependancy in manifest.get("depends", []):
6173
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))
6288
return {
89+
"name": manifest.get("name"),
6390
"module_id": module_id,
6491
"version": manifest.get(
6592
"version", repository_branch.branch_id.name + ".0.0-dev"
6693
),
94+
"license": manifest.get("license"),
95+
"summary": manifest.get("summary"),
96+
"website": manifest.get("website"),
97+
"auto_install": manifest.get("auto_install", False),
6798
"repository_branch_id": repository_branch.id,
6899
"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)],
69103
}

vcp_odoo/security/ir.model.access.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ access_vcp_odoo_module,Access Odoo Module,model_vcp_odoo_module,vcp_management.g
33
manage_vcp_odoo_module,Manage Odoo Module,model_vcp_odoo_module,vcp_management.group_vcp_manager,1,1,1,0
44
access_vcp_odoo_module_version,Access Odoo Module Version,model_vcp_odoo_module_version,vcp_management.group_vcp_user,1,0,0,0
55
manage_vcp_odoo_module_version,Manage Odoo Module Version,model_vcp_odoo_module_version,vcp_management.group_vcp_manager,1,1,1,0
6+
access_vcp_odoo_bin_package,Access Odoo Bin Package,model_vcp_odoo_bin_package,vcp_management.group_vcp_user,1,0,0,0
7+
manage_vcp_odoo_bin_package,Manage Odoo Bin Package,model_vcp_odoo_bin_package,vcp_management.group_vcp_manager,1,1,1,0
8+
access_vcp_odoo_lib_python,Access Odoo Python Library,model_vcp_odoo_lib_python,vcp_management.group_vcp_user,1,0,0,0
9+
manage_vcp_odoo_lib_python,Manage Odoo Python Library,model_vcp_odoo_lib_python,vcp_management.group_vcp_manager,1,1,1,0

vcp_odoo/views/vcp_odoo_module_version.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,32 @@
88
<form>
99
<header />
1010
<sheet>
11+
<field
12+
name="image_1920"
13+
widget="image"
14+
class="oe_avatar"
15+
options="{'preview_image': 'image_128'}"
16+
/>
17+
<div class="oe_title">
18+
<h1>
19+
<field name="name" />
20+
</h1>
21+
</div>
1122
<group>
1223
<field name="module_id" />
1324
<field name="version" />
1425
<field name="depends_on_module_ids" widget="many2many_tags" />
26+
<field name="auto_install" />
27+
<field name="license" />
28+
<field name="website" />
29+
<field name="lib_python_ids" widget="many2many_tags" />
30+
<field name="bin_package_ids" widget="many2many_tags" />
1531
</group>
32+
<notebook>
33+
<page name="summary" string="Summary">
34+
<field name="summary" />
35+
</page>
36+
</notebook>
1637
</sheet>
1738
</form>
1839
</field>
@@ -22,6 +43,7 @@
2243
<field name="model">vcp.odoo.module.version</field>
2344
<field name="arch" type="xml">
2445
<search>
46+
<field name="name" />
2547
<field name="module_id" />
2648
<field name="version" />
2749
</search>
@@ -32,6 +54,7 @@
3254
<field name="model">vcp.odoo.module.version</field>
3355
<field name="arch" type="xml">
3456
<list>
57+
<field name="name" />
3558
<field name="module_id" />
3659
<field name="version" />
3760
<field name="depends_on_module_ids" widget="many2many_tags" />

0 commit comments

Comments
 (0)