class DemoWebsiteLeafletMapFeature(models.Model):
    _name = "demo.website_leaflet.map.feature"
    _description = "Map Feature"

    name = fields.Char(required=True)

    active = fields.Boolean(default=True)

    category_id = fields.Many2one(
        comodel_name="demo.website_leaflet.category",
        string="Category",
        ondelete="restrict",
    )

    geo_line = fields.GeoLine()

    geo_point = fields.GeoPoint()

    geo_polygon = fields.GeoPolygon()

    html_text = fields.Html(string="Popup text")

    open_popup = fields.Boolean(string="Popup opened on map")

    type = fields.Selection(
        selection=[
            ("geo_point", "Geo Point"),
            ("geo_line", "Geo Line"),
            ("geo_polygon", "Geo Polygon"),
        ],
        required=True,
        default="geo_point",
    )
class RetailMachine(models.Model):
    """GEO OSV SAMPLE"""

    _name = "geoengine.demo.automatic.retailing.machine"

    the_point = fields.GeoPoint('Coordinate')
    the_line = fields.GeoLine('Power supply line', index=True)
    total_sales = fields.Float('Total sale', index=True)
    money_level = fields.Char('Money level', size=32, index=True)
    state = fields.Selection([('hs', 'HS'), ('ok', 'OK')], 'State', index=True)
    name = fields.Char('Serial number', size=64, required=True)
    zip_id = fields.Many2one('dummy.zip')

    @api.onchange('the_point')
    def onchange_geo_point(self):
        """ Exemple of on change on the point
        Lookup in zips if the code is within an area.
        Change the zip_id field accordingly
        """
        if self.the_point:
            zip_match = self.env['dummy.zip'].geo_search(geo_domain=[
                ('the_geom', 'geo_contains', self.the_point)
            ],
                                                         limit=1)
            if zip_match:
                self.zip_id = zip_match[0]
class DemoWebsiteLeafletMapFeature(models.Model):
    _name = 'demo.website_leaflet.map.feature'
    _description = 'Map Feature'

    active = fields.Boolean(
        string='Active',
        default=True,
    )

    category_id = fields.Many2one(
        string='Category',
        comodel_name='demo.website_leaflet.category',
        ondelete='restrict',
    )

    geo_line = fields.GeoLine(string='Geo Line')

    geo_point = fields.GeoPoint(string='Geo Point')

    geo_polygon = fields.GeoPolygon(string='Geo Polygon')

    html_text = fields.Html(string='Popup text')

    name = fields.Char(
        string='Name',
        required=True,
    )

    open_popup = fields.Boolean(string='Popup opened on map')

    type = fields.Selection(
        string='Type',
        selection=[('geo_point', _('Geo Point')), ('geo_line', _('Geo Line')),
                   ('geo_polygon', _('Geo Polygon'))],
        default='point',
        required=True,
    )
Exemple #4
0
class DummyAbstractModel(models.AbstractModel):
    _name = 'test.abstract.dummy'
    _description = 'test.abstract.dummy'

    geo_line = fields.GeoLine(string="Line")