[17.0][IMP] api_log_mail: add default mail template for exceptions - #627
[17.0][IMP] api_log_mail: add default mail template for exceptions#627alessandropecchini99 wants to merge 1 commit into
Conversation
|
Hi @SirPyTech, |
SirPyTech
left a comment
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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"> |
| <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> |
There was a problem hiding this comment.
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.

FW Port from this PR: #622