New version of eradicate_quick_create that use web_m2x_options

This commit is contained in:
Alexis de Lattre
2019-07-18 10:41:49 +02:00
parent 3bb11966dd
commit d937d954ab
4 changed files with 25 additions and 22 deletions

View File

@@ -1 +1 @@
from . import model
from .hooks import web_m2x_options_create

View File

@@ -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 <alexis.delattre@akretion.com>.
""",
'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,
}

View File

@@ -0,0 +1,19 @@
# Copyright 2019 Akretion France
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# 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',
})

View File

@@ -1,19 +0,0 @@
# Copyright 2014-2019 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# 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)