Skip to content

Odoo 19 Compatibility #286

@michaelhofer

Description

@michaelhofer

I have recently migrated an Odoo instance to Odoo 19 and have noticed that this breaks the auto_backup module.

The auto_backup module fails on Odoo 19 with the following error:

module 'odoo.tools' has no attribute 'find_pg_tool'

It seems like Odoo 19 removed two utility functions that were previously available in odoo.tools:

  • tools.find_pg_tool()
  • tools.exec_pg_environ()

Would those changes make sense for a PR, or are there better ways to do that?

  1. Finding pg_dump tool:
  # Old (Odoo ≤18):
  cmd = [tools.find_pg_tool('pg_dump'), '--no-owner', db_name]

  # New (Odoo 19):
  pg_dump_path = shutil.which('pg_dump')
  if not pg_dump_path:
      raise UserError(_('PostgreSQL pg_dump tool not found in system PATH'))
  cmd = [pg_dump_path, '--no-owner', db_name]
  1. Setting PostgreSQL environment:
  # Old (Odoo ≤18):
  env = tools.exec_pg_environ()

  # New (Odoo 19):
  env = os.environ.copy()
  db_config = odoo.tools.config
  if db_config.get('db_host'):
      env['PGHOST'] = db_config['db_host']
  if db_config.get('db_port'):
      env['PGPORT'] = str(db_config['db_port'])
  if db_config.get('db_user'):
      env['PGUSER'] = db_config['db_user']
  if db_config.get('db_password'):
      env['PGPASSWORD'] = db_config['db_password']

Is this approach acceptable for fixing Odoo 19 compatibility? Are there any concerns with using shutil.which() and manually constructing the PostgreSQL environment variables?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions