Skip to content

[MIG] base_geoengine: Migration to 18.0#1

Open
weinni2000 wants to merge 1 commit into18.0.after_lintersfrom
18.0-mig-base_geoengine
Open

[MIG] base_geoengine: Migration to 18.0#1
weinni2000 wants to merge 1 commit into18.0.after_lintersfrom
18.0-mig-base_geoengine

Conversation

@weinni2000
Copy link
Owner

@weinni2000 weinni2000 commented Nov 13, 2024

see modifications necessary for v18

Summary by Sourcery

Migrate the base_geoengine module to Odoo version 18.0, updating SQL expression handling, refactoring JavaScript modules, and adjusting documentation and CI configurations.

Enhancements:

  • Refactor the geoengine module to improve the handling of geospatial operators and SQL expressions, enhancing the integration with Odoo's search method.
  • Update JavaScript modules to use the new asset bundle system for loading libraries, improving the maintainability and performance of the geoengine module.

Build:

  • Add a new asset bundle 'base_geoengine.assets_jsLibs_geoengine' for managing JavaScript library dependencies.

CI:

  • Update the CI configuration to use a PostGIS-enabled PostgreSQL image, ensuring compatibility with geospatial features.

Documentation:

  • Update documentation links and references to reflect the migration to version 18.0, ensuring users have access to the correct resources.

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 13, 2024

Reviewer's Guide by Sourcery

This pull request migrates the base_geoengine module from Odoo 17.0 to 18.0. The main changes include updating the JavaScript code to be compatible with Odoo 18.0's new JavaScript framework, fixing template issues, and updating database-related code to work with the new version.

Class diagram for updated geoengine expressions

classDiagram
    class GeoField {
        +column_type()
        +convert_to_column(value, record, values, validate)
    }

    class GeoOperator {
        +_get_direct_como_op_sql(table, col, value, params, op)
        +_get_postgis_comp_sql(table, col, value, params, op)
        +get_geo_greater_sql(table, col, value, params)
        +get_geo_equal_sql(table, col, value, params)
    }

    class Expression {
        +parse()
        +__leaf_to_sql(leaf, model, alias)
    }

    GeoField --> GeoOperator : uses
    Expression --> GeoOperator : uses
    Expression --> GeoField : uses
Loading

Class diagram for updated GeoengineRecord component

classDiagram
    class GeoengineRecord {
        +setup()
        +createRecord(props)
        +static template
        +static Compiler
        +static INFO_BOX_ATTRIBUTE
    }

    GeoengineRecord --> GeoengineCompiler : uses
    GeoengineRecord --> INFO_BOX_ATTRIBUTE : uses
Loading

File-Level Changes

Change Details Files
Updated JavaScript code to be compatible with Odoo 18.0's framework
  • Removed @odoo-module directives as they are no longer needed
  • Updated imports to use new paths and naming conventions
  • Replaced _lt with _t for translations
  • Updated component templates to use new syntax
  • Fixed service usage by replacing useService with direct imports for some services
base_geoengine/static/src/js/views/geoengine/geoengine_record/geoengine_record.esm.js
base_geoengine/static/src/js/views/geoengine/geoengine_renderer/geoengine_renderer.esm.js
base_geoengine/static/src/js/views/geoengine/layers_panel/layers_panel.esm.js
base_geoengine/static/src/js/widgets/domain_selector_geo_field/domain_selector_geo_field/domain_selector_geo_field.esm.js
Updated database and SQL handling for PostgreSQL compatibility
  • Modified SQL query construction for geometry operations
  • Updated parameter handling in SQL queries
  • Fixed string escaping in geometry queries
base_geoengine/expressions.py
base_geoengine/geo_operators.py
Added new field templates and components for Odoo 18.0
  • Added new field component templates
  • Created separate files for different field types
  • Updated field rendering logic
base_geoengine/static/src/js/views/fields/char_field.esm.js
base_geoengine/static/src/js/views/fields/float_field.esm.js
base_geoengine/static/src/js/views/fields/integer_field.esm.js
base_geoengine/static/src/js/views/fields/field.esm.js
base_geoengine/static/src/js/views/fields/badge_field.esm.js
Updated view definitions and XML templates
  • Changed tree views to list views
  • Updated XML template syntax
  • Modified asset bundle definitions
base_geoengine/views/geo_raster_layer_view.xml
base_geoengine/views/geo_vector_layer_view.xml
base_geoengine/__manifest__.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @weinni2000 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 1 issue found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

createRecord(props) {
const {record} = props;
this.record = Object.create(null);
this.record = Object.create(null); // Kills the Chrome debugger
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Problematic workaround for Chrome debugger issue

Using Object.create(null) as a workaround for Chrome debugger issues is concerning. This could cause maintainability problems and debugging difficulties. Consider finding a proper solution that doesn't break debugging tools.

- A search bar is also available. It allows you to perform a search
into the RecordsPanel.
- A button to open/close the panels is also available.
- The module has been translated in French.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (documentation): Remove duplicate word 'now'

expression.SQL_OPERATORS.update(GEO_SQL_OPERATORS)


def __leaf_to_sql(leaf, model, alias): # noqa: C901
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (code-quality): We've found these issues:


Explanation

The quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.

How can you solve this?

It might be worth refactoring this function to make it shorter and more readable.

  • Reduce the function length by extracting pieces of functionality out into
    their own functions. This is the most important thing you can do - ideally a
    function should be less than 10 lines.
  • Reduce nesting, perhaps by introducing guard clauses to return early.
  • Ensure that variables are tightly scoped, so that code using related concepts
    sits together within the function rather than being scattered.

Comment on lines +992 to +997
if operator in (">", "<="):
right += " 23:59:59"
else:
right += " 00:00:00"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (code-quality): Replace if statement with if expression (assign-if-exp)

Comment on lines 14 to +17
else:
base = self.geo_field.entry_to_shape(value, same_type=False)
params.append(base.wkt)
return f" ST_Area({table}.{col}) {op} ST_Area(ST_GeomFromText(%s))"
return f" ST_Area({table}.{col}) {op} ST_Area(ST_GeomFromText('%s'))"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Remove unnecessary else after guard condition (remove-unnecessary-else)

Suggested change
else:
base = self.geo_field.entry_to_shape(value, same_type=False)
params.append(base.wkt)
return f" ST_Area({table}.{col}) {op} ST_Area(ST_GeomFromText(%s))"
return f" ST_Area({table}.{col}) {op} ST_Area(ST_GeomFromText('%s'))"
base = self.geo_field.entry_to_shape(value, same_type=False)
params.append(base.wkt)
return f" ST_Area({table}.{col}) {op} ST_Area(ST_GeomFromText('%s'))"

@weinni2000 weinni2000 force-pushed the 18.0-mig-base_geoengine branch 3 times, most recently from fa710ed to 72b900b Compare November 13, 2024 14:27
@weinni2000 weinni2000 force-pushed the 18.0-mig-base_geoengine branch from 72b900b to 490d05a Compare November 22, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant