Skip to content

fix(spp_hazard_programs,spp_import_match,spp_oauth): beta fixes and import overwrite toggle#85

Merged
emjay0921 merged 6 commits into19.0from
fix/hazard-import-oauth-beta-fixes
Mar 11, 2026
Merged

fix(spp_hazard_programs,spp_import_match,spp_oauth): beta fixes and import overwrite toggle#85
emjay0921 merged 6 commits into19.0from
fix/hazard-import-oauth-beta-fixes

Conversation

@emjay0921
Copy link
Copy Markdown
Contributor

Why is this change needed?

  • spp_hazard_programs: Unused ACL file and stale view XML needed cleanup
  • spp_import_match: Legacy JS/XML was incompatible with Odoo 19 OWL framework; import matching lacked user control for overwrite behavior and result feedback
  • spp_oauth: Minor fixes for Odoo 19 compatibility in RSA tools and settings view

How was the change implemented?

  • spp_hazard_programs: Removed unused ir.model.access.csv, fixed program_views.xml
  • spp_import_match:
    • Migrated legacy JS/XML to modern OWL components (import_match_selector.js / .xml)
    • Added "Overwrite Match" toggle in import dialog (defaults from config, user-controllable)
    • Added import result notifications showing match counts (created/skipped/overwritten)
    • Used threading.local() to pass counts between Base.load() and execute_import()
    • Dry run shows preview counts; real import shows success toast
  • spp_oauth: Fixed rsa_encode_decode.py and res_config_view.xml for Odoo 19

New unit tests

No new unit tests added. Existing tests for spp_oauth (10/10 pass) and spp_import_match verified.

Unit tests executed by the author

  • spp_oauth: 10 tests, 0 failed, 0 errors
  • spp_import_match: manual testing with CSV import (match/create/overwrite/skip scenarios)

How to test manually

  1. spp_import_match: Go to any import dialog → select Import Matching config → verify "Overwrite Match" toggle appears below dropdown → import CSV with matching records → verify counts in notification
  2. spp_oauth: Go to Settings > SPP OAuth Settings → verify key fields → run /tmp/test_spp_oauth.py for JWT signing/verification

Related links

…mport overwrite toggle

- spp_hazard_programs: remove unused ACL file, fix view XML
- spp_import_match: migrate legacy JS/XML to OWL components, add overwrite match toggle with per-import control, add import result notifications with match counts
- spp_oauth: fix RSA encode/decode and settings view for Odoo 19
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.42%. Comparing base (a4f3701) to head (2abff7b).
⚠️ Report is 9 commits behind head on 19.0.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0      #85      +/-   ##
==========================================
+ Coverage   69.15%   69.42%   +0.26%     
==========================================
  Files         628      647      +19     
  Lines       35632    36055     +423     
==========================================
+ Hits        24643    25030     +387     
- Misses      10989    11025      +36     
Flag Coverage Δ
spp_base_common 90.26% <ø> (ø)
spp_hazard_programs 97.14% <ø> (?)
spp_import_match 89.49% <100.00%> (?)
spp_oauth 97.43% <100.00%> (?)
spp_programs 45.51% <ø> (ø)
spp_security 66.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_hazard_programs/__manifest__.py 0.00% <ø> (ø)
spp_import_match/__manifest__.py 0.00% <ø> (ø)
spp_import_match/models/base.py 83.75% <100.00%> (ø)
spp_import_match/models/base_import.py 83.89% <100.00%> (ø)
spp_import_match/models/import_match.py 100.00% <100.00%> (ø)
spp_oauth/__manifest__.py 0.00% <ø> (ø)
spp_oauth/tools/rsa_encode_decode.py 100.00% <100.00%> (ø)

... and 12 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on refining and stabilizing three core OpenSPP modules for Odoo 19. It addresses critical compatibility issues, enhances user control over data import processes, and streamlines module configurations, moving them from an alpha to a beta development stage. The changes aim to improve the robustness and usability of the platform's hazard programs, data import functionalities, and OAuth authentication.

Highlights

  • Module Maturity Update: The development status for spp_hazard_programs, spp_import_match, and spp_oauth modules has been updated from Alpha to Beta, indicating increased stability and readiness.
  • Import Matching Enhancements: The spp_import_match module has been significantly improved with a migration to Odoo 19's OWL framework, the addition of an 'Overwrite Match' toggle for user control during imports, and detailed notifications showing created, skipped, and overwritten record counts.
  • Hazard Programs Cleanup: The spp_hazard_programs module underwent a cleanup, which involved removing an unused Access Control List (ACL) file and a stale view XML entry.
  • OAuth Compatibility Fixes: Minor fixes were applied to the spp_oauth module to ensure full compatibility with Odoo 19, specifically addressing issues in RSA tools and the settings view configuration.
Activity
  • The author, emjay0921, performed manual testing for spp_import_match covering match, create, overwrite, and skip scenarios.
  • Existing unit tests for spp_oauth were verified, with all 10 tests passing.
  • No new unit tests were added in this pull request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several fixes and improvements across spp_hazard_programs, spp_import_match, and spp_oauth modules, upgrading them to Beta status. The changes in spp_import_match are significant, migrating the import matching feature to the OWL framework, adding an overwrite toggle, and providing user feedback on import results. The use of threading.local is a good approach for passing data in Odoo's threaded environment, and the refactoring in spp_import_match/models/base.py to use self._fields is a great performance improvement. My review includes a suggestion to refactor some duplicated code for better maintainability and a fix for a documentation formatting issue.

Comment on lines +70 to +90
if dryrun:
_logger.info("Doing dry-run import")
if import_match_ids:
self = self.with_context(import_match_ids=import_match_ids)
return super().execute_import(fields, columns, options, dryrun=True)
self = self.with_context(import_match_ids=import_match_ids, overwrite_match=overwrite_match)
result = super().execute_import(fields, columns, options, dryrun=True)
counts = getattr(_import_match_local, "counts", None)
if counts:
result["import_match_counts"] = counts
_import_match_local.counts = None
return result

if len(input_file_data) <= 100:
_logger.info("Doing normal import")
if import_match_ids:
self = self.with_context(import_match_ids=import_match_ids)
return super().execute_import(fields, columns, options, dryrun=False)
self = self.with_context(import_match_ids=import_match_ids, overwrite_match=overwrite_match)
result = super().execute_import(fields, columns, options, dryrun=False)
counts = getattr(_import_match_local, "counts", None)
if counts:
result["import_match_counts"] = counts
_import_match_local.counts = None
return result
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There's significant code duplication between the dryrun block and the synchronous import block (len(input_file_data) <= 100). Both blocks perform nearly identical logic for adding context, calling super().execute_import, and handling the results. This can be refactored into a single conditional block to improve maintainability and reduce redundancy.

Suggested change
if dryrun:
_logger.info("Doing dry-run import")
if import_match_ids:
self = self.with_context(import_match_ids=import_match_ids)
return super().execute_import(fields, columns, options, dryrun=True)
self = self.with_context(import_match_ids=import_match_ids, overwrite_match=overwrite_match)
result = super().execute_import(fields, columns, options, dryrun=True)
counts = getattr(_import_match_local, "counts", None)
if counts:
result["import_match_counts"] = counts
_import_match_local.counts = None
return result
if len(input_file_data) <= 100:
_logger.info("Doing normal import")
if import_match_ids:
self = self.with_context(import_match_ids=import_match_ids)
return super().execute_import(fields, columns, options, dryrun=False)
self = self.with_context(import_match_ids=import_match_ids, overwrite_match=overwrite_match)
result = super().execute_import(fields, columns, options, dryrun=False)
counts = getattr(_import_match_local, "counts", None)
if counts:
result["import_match_counts"] = counts
_import_match_local.counts = None
return result
if dryrun or len(input_file_data) <= 100:
_logger.info("Doing %s import", "dry-run" if dryrun else "synchronous")
import_instance = self
if import_match_ids:
import_instance = self.with_context(
import_match_ids=import_match_ids, overwrite_match=overwrite_match
)
result = super(SPPBaseImport, import_instance).execute_import(
fields, columns, options, dryrun=dryrun
)
counts = getattr(_import_match_local, "counts", None)
if counts:
result["import_match_counts"] = counts
_import_match_local.counts = None
return result

Comment on lines +62 to +63
| ` | Decodes and verifies JWT token, |
| `verify_and_decode_signature()`` | returns payload |
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There appears to be a formatting error in this reStructuredText table. The backticks for verify_and_decode_signature() are misplaced, which will likely cause rendering issues in the documentation. The function name should be on the same line and enclosed in double backticks. You may need to adjust the table's column widths to accommodate the full function name on one line.

Suggested change
| ` | Decodes and verifies JWT token, |
| `verify_and_decode_signature()`` | returns payload |
| ``verify_and_decode_signature()`` | Decodes and verifies JWT token, returns payload |

…et via UI

When import_match_ids is not passed through the UI options (e.g. in
tests or programmatic imports), fall back to reading overwrite_match
from the matching config records instead of defaulting to False.
Reverts oca-gen-addon-readme output to match CI's version to avoid
pre-commit failures from tool version differences.
Regenerated auto-generated files for spp_hazard_programs,
spp_import_match, and spp_oauth to match CI oca-gen-addon-readme
output with Beta status badges.
@gonzalesedwin1123
Copy link
Copy Markdown
Member

@emjay0921 Please increase the code coverage of spp_import_match/models/base_import.py. Fix the code base on the Gemini-code-assist recommendations.

Add test_base_load.py (8 tests) covering Base.load() override paths:
no usable rules, overwrite true/false, no match creates, mixed records,
import_match_ids context filtering, id field append, match counts tracking.

Add test_base_import_methods.py (8 tests) covering SPPBaseImport helpers:
CSV attachment roundtrip, custom options, extract chunks, import_one_chunk
success/error, ImportValidationError, execute_import with match_ids context.

Add 3 tests to test_import_match_model.py: onchange_field_id skips
relational fields, match_find sub_field matching, match_find multiple
rule combinations.
…in execute_import

Merge the nearly identical dryrun and synchronous (<= 100 rows) blocks
into a single conditional, reducing code duplication while preserving
identical behavior.
@emjay0921 emjay0921 merged commit 87d3302 into 19.0 Mar 11, 2026
21 checks passed
@emjay0921 emjay0921 deleted the fix/hazard-import-oauth-beta-fixes branch March 11, 2026 03:08
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.

2 participants