diff --git a/base_optional_quick_create/README.rst b/base_optional_quick_create/README.rst index 0441f0e..fb2fbe3 100644 --- a/base_optional_quick_create/README.rst +++ b/base_optional_quick_create/README.rst @@ -14,38 +14,26 @@ form. Got the idea from https://twitter.com/nbessi/status/337869826028605441 -Installation -============ - -To install this module, you need to click on install - Usage ===== To use this module, you need to: - * go into the menu of ir_model - * select the model you want to disable the quick create option - * check the Avoid quick create + * go into the menu of *ir_model*, + * select the model for which you want to disable the quick create option, + * enable the option *Avoid quick create*. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/149/9.0 - -For further information, please visit: - - * https://www.odoo.com/forum/help-1 - -Known issues / Roadmap -====================== + :target: https://runbot.odoo-community.org/runbot/149/10.0 Bug Tracker =========== Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback. Credits ======= @@ -55,6 +43,7 @@ Contributors * Jonathan Nemry * Lorenzo Battistini +* Alexis de Lattre Maintainer ---------- @@ -67,4 +56,4 @@ This module is maintained by the OCA. OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. \ No newline at end of file +To contribute to this module, please visit https://odoo-community.org. diff --git a/base_optional_quick_create/__init__.py b/base_optional_quick_create/__init__.py index e600c44..cde864b 100644 --- a/base_optional_quick_create/__init__.py +++ b/base_optional_quick_create/__init__.py @@ -1,5 +1,3 @@ # -*- coding: utf-8 -*- -# © 2013 Agile Business Group sagl () -# © 2016 ACSONE SA/NA () from . import models diff --git a/base_optional_quick_create/__openerp__.py b/base_optional_quick_create/__manifest__.py similarity index 85% rename from base_optional_quick_create/__openerp__.py rename to base_optional_quick_create/__manifest__.py index e773b3f..0ba25d2 100644 --- a/base_optional_quick_create/__openerp__.py +++ b/base_optional_quick_create/__manifest__.py @@ -4,7 +4,7 @@ { 'name': "Optional quick create", - 'version': '9.0.1.0.0', + 'version': '10.0.1.0.0', 'category': 'Tools', 'summary': "Avoid 'quick create' on m2o fields, on a 'by model' basis", 'author': "Agile Business Group,Odoo Community Association (OCA)", @@ -14,7 +14,5 @@ "data": [ 'views/model_view.xml', ], - "demo": [], - 'test': [], - 'installable': True + 'installable': True, } diff --git a/base_optional_quick_create/models/__init__.py b/base_optional_quick_create/models/__init__.py index a32fc06..045938c 100644 --- a/base_optional_quick_create/models/__init__.py +++ b/base_optional_quick_create/models/__init__.py @@ -1,5 +1,3 @@ # -*- coding: utf-8 -*- -# © 2013 Agile Business Group sagl () -# © 2016 ACSONE SA/NA () from . import ir_model diff --git a/base_optional_quick_create/models/ir_model.py b/base_optional_quick_create/models/ir_model.py index e1b3787..53df25d 100644 --- a/base_optional_quick_create/models/ir_model.py +++ b/base_optional_quick_create/models/ir_model.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # © 2013 Agile Business Group sagl () # © 2016 ACSONE SA/NA () +# © 2016 Akretion (Alexis de Lattre ) -from openerp import api, fields, models, _ -from openerp.exceptions import UserError -from openerp import SUPERUSER_ID +from odoo import api, fields, models, _ +from odoo.exceptions import UserError class IrModel(models.Model): @@ -12,35 +12,38 @@ class IrModel(models.Model): avoid_quick_create = fields.Boolean() - def _patch_quick_create(self, cr, ids): + @api.multi + def _patch_quick_create(self): + @api.multi def _wrap_name_create(): - def wrapper(self, cr, uid, name, context=None): + def wrapper(self): raise UserError(_("Can't create quickly. Opening create form")) return wrapper - for model in self.browse(cr, SUPERUSER_ID, ids): + for model in self: if model.avoid_quick_create: model_name = model.model - model_obj = self.pool.get(model_name) - if model_obj and not hasattr(model_obj, 'check_quick_create'): + model_obj = self.env.get(model_name) + if model_name and not hasattr(model_obj, 'check_quick_create'): model_obj._patch_method('name_create', _wrap_name_create()) model_obj.check_quick_create = True return True - def _register_hook(self, cr): - self._patch_quick_create(cr, self.search(cr, SUPERUSER_ID, [])) - return super(IrModel, self)._register_hook(cr) + def _register_hook(self): + models = self.search([]) + models._patch_quick_create() + return super(IrModel, self)._register_hook() @api.model @api.returns('self', lambda value: value.id) def create(self, vals): ir_model = super(IrModel, self).create(vals) - self.pool[self._name]._patch_quick_create(self.env.cr, [ir_model.id]) + ir_model._patch_quick_create() return ir_model @api.multi def write(self, vals): res = super(IrModel, self).write(vals) - self.pool[self._name]._patch_quick_create(self.env.cr, self.ids) + self._patch_quick_create() return res diff --git a/base_optional_quick_create/views/model_view.xml b/base_optional_quick_create/views/model_view.xml index add2f49..ec7394e 100644 --- a/base_optional_quick_create/views/model_view.xml +++ b/base_optional_quick_create/views/model_view.xml @@ -1,14 +1,12 @@ - - - - ir.model - - - - - + + + ir.model + + + + - - - + + +