Skip to content

[IMP] edi_core_oca, edi_storage_oca: backend test mode - #393

Closed
dreispt wants to merge 2 commits into
OCA:19.0from
dreispt:feature-edi-backend-test-mode
Closed

dreispt wants to merge 2 commits into
OCA:19.0from
dreispt:feature-edi-backend-test-mode

Conversation

@dreispt

@dreispt dreispt commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a Test mode toggle to EDI backends so exchanges can run against
test endpoints instead of live partners.

  • edi.backend.test_mode flag, shown only for backend types that
    support it (demo_* types by default; connectors opt in via
    _edi_test_mode_supported).
  • A warning banner appears on the backend form while test mode is on.
  • data/neutralize.sql enables test mode on all backends, so copied
    databases never reach live partners.
  • Connection parameters resolve through get_conn_parameter(), which
    connectors can override to return test values — edi_storage_oca now
    reads directories through it.

No behavior change for existing backends: test mode defaults to off.

Test plan

  • Enable test mode on a demo backend and confirm the banner shows.
  • Confirm the toggle is hidden on non-demo backend types.
  • Neutralize a database and check test_mode is set.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @simahawk, @etobella,
some modules you are maintaining are being modified, check this out!

@dreispt
dreispt force-pushed the feature-edi-backend-test-mode branch 3 times, most recently from 64ff908 to 721f4f9 Compare November 10, 2026 16:23
@OCA-git-bot OCA-git-bot added the mod:edi_storage_oca Module edi_storage_oca label Nov 10, 2026
@dreispt dreispt changed the title [IMP] edi_core_oca: add test_mode flag to edi.backend [IMP] edi_core_oca, edi_storage_oca: backend test mode support Nov 10, 2026
@dreispt
dreispt force-pushed the feature-edi-backend-test-mode branch from b6f3f91 to 081f506 Compare November 10, 2026 16:35
@dreispt dreispt changed the title [IMP] edi_core_oca, edi_storage_oca: backend test mode support [IMP] edi_core_oca, edi_storage_oca: backend test mode Nov 10, 2026
@dreispt
dreispt force-pushed the feature-edi-backend-test-mode branch 2 times, most recently from a300e50 to 83a2286 Compare November 10, 2026 16:51
@etobella

Copy link
Copy Markdown
Member

🤔 Might have sense, however, wouldn't be easier to ignore the send?

@dreispt
dreispt force-pushed the feature-edi-backend-test-mode branch 2 times, most recently from 5a8459a to 1bc9c06 Compare November 10, 2026 18:07
@dreispt

dreispt commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

🤔 Might have sense, however, wouldn't be easier to ignore the send?

I want the send to happen, but to a different server, or a different login, or sometimes the just different target directories.

Add a generic test-mode toggle on edi.backend so backend
implementations can route exchanges through their test
configuration instead of live partners.

- test_mode boolean on the backend form, visible only for backend
  types flagged test_mode_supported (new field on edi.backend.type)
- test_mode_supported related field + warning banner while active
- get_conn_parameter(name, operation=None) resolves test_<name>
  for whitelisted params (_edi_test_conn_param_fields) at read
  time, to be extended by backend implementations
- data/neutralize.sql enables test_mode on all backends of copied
  or neutralized databases so they never hit live partners

Assisted-by: Devin:SWE-2 Flash Medium
Route all connection reads through edi.backend.get_conn_parameter()
so test mode resolves test_* values at read time without rewriting
live configuration:

- whitelist storage_id + all *_dir_* params for test_ overrides
- test_storage_id field for an alternate test FS storage
  (different host/credentials)
- test_*_dir_* fields on the backend form (Test environment group)

Assisted-by: Devin:SWE-2 Flash Medium
@dreispt
dreispt force-pushed the feature-edi-backend-test-mode branch from 1bc9c06 to 8b4d1f2 Compare November 10, 2026 18:42
@dreispt
dreispt marked this pull request as ready for review November 10, 2026 18:46

@simahawk simahawk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please move it to its own module, eg: edi_storage_test_mode.

As for non prod envs override, I would recommend to use confidoo (we are moving away from server env for this). See OCA/server-env#258

@@ -0,0 +1,2 @@
-- Copied/neutralized databases must not talk to live partners.
UPDATE edi_backend SET test_mode = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would avoid this by default, if you really need it it should be done in your own module.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Providing a test mode and not supporting the neutralization sounds broken to me.
Note that this will have absolutely no effect in backends that don't support the test mode yet.
Hopefully that is added, because it is scary to have a test neutralized DB that can still send invoices to my customer's production system.

output_dir_error = fields.Char(
"Output error directory", help="Path to folder for error operations"
)
test_input_dir_pending = fields.Char(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would simply assume that by convention the normal path is prefixed or suffixed by "test" and if you use a different storage, you don't care

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

II may not be in control of the directory structure provided by the external system.

def exchange_record_model(self):
return self.env["edi.exchange.record"]

def get_conn_parameter(self, name, operation=None):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should definitely not be in core and it looks more as a task for a send handler

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

An alternative would be to have backend specific neutralization scripts that overwite the production secrets with the test secrets.
I do see myself reimplementing a "get_conn_parameters" on each integration, so it would be nice to have a common method available to extend form.

@simahawk

Copy link
Copy Markdown
Contributor

I want the send to happen, but to a different server, or a different login, or sometimes the just different target directories.

But then just set another storage while you are testing. In any case what you are proposing here is going to impact ALL the exchanges.
I don't think we need an additional module for this 🤔

A different thing would be if you want to send to a specific storage 1 single exchange type to test.

Let's take a step back: what is the flow that you have in mind and what is really missing to make it happen in a smooth way?

@dreispt

dreispt commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

@simahawk It could me moved to a separate module, but I believe this is a missing critical feature, it it would not be a good service to do so. Explaining.

On the motivation:

Proper neutralization of external connections is a basic expectation for staging/testing systems. Not supporting this is a business risk.
So at minimum backends should provide the neutralization scripts necessary to guarantee than production connections are disabled.
Neutralization is a standard feature in Odoo for quite a few versions, and may hosting systems rely on it, including but not limited to Odoo.sh.
All Odoo CE and EE provided connections implement this pattern.
You're OK to roll out alternatives more convenient to you, but the standard neutralization feature should be honored.

Having the neutralization automatically enable the test system connection credentials through configuration is a quality of life improvement.
This allows end users to try workflows in a staging environment without the need to manually retrieve and set the test connection secrets.

On the proposed implementation:

It is designed provide support for 2) while having no impact on existing backend implementations and installations.
The Test Mode feature is designed as an opt-in to be adopted by the backend implementations.
Existing backends will see absolutely no change, unless they opt to implement the test mode feature.

  1. I realize there is an implementation gap, and 1) is currently not enforced for backends not adopting the test mode, keeping exposure for critical business risk. I can improve the proposed code to incorporate that case.

@etobella

Copy link
Copy Markdown
Member

@dreispt If we want proper neutralization, the right approach would be disable sending. It is safer because it covers all examples.

Right now, this relies on an extra system to add a lot of extra configuration that users will not implement and might have no sense in a lot of cases.

@simahawk

simahawk commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

@simahawk It could me moved to a separate module, but I believe this is a missing critical feature, it it would not be a good service to do so. Explaining.

On the motivation:

Proper neutralization of external connections is a basic expectation for staging/testing systems. Not supporting this is a business risk. So at minimum backends should provide the neutralization scripts necessary to guarantee than production connections are disabled. Neutralization is a standard feature in Odoo for quite a few versions, and may hosting systems rely on it, including but not limited to Odoo.sh. All Odoo CE and EE provided connections implement this pattern. You're OK to roll out alternatives more convenient to you, but the standard neutralization feature should be honored.

This is not the place. The framework is agnostic of where you send files to or receive from. The neutralization must be done on the storage and webservice (for WS I've just added it on v18).

Having the neutralization automatically enable the test system connection credentials through configuration is a quality of life improvement. This allows end users to try workflows in a staging environment without the need to manually retrieve and set the test connection secrets.

That's why I suggested to use per env conf instead of handling everything on prod.

On the proposed implementation:

It is designed provide support for 2) while having no impact on existing backend implementations and installations. The Test Mode feature is designed as an opt-in to be adopted by the backend implementations. Existing backends will see absolutely no change, unless they opt to implement the test mode feature.

4. I realize there is an implementation gap, and 1) is currently not enforced for backends not adopting the test mode, keeping exposure for critical business risk. I can improve the proposed code to incorporate that case.

It shouldn't be part of the core because as of now is not a business risk. You can already achieve what you want today w/o further additions (or just the neutralization of the storage modules).

@dreispt

dreispt commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

I can agree on a test mode to be a separate module.
But proper neutralization of existing connections is critical.
That might be through inactivation of backends, or by resetting the production secrets, or both.

@simahawk

Copy link
Copy Markdown
Contributor

But proper neutralization of existing connections is critical.

Again, is not to be done here. It goes on the modules/model that you use to send to/receive from :)

@dreispt

dreispt commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Again, is not to be done here. It goes on the modules/model that you use to send to/receive from :)

I disagree.
Backends with no ensure neutralization are a serious business risk.
If possible, it is responsible for the core module to provide such neutralization logic.
Especially when this is generally expected, being a core Odoo feature that is honored everywhere else.

@dreispt dreispt closed this Nov 11, 2026
@simahawk

Copy link
Copy Markdown
Contributor

@dreispt I'm not sure if I'm not explaining myself properly or if you should re-read what I wrote before 😅
I explained why storage and webservice neutralization do not belong to here.
If you are setting credentials on the edi.backend, I would argue why you do that -> is that the case?
If you have special use cases or counter arguments provide full details and I will be more than happy to jump on a call with you to discuss this 😉

@dreispt

dreispt commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Thank you for following up. I may have misunderstood (misled?) at what a backend is.

I assumed it represented a connection to an external system, and the backend type represented the different APIs and transports.
And so the backend would hold secrets and connection details.

I can see that Storage delegates secrets to a separate Model, and Webservice transports use a similar pattern.
So I can agree that the secret handling is per transport implementation, and not at the backend level.

@dreispt

dreispt commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Follow up: OCA/storage#696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:edi_core_oca Module edi_core_oca mod:edi_storage_oca Module edi_storage_oca series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants