Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4332][ADD] account_invoice_custom_portal_report #224

Merged
merged 4 commits into from
Jun 24, 2024

Conversation

AungKoKoLin1997
Copy link
Contributor

@@ -0,0 +1,13 @@
# Copyright 2024 Quartile Limited
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 2024 Quartile Limited
# Copyright 2024 Quartile (https://www.quartile.co)

"version": "12.0.1.0.0",
"category": "Portal",
"license": "AGPL-3",
"author": "Quartile Limited",
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
"author": "Quartile Limited",
"author": "Quartile",

Comment on lines 12 to 13
help="This report will be used as a template in the customer portal "
"view of the invoice.",
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
help="This report will be used as a template in the customer portal "
"view of the invoice.",
help="This report template will be used in the customer portal to show the invoice.",

Comment on lines 4 to 9
Background
~~~~~~~~~~

When we create and use a custom report for invoices and send an email to our customers with this custom report,
the customer sees the Odoo standard report template when they open the invoice in their portal view.
This module addresses this issue.
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary? We generally prefer to have a context/reasoning to what we do, but this one looks obvious to me.

class CustomerPortal(CustomerPortal):
def _show_report(self, model, report_type, report_ref, download=False):
invoice_report = request.env.user.company_id.account_invoice_report
if model._name == "account.invoice" and invoice_report:
Copy link
Member

Choose a reason for hiding this comment

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

This should only be done for customer invoices.

@kanda999 Please check which template should show for customer credit notes.

Copy link
Contributor

Choose a reason for hiding this comment

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

@yostashiro
The custom report we want to set up can also display credit note.

<span t-if="o.type == 'in_refund'">Vendor Credit Note</span>
<span t-if="o.type == 'in_invoice'">Vendor Bill</span>

However, the customer may want to view a different report as credit note in the future.

@AungKoKoLin1997
Could you please add the filter for customer invoice?

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

account_invoice_report = fields.Many2one(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that a name like account_invoice_portal_report would be better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should change the name of the field since we are adding a filter.


account_invoice_report = fields.Many2one(
"ir.actions.report",
help="This report will be used as a template in the customer portal "
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
help="This report will be used as a template in the customer portal "
domain="[('model', '=', 'account.invoice')]",
help="This report will be used as a template in the customer portal "

@kanda999 kanda999 force-pushed the 12.0-add-account_invoice_custom_portal_report branch from 70ccfe5 to 795c9e6 Compare June 24, 2024 07:38
Copy link
Contributor

@kanda999 kanda999 left a comment

Choose a reason for hiding this comment

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

Code and Functional review.

Comment on lines 10 to 15
invoice_report = request.env.user.company_id.customer_invoice_portal_report
if (
model._name == "account.invoice"
and invoice_report
and model.type == "out_invoice"
):
Copy link
Member

Choose a reason for hiding this comment

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

For early returns.

Suggested change
invoice_report = request.env.user.company_id.customer_invoice_portal_report
if (
model._name == "account.invoice"
and invoice_report
and model.type == "out_invoice"
):
if not (model._name == "account.invoice" and model.type == "out_invoice"):
return super()._show_report(model, report_type, report_ref, download)
invoice_report = request.env.user.company_id.customer_invoice_portal_report
if invoice_report:

@kanda999 kanda999 merged commit 24b8a8d into 12.0 Jun 24, 2024
2 checks passed
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