Skip to content

[18.0][ADD] report_positioned_image#1138

Open
kanda999 wants to merge 1 commit intoOCA:18.0from
qrtl:18.0-add-report_positioned_image
Open

[18.0][ADD] report_positioned_image#1138
kanda999 wants to merge 1 commit intoOCA:18.0from
qrtl:18.0-add-report_positioned_image

Conversation

@kanda999
Copy link

@kanda999 kanda999 commented Feb 26, 2026

@qrtl QT6451

@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-report_positioned_image branch from 9cdb5c7 to 008cb16 Compare March 4, 2026 03:59
Comment on lines +11 to +20
<script>
var page = window.location.search.match(/[?&]page=(\\d+)/);
if (page && parseInt(page[1]) > 1) {{
var elements = document.getElementsByClassName('{css_class}');
for (var i = 0; i < elements.length; i++) {{
elements[i].style.display = 'none';
}}
}}
</script>
"""
Copy link
Author

Choose a reason for hiding this comment

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

Is it unavoidable to use JS?

@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-report_positioned_image branch 2 times, most recently from 87ba8b0 to c6135ae Compare March 5, 2026 08:42
@kanda999 kanda999 marked this pull request as ready for review March 9, 2026 02:01
@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-report_positioned_image branch from c6135ae to 8749993 Compare March 9, 2026 02:16
@AungKoKoLin1997
Copy link
Contributor

Tests CI is fixed at #1142.

@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-report_positioned_image branch 2 times, most recently from a1d9344 to 7a887ff Compare March 10, 2026 08:08
Copy link
Member

@yostashiro yostashiro left a comment

Choose a reason for hiding this comment

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

Functional test. 'First Page Only' option doesn't seem to be working.

Image Image

# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Report Positioned Image",
"summary": "Add positioned images to PDF reports generated by Odoo.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"summary": "Add positioned images to PDF reports generated by Odoo.",
"summary": "Add positioned images to PDF reports",

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated!

Comment on lines +1 to +3
# Copyright 2026 Quartile
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Copyright 2026 Quartile
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated!

class ResCompany(models.Model):
_inherit = "res.company"

report_positioned_image_ids = fields.Many2many(
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be one2many. It looks inconsistent with how company_id is defined as many2one in report.positioned.image.

Copy link
Contributor

Choose a reason for hiding this comment

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

I intentionally avoid using a One2many field because it can lead to unintended behavior.

For example, when we add a positioned image to an Order/Quotation report for a specific company, that image is also assigned to the company’s report images. As a result, every time we create a positioned image for a specific report, all of those images are added to the company as well.

Then, if we remove the report images from the company, they are also unlinked from the specific report, which is not the intended behavior.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, we may add a help text to company_id of the image model to make the intent clear.

class IrActionsReport(models.Model):
_inherit = "ir.actions.report"

include_company_report_image = fields.Boolean(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
include_company_report_image = fields.Boolean(
include_company_images = fields.Boolean(

Copy link
Contributor

@AungKoKoLin1997 AungKoKoLin1997 Mar 12, 2026

Choose a reason for hiding this comment

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

I wanted to include report to make the purpose clearer, but I think include_company_images is already enough. So I updated it.

@@ -0,0 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_report_positioned_image_portal,report.positioned.image portal,model_report_positioned_image,base.group_portal,1,0,0,0
Copy link
Member

Choose a reason for hiding this comment

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

This one doesn't look necessary. Please confirm.

Suggested change
access_report_positioned_image_portal,report.positioned.image portal,model_report_positioned_image,base.group_portal,1,0,0,0
access_report_positioned_image_portal,report.positioned.image

Copy link
Contributor

Choose a reason for hiding this comment

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

I initially thought that portal users would need access to the model.
After verifying the behavior, I confirmed that this is not necessary because _show_report in the portal runs with sudo().

@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-report_positioned_image branch from 7a887ff to 0b84ccf Compare March 12, 2026 08:55
@AungKoKoLin1997
Copy link
Contributor

'First Page Only' option doesn't seem to be working.

@yostashiro For some reason, my latest code changes are not reflected in this PR.

In my update, I added report_qweb_element_page_visibility as a dependency to improve the usability of the first-page feature.

first_page_only = fields.Boolean()
company_id = fields.Many2one(
comodel_name="res.company",
required=True,
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove this required=True? I think it will allow more flexible use of the images. We should also add a record rule for this model.

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.

3 participants