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     _inherit = 'ir.model'
28 
29     _columns = {
30         'avoid_quick_create': fields.boolean('Avoid quick create'),
31         }
32 
33     def _wrap_name_create(self, old_create, model):
34         def wrapper(cr, uid, name, context=None):
35             raise orm.except_orm(
36                 _('Error'),
37                 _("Can't create quickly. Opening create form"))
38         return wrapper
39 
40     def _register_hook(self, cr, ids=None):
41         if ids is None:
42             ids = self.search(cr, SUPERUSER_ID, [])
43         for model in self.browse(cr, SUPERUSER_ID, ids):
44             if model.avoid_quick_create:
45                 model_name = model.model
46                 model_obj = self.pool.get(model_name)
47                 if not hasattr(model_obj, 'check_quick_create'):
48                     model_obj.name_create = self._wrap_name_create(
49                         model_obj.name_create, model_name)
50                     model_obj.check_quick_create = True
51         return True
52 
53     def create(self, cr, uid, vals, context=None):
54         res_id = super(ir_model, self).create(cr, uid, vals, context=context)
55         self._register_hook(cr, [res_id])
56         return res_id
57 
58     def write(self, cr, uid, ids, vals, context=None):
59         if isinstance(ids, (int, long)):
60             ids = [ids]
61         res = super(ir_model, self).write(cr, uid, ids, vals, context=context)
62         self._register_hook(cr, ids)
63         return res
64
```
--- 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()

```

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
@@ -44,7 +44,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)
                     model_obj.check_quick_create = True

{"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@@ -44,7 +44,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, model_name)\n                     model_obj.check_quick_create = True\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    _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(\n                _('Error'),\n                _(\"Can't create quickly. 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, 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        res = super(ir_model, self).write(cr, uid, ids, vals, context=context)\n        self._register_hook(cr, ids)\n        return res\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    _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(\n                _('Error'),\n                _(\"Can't create quickly. 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, 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        res = super(ir_model, self).write(cr, uid, ids, vals, context=context)\n        self._register_hook(cr, ids)\n        return res\n", "path": "base_optional_quick_create/model.py"}]}