Skip to content

[17.0][IMP] api_log_mail: add default mail template for exceptions - #627

Open
alessandropecchini99 wants to merge 1 commit into
OCA:17.0from
PyTech-SRL:17-farward-port-default-mail-template-api_log
Open

[17.0][IMP] api_log_mail: add default mail template for exceptions#627
alessandropecchini99 wants to merge 1 commit into
OCA:17.0from
PyTech-SRL:17-farward-port-default-mail-template-api_log

Conversation

@alessandropecchini99

@alessandropecchini99 alessandropecchini99 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

FW Port from this PR: #622

@OCA-git-bot

Copy link
Copy Markdown
Contributor

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

@alessandropecchini99
alessandropecchini99 marked this pull request as draft July 6, 2026 14:28
@alessandropecchini99
alessandropecchini99 marked this pull request as ready for review July 16, 2026 09:35

@HekkiMelody HekkiMelody left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code review, LGTM

@SirPyTech SirPyTech 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.

Thanks for the PR!
It would be nice to apply the changes directly in 16.0 too, especially the fix for the issues.

~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo noupdate="1">
<record id="email_template_fastapi_error" model="mail.template">

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.

suggestion: api_log_mail is a generic module so it should not mention fastapi.
Please either remove the fastapi mentions, or move this to the fastapi_log_mail module.
Note that the migration from 16.0 should work as expected: for instance, if you rename the XMLID you should call https://oca.github.io/openupgradelib/API.html#openupgradelib.openupgrade.rename_xmlids.

>{{object.collection_ref.user_id.email or object.env.ref('base.partner_root').email}}</field>
<field
name="email_to"
>{{object.collection_ref.company_id.scheduler_error_email_address}}</field>

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.

issue: The field scheduler_error_email_address does not exist, so rendering the template raises

[...]
UserError: Failed to render inline_template template: {{object.collection_ref.company_id.scheduler_error_email_address}}
Error details: AttributeError("'res.company' object has no attribute 'scheduler_error_email_address'") while evaluating
'object.collection_ref.company_id.scheduler_error_email_address'

It would be a nice addition to the module, or you can just pick the email of the admin user.

After you fix it, remember to add a test so that there won't be a regression in the future, as suggested in:

As a general rule, a bug fix should come with a unittest which would fail without the fix itself. This is to assure that regression will not happen in the future.

(from https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#6tests)

~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo noupdate="1">
<record id="email_template_fastapi_error" model="mail.template">

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.

chore: Please inform the user in readme/CONFIGURE.md that this template exists and should be properly configured/customized.

>{{object.collection_ref.company_id.scheduler_error_email_address}}</field>
<field name="subject">Odoo FastAPI Error</field>
<field name="auto_delete" eval="False" />
<field name="body_html" type="html">

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.

praise: This prints out a nicely formatted email 🤗
Image

<field name="model_id" ref="api_log.model_api_log" />
<field
name="email_from"
>{{object.collection_ref.user_id.email or object.env.ref('base.partner_root').email}}</field>

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.

issue: The field user_id does not exist in a generic collection, it is only present when the collection is a fastapi.endpoint record.
Please remove it if you choose to keep the template in this module.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants