prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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
  
  
  </issue>
  <code>
  [start of base_optional_quick_create/model.py]
  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 of base_optional_quick_create/model.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
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
  @@ -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
  
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@@ -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"}]}