"""Helper to setup Postgis"""
import logging

from odoo.exceptions import MissingError

logger = logging.getLogger('geoengine.sql')


def init_postgis(cr):
    """ Initialize postgis
    Add PostGIS support to the database. PostGIS is a spatial database
    extender for PostgreSQL object-relational database. It adds support for
    geographic objects allowing location queries to be run in SQL.
    """
    cr.execute("""
        SELECT
            tablename
        FROM
            pg_tables
        WHERE
            tablename='spatial_ref_sys';
    """)
    check = cr.fetchone()
    if check:
        return {}
    try:
        cr.execute("""
        CREATE EXTENSION postgis;
        CREATE EXTENSION postgis_topology;
    """)
    except Exception:
        raise MissingError(
            "Error, can not automatically initialize spatial postgis support. "
            "Database user may have to be superuser and postgres/postgis "
            "extentions with their devel header have to be installed. "
            "If you do not want Odoo to connect with a super user "
            "you can manually prepare your database. To do this"
            "open a client to your database using a super user and run: \n"
            "CREATE EXTENSION postgis;\n"
            "CREATE EXTENSION postgis_topology;\n"
        )

"""Helper to setup Postgis"""
import logging

from odoo import _
from odoo.exceptions import MissingError

logger = logging.getLogger('geoengine.sql')


def init_postgis(cr):
    """ Initialize postgis
    Add PostGIS support to the database. PostGIS is a spatial database
    extender for PostgreSQL object-relational database. It adds support for
    geographic objects allowing location queries to be run in SQL.
    """
    cr.execute("""
        SELECT
            tablename
        FROM
            pg_tables
        WHERE
            tablename='spatial_ref_sys';
    """)
    check = cr.fetchone()
    if check:
        return {}
    try:
        cr.execute("""
        CREATE EXTENSION postgis;
        CREATE EXTENSION postgis_topology;
    """)
    except Exception:
        raise MissingError(
            _(
                "Error, can not automatically initialize spatial postgis"
                " support. Database user may have to be superuser and"
                " postgres/postgis extensions with their devel header have"
                " to be installed. If you do not want Odoo to connect with a"
                " super user you can manually prepare your database. To do"
                " this, open a client to your database using a super user and"
                " run:\n"
                "CREATE EXTENSION postgis;\n"
                "CREATE EXTENSION postgis_topology;\n"
            )
        )

Make MissingError translatable for auto install of postgis extension, plus fix some typos
Make MissingError translatable for auto install of postgis extension, plus fix some typos

  """Helper to setup Postgis"""
  import logging
  
+ from odoo import _
  from odoo.exceptions import MissingError
  
  logger = logging.getLogger('geoengine.sql')
  
  
  def init_postgis(cr):
      """ Initialize postgis
      Add PostGIS support to the database. PostGIS is a spatial database
      extender for PostgreSQL object-relational database. It adds support for
      geographic objects allowing location queries to be run in SQL.
      """
      cr.execute("""
          SELECT
              tablename
          FROM
              pg_tables
          WHERE
              tablename='spatial_ref_sys';
      """)
      check = cr.fetchone()
      if check:
          return {}
      try:
          cr.execute("""
          CREATE EXTENSION postgis;
          CREATE EXTENSION postgis_topology;
      """)
      except Exception:
          raise MissingError(
+             _(
-             "Error, can not automatically initialize spatial postgis support. "
+                 "Error, can not automatically initialize spatial postgis"
-             "Database user may have to be superuser and postgres/postgis "
+                 " support. Database user may have to be superuser and"
-             "extentions with their devel header have to be installed. "
+                 " postgres/postgis extensions with their devel header have"
-             "If you do not want Odoo to connect with a super user "
+                 " to be installed. If you do not want Odoo to connect with a"
-             "you can manually prepare your database. To do this"
+                 " super user you can manually prepare your database. To do"
-             "open a client to your database using a super user and run: \n"
+                 " this, open a client to your database using a super user and"
+                 " run:\n"
-             "CREATE EXTENSION postgis;\n"
+                 "CREATE EXTENSION postgis;\n"
-             "CREATE EXTENSION postgis_topology;\n"
+                 "CREATE EXTENSION postgis_topology;\n"
+             )
          )
  
Make MissingError translatable for auto install of postgis extension, plus fix some typos
## Code Before:
"""Helper to setup Postgis"""
import logging

from odoo.exceptions import MissingError

logger = logging.getLogger('geoengine.sql')


def init_postgis(cr):
    """ Initialize postgis
    Add PostGIS support to the database. PostGIS is a spatial database
    extender for PostgreSQL object-relational database. It adds support for
    geographic objects allowing location queries to be run in SQL.
    """
    cr.execute("""
        SELECT
            tablename
        FROM
            pg_tables
        WHERE
            tablename='spatial_ref_sys';
    """)
    check = cr.fetchone()
    if check:
        return {}
    try:
        cr.execute("""
        CREATE EXTENSION postgis;
        CREATE EXTENSION postgis_topology;
    """)
    except Exception:
        raise MissingError(
            "Error, can not automatically initialize spatial postgis support. "
            "Database user may have to be superuser and postgres/postgis "
            "extentions with their devel header have to be installed. "
            "If you do not want Odoo to connect with a super user "
            "you can manually prepare your database. To do this"
            "open a client to your database using a super user and run: \n"
            "CREATE EXTENSION postgis;\n"
            "CREATE EXTENSION postgis_topology;\n"
        )

## Instruction:
Make MissingError translatable for auto install of postgis extension, plus fix some typos
## Code After:
"""Helper to setup Postgis"""
import logging

from odoo import _
from odoo.exceptions import MissingError

logger = logging.getLogger('geoengine.sql')


def init_postgis(cr):
    """ Initialize postgis
    Add PostGIS support to the database. PostGIS is a spatial database
    extender for PostgreSQL object-relational database. It adds support for
    geographic objects allowing location queries to be run in SQL.
    """
    cr.execute("""
        SELECT
            tablename
        FROM
            pg_tables
        WHERE
            tablename='spatial_ref_sys';
    """)
    check = cr.fetchone()
    if check:
        return {}
    try:
        cr.execute("""
        CREATE EXTENSION postgis;
        CREATE EXTENSION postgis_topology;
    """)
    except Exception:
        raise MissingError(
            _(
                "Error, can not automatically initialize spatial postgis"
                " support. Database user may have to be superuser and"
                " postgres/postgis extensions with their devel header have"
                " to be installed. If you do not want Odoo to connect with a"
                " super user you can manually prepare your database. To do"
                " this, open a client to your database using a super user and"
                " run:\n"
                "CREATE EXTENSION postgis;\n"
                "CREATE EXTENSION postgis_topology;\n"
            )
        )
