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: dummy.zip

Compute Method: _compute_ZIP_total_sales

Inputs Method Outputs
  • id
"""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.search(
                [
                    (
                        "the_point",
                        "geo_intersect",
                        {"dummy.zip.the_geom": [("id", "=", rec.id)]},
                    )
                ]
            )
            cursor = self.env.cr
            if res.ids:
                cursor.execute(
                    "SELECT sum(total_sales) from"
                    " geoengine_demo_automatic_retailing_machine "
                    "where id in %s;",
                    (tuple(res.ids),),
                )
                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

Back to entity