# Copyright 2011-2012 Nicolas Bessi (Camptocamp SA)
# Copyright 2016 Yannick Vaucher (Camptocamp SA)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models

GEO_VIEW = ("geoengine", "GeoEngine")


class IrUIView(models.Model):
    _inherit = "ir.ui.view"

    @api.model
    def _setup_fields(self):
        """Hack due since the field 'type' is not defined with the new api.
        """
        cls = type(self)
        type_selection = cls._fields["type"].selection
        if GEO_VIEW not in type_selection:
            tmp = list(type_selection)
            tmp.append(GEO_VIEW)
            cls._fields["type"].selection = tuple(set(tmp))
        super()._setup_fields()

    raster_layer_ids = fields.One2many(
        "geoengine.raster.layer", "view_id", "Raster layers", required=False
    )

    vector_layer_ids = fields.One2many(
        "geoengine.vector.layer", "view_id", "Vector layers", required=True
    )

    projection = fields.Char(default="EPSG:3857", required=True)
    default_extent = fields.Char(
        "Default map extent",
        size=128,
        default="-123164.85222423, 5574694.9538936, 1578017.6490538,"
        " 6186191.1800898",
    )
    default_zoom = fields.Integer("Default map zoom")
    restricted_extent = fields.Char("Restricted map extent", size=128)

@@ -178,13 +178,8 @@
 port
- api,
  fie
@@ -195,47 +195,8 @@
 ls%0A%0A
-GEO_VIEW = (%22geoengine%22, %22GeoEngine%22)%0A%0A
 %0Acla
@@ -259,421 +259,74 @@
     
-@api.model%0A    def _setup_fields(self):%0A        %22%22%22Hack due since the field 'type' is not defined with the new api.%0A        %22%22%22%0A        cls = type(self)%0A        type_selection = cls._fields%5B%22type%22%5D.selection%0A        if GEO_VIEW not in type_selection:%0A            tmp = list(type_selection)%0A            tmp.append(GEO_VIEW)%0A            cls._fields%5B%22type%22%5D.selection = tuple(set(tmp))%0A        super()._setup_fields(
+type = fields.Selection(selection_add=%5B(%22geoengine%22, %22GeoEngine%22)%5D
 )%0A%0A 

remove unnecessary hack