Skip to content

Conversation

@acsonefho
Copy link

This module is used to add condition (domain) on dynamic reports during generation of mail.template. When the mail is generated (based on the mail template), all dynamic attachments are generated (by standard Odoo) then the domain is applied (based on the record) to know if the attachment should be dropped or not.

@acsonefho
Copy link
Author

@OCA/mail-maintainers is it possible to review this PR please? 🦸

@tobiaszehntner tobiaszehntner force-pushed the 18.0-mail_template_conditional_report branch 2 times, most recently from ad7b053 to a570128 Compare May 30, 2025 14:33
This module is used to add condition (domain) on dynamic reports during generation of mail.template.
When the mail is generated (based on the mail template), all dynamic attachments are generated (by standard Odoo) then the domain is applied (based on the record) to know if the attachment should be dropped or not.
@tobiaszehntner tobiaszehntner force-pushed the 18.0-mail_template_conditional_report branch from a570128 to 70e3e51 Compare May 30, 2025 14:38
Copy link
Member

@hbrunn hbrunn left a comment

Choose a reason for hiding this comment

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

@acsonefho you don't need to ping maintainers 5 days after submission, we get more than enough noise as it is

ALTER TABLE mail_template_ir_actions_report_rel
ADD COLUMN id SERIAL PRIMARY KEY;
"""
env.cr.execute(query)
Copy link
Member

Choose a reason for hiding this comment

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

add an uninstall hook to undo this

attachments = values.pop("attachments", [])
validated_attachments = []
for template_report, attachment in zip(
self.mail_template_report_ids, attachments, strict=True
Copy link
Member

Choose a reason for hiding this comment

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

how do you guarantee those are ordered the same?

<list>
<field
name="ir_actions_report_id"
options="{'no_create': True, 'no_open': True}"
Copy link
Member

Choose a reason for hiding this comment

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

why no_open?

return TRUE_DOMAIN
return safe_eval(
self.filter_domain,
{
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest to put this into its own function for easy customization by other modules

@acsonefho
Copy link
Author

@acsonefho you don't need to ping maintainers 5 days after submission, we get more than enough noise as it is

The goal was to have opinion's members at the beginning to avoid full rewrite after few months.

Copy link
Member

@StefanRijnhart StefanRijnhart left a comment

Choose a reason for hiding this comment

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

Recycling my remark from #97 (which may interest you as well):

In Odoo, 'full' ir.model.access permissions are granted on the mail.template model to all users as is the case here, but these are amended by record rules specifying that regular users can only control their own templates: https://github.com/odoo/odoo/blob/18.0/addons/mail/security/mail_security.xml#L265-L285. Would you consider doing the same here (i.e. regular users can only create/write/delete conditional report configurations linked to the templates that they own), and editor/manager groups can edit all conditional attachments?

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.

4 participants