-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
@@ -0,0 +1,13 @@ | |||
# Copyright 2024 Quartile Limited |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"author": "Quartile Limited", | |
"author": "Quartile", |
help="This report will be used as a template in the customer portal " | ||
"view of the invoice.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.", |
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. |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
hls-custom/account_invoice_report_hls/report/report_invoice_delivery_templates.xml
Lines 41 to 42 in a41b81f
<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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 " |
70ccfe5
to
795c9e6
Compare
There was a problem hiding this 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.
invoice_report = request.env.user.company_id.customer_invoice_portal_report | ||
if ( | ||
model._name == "account.invoice" | ||
and invoice_report | ||
and model.type == "out_invoice" | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For early returns.
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: |
4332