Skip to content

[19.0][MIG] edi_mail_import_oca#229

Open
etobella wants to merge 5 commits intoOCA:19.0from
dixmit:19.0-mig-mail
Open

[19.0][MIG] edi_mail_import_oca#229
etobella wants to merge 5 commits intoOCA:19.0from
dixmit:19.0-mig-mail

Conversation

@etobella
Copy link
Member

@etobella etobella commented Feb 2, 2026

Depends on #215

Copy link
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

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

Interesting approach! Thanks!


class EdiExchangeType(models.Model):
_name = "edi.exchange.type"
_inherit = ["edi.exchange.type", "mail.alias.mixin"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking out loud: instead of polluting the exchange type model, wouldn't be interesting to have a specific record for this? Eg: "EDI mail gateway" or something similar.
Easier to maintain and to configure for the end user probably. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or maybe using edi.backend. At the end, that is the goal of backends, isn't it?

@etobella
Copy link
Member Author

etobella commented Feb 4, 2026

@simahawk After your comments, I do agree that the best approach would be to set everything on the backend and do the same thing we do with Storage.

Also, I improved REadmes and information inside the backend to make it easier to handle (actually, it would be nice to include similar information in other modules to make it easier for users. Thanks for your comments, IMO they improved the solution.

image

<label
for="alias_name"
class="fw-bold o_form_label"
string="Create tasks by sending an email to"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
string="Create tasks by sending an email to"
string="Create EDI records by sending an email to"

return values

def _mail_exchange_type_pending_input_domain(self):
"""Domain for retrieving input exchange types for emails."""
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add some more conventional constraint here.
What if we add specific type of backend Email and we rely on the fact that exc types refer to that type.
I would make it more clear from the configuration point of view.

not custom_values.get("type_id")
and not backend.full_mail_exchange_type_id
):
types = self.env["edi.exchange.type"].search(
Copy link
Contributor

Choose a reason for hiding this comment

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

if we rely on the fact that we can have multiple files in an email and multiple types configured, we should support multiple creation of records.

Hence, here we should collect all new record values and call super on each set of values at the end.
Also, each record should be related to a single parent record (conventionally I would use the 1st one).

custom_values["type_id"] = exchange_type.id
break
else:
if backend.full_mail_exchange_type_id:
Copy link
Contributor

Choose a reason for hiding this comment

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

If I get it right you want the possibility to just store the full content of the email. Correct?

If that's the case, I would move this configuration on the type itself.
Something like:

mail_record_policy = fields.Selection(
    [
        ("full", "Only archive the full mail message"),
        ("pattern", "Match single filename pattern"),
    ]
)

This field will be visible only for the backend type email and will command how this record creation will work.

As for the full json storage: IMO attachments should not be incapsulated into the json data.
We should store them as attachments of the exchange record.

WDYT?

content = json.dumps(new_message_dict)
filename = "email_message.json"
if not custom_values or "type_id" not in custom_values:
_logger.warning(
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a need for this logging if you raise an error?

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