Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Geo spatial support Demo

Entity: geoengine.demo.automatic.retailing.machine

Compute Method: _compute_zip_id

Inputs Method Outputs
"""Exemple of on change on the point
        Lookup in zips if the code is within an area.
        Change the zip_id field accordingly
        """
for rec in self:
            if rec.the_point:
                zip_match = (
                    self.env["dummy.zip"]
                    .search([("the_geom", "geo_contains", rec.the_point)], limit=1)
                    .ids
                )
                if zip_match:
                    rec.zip_id = zip_match[0]
            else:
                rec.zip_id = 0

Back to entity