From d937d954ab6014a918411062d8927b726083ceab Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 18 Jul 2019 10:41:49 +0200 Subject: [PATCH] New version of eradicate_quick_create that use web_m2x_options --- eradicate_quick_create/__init__.py | 2 +- eradicate_quick_create/__manifest__.py | 7 +++++-- eradicate_quick_create/hooks.py | 19 +++++++++++++++++++ eradicate_quick_create/model.py | 19 ------------------- 4 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 eradicate_quick_create/hooks.py delete mode 100644 eradicate_quick_create/model.py diff --git a/eradicate_quick_create/__init__.py b/eradicate_quick_create/__init__.py index 9186ee3..9c60e5a 100644 --- a/eradicate_quick_create/__init__.py +++ b/eradicate_quick_create/__init__.py @@ -1 +1 @@ -from . import model +from .hooks import web_m2x_options_create diff --git a/eradicate_quick_create/__manifest__.py b/eradicate_quick_create/__manifest__.py index 62a463e..a79a3c6 100644 --- a/eradicate_quick_create/__manifest__.py +++ b/eradicate_quick_create/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Eradicate Quick Create', - 'version': '12.0.1.0.0', + 'version': '12.0.2.0.0', 'category': 'Tools', 'license': 'AGPL-3', 'summary': 'Disable quick create on all objects', @@ -13,10 +13,13 @@ Eradicate Quick Create Disable quick create on all objects of Odoo. +This new version of the module uses the module *web_m2x_options* from the OCA *web* project instead of the module *base_optional_quick_create* from the OCA project *server-ux*. + This module has been written by Alexis de Lattre from Akretion . """, 'author': 'Akretion', 'website': 'http://www.akretion.com', - 'depends': ['base_optional_quick_create'], + 'depends': ['web_m2x_options'], + 'post_init_hook': 'web_m2x_options_create', 'installable': True, } diff --git a/eradicate_quick_create/hooks.py b/eradicate_quick_create/hooks.py new file mode 100644 index 0000000..ca5cf31 --- /dev/null +++ b/eradicate_quick_create/hooks.py @@ -0,0 +1,19 @@ +# Copyright 2019 Akretion France +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import SUPERUSER_ID +from odoo.api import Environment + + +def web_m2x_options_create(cr, registry): + env = Environment(cr, SUPERUSER_ID, {}) + config_parameter = env['ir.config_parameter'].search( + [('key', '=', 'web_m2x_options.create')]) + if config_parameter and config_parameter.value != 'False': + config_parameter.value = 'False' + else: + env['ir.config_parameter'].create({ + 'key': 'web_m2x_options.create', + 'value': 'False', + }) diff --git a/eradicate_quick_create/model.py b/eradicate_quick_create/model.py deleted file mode 100644 index 335f589..0000000 --- a/eradicate_quick_create/model.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2014-2019 Akretion France (http://www.akretion.com) -# @author Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import api, fields, models - - -class IrModel(models.Model): - _inherit = 'ir.model' - - @api.model_cr - def init(self): - '''Activate 'avoid_quick_create' on all existing models''' - self._cr.execute( - "UPDATE ir_model SET avoid_quick_create=true " - "WHERE avoid_quick_create is not true") - return True - - avoid_quick_create = fields.Boolean(default=True)