[FIX+IMP] module_analysis : remove analysis when updating modules, because the analysis is partial (it also make the update slower) ; Add instead a cron task that is executed nightly to update analysis automatically
parent
0946eba3ca
commit
76ea08b51e
|
@ -20,11 +20,14 @@
|
||||||
"views/view_ir_module_type.xml",
|
"views/view_ir_module_type.xml",
|
||||||
"views/view_ir_module_type_rule.xml",
|
"views/view_ir_module_type_rule.xml",
|
||||||
"views/view_ir_module_module.xml",
|
"views/view_ir_module_module.xml",
|
||||||
|
"data/ir_cron.xml",
|
||||||
"data/ir_config_parameter.xml",
|
"data/ir_config_parameter.xml",
|
||||||
"data/ir_module_type.xml",
|
"data/ir_module_type.xml",
|
||||||
"data/ir_module_type_rule.xml",
|
"data/ir_module_type_rule.xml",
|
||||||
],
|
],
|
||||||
"external_dependencies": {"python": ["pygount"]},
|
"external_dependencies": {
|
||||||
|
"python": ["pygount"],
|
||||||
|
},
|
||||||
"post_init_hook": "analyse_installed_modules",
|
"post_init_hook": "analyse_installed_modules",
|
||||||
"installable": True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2021-Today: GRAP (<http://www.grap.coop/>)
|
||||||
|
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
-->
|
||||||
|
<odoo noupdate="1">
|
||||||
|
<record id="cron_module_analysis" model="ir.cron">
|
||||||
|
<field name="name">Update Module Analysis</field>
|
||||||
|
<field name="active" eval="True" />
|
||||||
|
<field name="model_id" ref="base.model_ir_module_module" />
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.cron_analyse_code()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">days</field>
|
||||||
|
<field name="nextcall" eval="(DateTime.today()).strftime('%Y-%m-%d')" />
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="user_id" ref="base.user_root" />
|
||||||
|
</record>
|
||||||
|
</odoo>
|
|
@ -79,14 +79,12 @@ class IrModuleModule(models.Model):
|
||||||
def update_list(self):
|
def update_list(self):
|
||||||
res = super().update_list()
|
res = super().update_list()
|
||||||
if self.env.context.get("analyse_installed_modules", False):
|
if self.env.context.get("analyse_installed_modules", False):
|
||||||
self.search([("state", "=", "installed")]).button_analyse_code()
|
self.search([("state", "=", "installed")])._analyse_code()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
res = super().write(vals)
|
res = super().write(vals)
|
||||||
if vals.get("state", False) == "installed":
|
if vals.get("state", False) == "uninstalled" and "module_analysis" not in [
|
||||||
self.button_analyse_code()
|
|
||||||
elif vals.get("state", False) == "uninstalled" and "module_analysis" not in [
|
|
||||||
x.name for x in self
|
x.name for x in self
|
||||||
]:
|
]:
|
||||||
self.write(self._get_clean_analyse_values())
|
self.write(self._get_clean_analyse_values())
|
||||||
|
@ -94,6 +92,14 @@ class IrModuleModule(models.Model):
|
||||||
|
|
||||||
# Public Section
|
# Public Section
|
||||||
def button_analyse_code(self):
|
def button_analyse_code(self):
|
||||||
|
self._analyse_code()
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def cron_analyse_code(self):
|
||||||
|
self.search([("state", "=", "installed")])._analyse_code()
|
||||||
|
|
||||||
|
# Custom Section
|
||||||
|
def _analyse_code(self):
|
||||||
IrModuleAuthor = self.env["ir.module.author"]
|
IrModuleAuthor = self.env["ir.module.author"]
|
||||||
IrModuleTypeRule = self.env["ir.module.type.rule"]
|
IrModuleTypeRule = self.env["ir.module.type.rule"]
|
||||||
rules = IrModuleTypeRule.search([])
|
rules = IrModuleTypeRule.search([])
|
||||||
|
@ -150,7 +156,6 @@ class IrModuleModule(models.Model):
|
||||||
values[v["field"]] = v["value"]
|
values[v["field"]] = v["value"]
|
||||||
module.write(values)
|
module.write(values)
|
||||||
|
|
||||||
# Custom Section
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_files_to_analyse(
|
def _get_files_to_analyse(
|
||||||
self, path, file_extensions, exclude_directories, exclude_files
|
self, path, file_extensions, exclude_directories, exclude_files
|
||||||
|
|
|
@ -6,6 +6,9 @@ from odoo import SUPERUSER_ID, api
|
||||||
|
|
||||||
|
|
||||||
def analyse_installed_modules(cr, registry):
|
def analyse_installed_modules(cr, registry):
|
||||||
|
with api.Environment.manage():
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
installed_modules = env["ir.module.module"].search([("state", "=", "installed")])
|
installed_modules = env["ir.module.module"].search(
|
||||||
|
["|", ("state", "=", "installed"), ("name", "=", "module_analysis")]
|
||||||
|
)
|
||||||
installed_modules.button_analyse_code()
|
installed_modules.button_analyse_code()
|
||||||
|
|
|
@ -14,7 +14,7 @@ developped for exemple,
|
||||||
.. image:: ../static/description/add_module_type_rules.png
|
.. image:: ../static/description/add_module_type_rules.png
|
||||||
|
|
||||||
|
|
||||||
to update the data, you have to :
|
to update the data manually, you have to :
|
||||||
|
|
||||||
* Go to 'Apps' / 'Update Apps List'
|
* Go to 'Apps' / 'Update Apps List'
|
||||||
|
|
||||||
|
@ -24,6 +24,12 @@ to update the data, you have to :
|
||||||
|
|
||||||
This will update analysis of your installed modules.
|
This will update analysis of your installed modules.
|
||||||
|
|
||||||
|
to update the data automatically, you have to :
|
||||||
|
|
||||||
|
* Go to 'Settings' / 'Technical' / 'Scheduled Actions'
|
||||||
|
|
||||||
|
* Configure the action 'Update Module Analysis'. (By default, the analysis will be done nightly)
|
||||||
|
|
||||||
|
|
||||||
Adding Extra data
|
Adding Extra data
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo.tests import tagged
|
from odoo.tests.common import TransactionCase, at_install, post_install
|
||||||
from odoo.tests.common import TransactionCase
|
|
||||||
|
|
||||||
|
|
||||||
@tagged("post_install", "-at_install")
|
@at_install(False)
|
||||||
|
@post_install(True)
|
||||||
class TestModule(TransactionCase):
|
class TestModule(TransactionCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
|
@ -11,6 +11,6 @@ mako
|
||||||
odoorpc
|
odoorpc
|
||||||
openpyxl
|
openpyxl
|
||||||
openupgradelib
|
openupgradelib
|
||||||
|
pygount
|
||||||
pysftp
|
pysftp
|
||||||
sentry_sdk
|
sentry_sdk
|
||||||
pygount
|
|
||||||
|
|
Loading…
Reference in New Issue