Exemplo n.º 1
0
        class DummyModelRelated(GeoModel):
            _name = 'test.dummy.related'

            dummy_test_id = fields.Many2one(String='dummy_test',
                                            comodel_name='test.dummy')
            the_geom_related = geo_fields.GeoMultiPolygon(
                'related', related='dummy_test_id.the_geom')
Exemplo n.º 2
0
class NPA(geo_model.GeoModel):

    """GEO OSV SAMPLE"""

    _name = "dummy.zip"

    priority = fields.Integer('Priority', default=100)
    name = fields.Char('ZIP', size=64, index=True, required=True)
    city = fields.Char('City', size=64, index=True, required=True)
    the_geom = geo_fields.GeoMultiPolygon('NPA Shape')
    total_sales = fields.Float(
        compute='_get_ZIP_total_sales',
        string='Spatial! Total Sales',
    )

    @api.multi
    def _get_ZIP_total_sales(self):
        """Return the total of the invoiced sales for this npa"""
        mach_obj = self.env['geoengine.demo.automatic.retailing.machine']
        for rec in self:
            res = mach_obj.geo_search(
                domain=[],
                geo_domain=[
                    ('the_point',
                     'geo_intersect',
                     {'dummy.zip.the_geom': [('id', '=', rec.id)]})])

            cursor = self.env.cr
            if res:
                cursor.execute("SELECT sum(total_sales) from"
                               " geoengine_demo_automatic_retailing_machine "
                               "where id in %s;",
                               (tuple(res),))
                res = cursor.fetchone()
                if res:
                    rec.total_sales = res[0] or 0.0
                else:
                    rec.total_sales = 0.0
            else:
                rec.total_sales = 0.0

    def name_get(self, cursor, uid, ids, context=None):
        res = []
        for r in self.browse(cursor, uid, ids):
            res.append((r.id, u"%s %s" % (r.name, r.city)))
        return res
Exemplo n.º 3
0
class res_city_district(geo_model.GeoModel):
    _name = 'res.country.state.city.district'
    _inherit = 'res.country.state.city.district'

    geo_polygon = geo_fields.GeoMultiPolygon('Shape')
Exemplo n.º 4
0
class res_city_neighborhood(geo_model.GeoModel):
    _name = 'res.country.state.city.neighborhood'
    _inherit = 'res.country.state.city.neighborhood'

    geo_polygon = geo_fields.GeoMultiPolygon('Shape')