prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [7.0] [base_optional_quick_create] AttributeError: 'NoneType' object has no attribute 'name_create'
  Error at starting before a migration if a model has been removed
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `base_optional_quick_create/model.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 ##############################################################################
  3 #
  4 #    Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
  5 #
  6 #    This program is free software: you can redistribute it and/or modify
  7 #    it under the terms of the GNU Affero General Public License as published
  8 #    by the Free Software Foundation, either version 3 of the License, or
  9 #    (at your option) any later version.
  10 #
  11 #    This program is distributed in the hope that it will be useful,
  12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14 #    GNU Affero General Public License for more details.
  15 #
  16 #    You should have received a copy of the GNU Affero General Public License
  17 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18 #
  19 ##############################################################################
  20 
  21 from openerp.osv import orm, fields
  22 from openerp import SUPERUSER_ID
  23 from openerp.tools.translate import _
  24 
  25 
  26 class ir_model(orm.Model):
  27 
  28     _inherit = 'ir.model'
  29 
  30     _columns = {
  31         'avoid_quick_create': fields.boolean('Avoid quick create'),
  32     }
  33 
  34     def _wrap_name_create(self, old_create, model):
  35         def wrapper(cr, uid, name, context=None):
  36             raise orm.except_orm(_('Error'),
  37                                  _("Can't create quickly. "
  38                                    "Opening create form"))
  39         return wrapper
  40 
  41     def _register_hook(self, cr, ids=None):
  42         if ids is None:
  43             ids = self.search(cr, SUPERUSER_ID, [])
  44         for model in self.browse(cr, SUPERUSER_ID, ids):
  45             if model.avoid_quick_create:
  46                 model_name = model.model
  47                 model_obj = self.pool.get(model_name)
  48                 if not hasattr(model_obj, 'check_quick_create'):
  49                     model_obj.name_create = self._wrap_name_create(
  50                         model_obj.name_create,
  51                         model_name)
  52                     model_obj.check_quick_create = True
  53         return True
  54 
  55     def create(self, cr, uid, vals, context=None):
  56         res_id = super(ir_model, self).create(cr, uid, vals, context=context)
  57         self._register_hook(cr, [res_id])
  58         return res_id
  59 
  60     def write(self, cr, uid, ids, vals, context=None):
  61         if isinstance(ids, (int, long)):
  62             ids = [ids]
  63         super(ir_model, self).write(cr, uid, ids, vals, context=context)
  64         self._register_hook(cr, ids)
  65         return True
  66
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/base_optional_quick_create/model.py b/base_optional_quick_create/model.py
  --- a/base_optional_quick_create/model.py
  +++ b/base_optional_quick_create/model.py
  @@ -45,7 +45,7 @@
               if model.avoid_quick_create:
                   model_name = model.model
                   model_obj = self.pool.get(model_name)
  -                if not hasattr(model_obj, 'check_quick_create'):
  +                if model_obj and not hasattr(model_obj, 'check_quick_create'):
                       model_obj.name_create = self._wrap_name_create(
                           model_obj.name_create,
                           model_name)
  
verification_info: {"golden_diff": "diff --git a/base_optional_quick_create/model.py b/base_optional_quick_create/model.py\n--- a/base_optional_quick_create/model.py\n+++ b/base_optional_quick_create/model.py\n@@ -45,7 +45,7 @@\n             if model.avoid_quick_create:\n                 model_name = model.model\n                 model_obj = self.pool.get(model_name)\n-                if not hasattr(model_obj, 'check_quick_create'):\n+                if model_obj and not hasattr(model_obj, 'check_quick_create'):\n                     model_obj.name_create = self._wrap_name_create(\n                         model_obj.name_create,\n                         model_name)\n", "issue": "[7.0] [base_optional_quick_create] AttributeError: 'NoneType' object has no attribute 'name_create'\nError at starting before a migration if a model has been removed\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n##############################################################################\n#\n#    Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)\n#\n#    This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU Affero General Public License as published\n#    by the Free Software Foundation, either version 3 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU Affero General Public License for more details.\n#\n#    You should have received a copy of the GNU Affero General Public License\n#    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n#\n##############################################################################\n\nfrom openerp.osv import orm, fields\nfrom openerp import SUPERUSER_ID\nfrom openerp.tools.translate import _\n\n\nclass ir_model(orm.Model):\n\n    _inherit = 'ir.model'\n\n    _columns = {\n        'avoid_quick_create': fields.boolean('Avoid quick create'),\n    }\n\n    def _wrap_name_create(self, old_create, model):\n        def wrapper(cr, uid, name, context=None):\n            raise orm.except_orm(_('Error'),\n                                 _(\"Can't create quickly. \"\n                                   \"Opening create form\"))\n        return wrapper\n\n    def _register_hook(self, cr, ids=None):\n        if ids is None:\n            ids = self.search(cr, SUPERUSER_ID, [])\n        for model in self.browse(cr, SUPERUSER_ID, ids):\n            if model.avoid_quick_create:\n                model_name = model.model\n                model_obj = self.pool.get(model_name)\n                if not hasattr(model_obj, 'check_quick_create'):\n                    model_obj.name_create = self._wrap_name_create(\n                        model_obj.name_create,\n                        model_name)\n                    model_obj.check_quick_create = True\n        return True\n\n    def create(self, cr, uid, vals, context=None):\n        res_id = super(ir_model, self).create(cr, uid, vals, context=context)\n        self._register_hook(cr, [res_id])\n        return res_id\n\n    def write(self, cr, uid, ids, vals, context=None):\n        if isinstance(ids, (int, long)):\n            ids = [ids]\n        super(ir_model, self).write(cr, uid, ids, vals, context=context)\n        self._register_hook(cr, ids)\n        return True\n", "path": "base_optional_quick_create/model.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n##############################################################################\n#\n#    Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)\n#\n#    This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU Affero General Public License as published\n#    by the Free Software Foundation, either version 3 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU Affero General Public License for more details.\n#\n#    You should have received a copy of the GNU Affero General Public License\n#    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n#\n##############################################################################\n\nfrom openerp.osv import orm, fields\nfrom openerp import SUPERUSER_ID\nfrom openerp.tools.translate import _\n\n\nclass ir_model(orm.Model):\n\n    _inherit = 'ir.model'\n\n    _columns = {\n        'avoid_quick_create': fields.boolean('Avoid quick create'),\n    }\n\n    def _wrap_name_create(self, old_create, model):\n        def wrapper(cr, uid, name, context=None):\n            raise orm.except_orm(_('Error'),\n                                 _(\"Can't create quickly. \"\n                                   \"Opening create form\"))\n        return wrapper\n\n    def _register_hook(self, cr, ids=None):\n        if ids is None:\n            ids = self.search(cr, SUPERUSER_ID, [])\n        for model in self.browse(cr, SUPERUSER_ID, ids):\n            if model.avoid_quick_create:\n                model_name = model.model\n                model_obj = self.pool.get(model_name)\n                if model_obj and not hasattr(model_obj, 'check_quick_create'):\n                    model_obj.name_create = self._wrap_name_create(\n                        model_obj.name_create,\n                        model_name)\n                    model_obj.check_quick_create = True\n        return True\n\n    def create(self, cr, uid, vals, context=None):\n        res_id = super(ir_model, self).create(cr, uid, vals, context=context)\n        self._register_hook(cr, [res_id])\n        return res_id\n\n    def write(self, cr, uid, ids, vals, context=None):\n        if isinstance(ids, (int, long)):\n            ids = [ids]\n        super(ir_model, self).write(cr, uid, ids, vals, context=context)\n        self._register_hook(cr, ids)\n        return True\n", "path": "base_optional_quick_create/model.py"}]}