-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
350 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
==================== | ||
Report Aeroo Invoice | ||
==================== | ||
This module allows printing a customer invoice using Aeroo reports. | ||
|
||
It defines an aeroo template as the main template for printing invoices. | ||
|
||
Print Button On Invoice Form | ||
---------------------------- | ||
The `Print` button on the customer invoice form allows to print the qweb invoice. | ||
|
||
This module changes the behavior of the button to print an aeroo report instead. | ||
|
||
Download Button On Portal | ||
------------------------- | ||
The dowload link on the portal is hardcoded to print a qweb report. | ||
|
||
This module changes the behavior of the button to print an aeroo report instead. | ||
|
||
Configuration | ||
------------- | ||
To set the main Aeroo invoice template: | ||
|
||
* Go to `Accounting / Configuration / Configuration`. | ||
* In the `Invoices` section, select the template in the field `Customer Invoice Aeroo Template`. | ||
|
||
Contributors | ||
------------ | ||
* Numigi (tm) and all its contributors (https://bit.ly/numigiens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import controllers | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Report Aeroo Invoice", | ||
"version": "16.0.1.0.0", | ||
"category": "Generic Modules/Aeroo Reports", | ||
"summary": "Allow Printing an Aeroo Invoice", | ||
"author": "Numigi", | ||
"maintainer": "Numigi", | ||
"website": "https://bit.ly/numigi-com", | ||
"depends": [ | ||
"account", | ||
"report_aeroo", | ||
], | ||
"data": [ | ||
"views/res_config_settings.xml", | ||
"views/portal.xml", | ||
], | ||
'web.assets_frontend': [ | ||
'report_aeroo_invoice/static/src/js/portal.js', | ||
], | ||
"demo": [ | ||
"demo/invoice.xml", | ||
], | ||
"license": "LGPL-3", | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import portal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/gpl). | ||
|
||
from odoo import http | ||
from odoo.addons.account.controllers.portal import PortalAccount | ||
from odoo.exceptions import AccessError, MissingError | ||
from odoo.http import request | ||
|
||
AEROO_INVOICE_REPORT_REF = "report_aeroo_invoice.aeroo_invoice_report" | ||
|
||
|
||
class PortalAccountWithAerooInvoiceReport(PortalAccount): | ||
|
||
@http.route( | ||
["/my/invoices/<int:invoice_id>"], type="http", auth="public", website=True | ||
) | ||
def portal_my_invoice_detail( | ||
self, invoice_id, access_token=None, report_type=None, download=False, **kw | ||
): | ||
template = request.env.ref(AEROO_INVOICE_REPORT_REF, raise_if_not_found=False) | ||
|
||
if not template or report_type != "pdf": | ||
return super().portal_my_invoice_detail( | ||
invoice_id, | ||
access_token=access_token, | ||
report_type=report_type, | ||
download=download, | ||
**kw | ||
) | ||
|
||
try: | ||
invoice = self._document_check_access( | ||
"account.move", invoice_id, access_token | ||
) | ||
except (AccessError, MissingError): | ||
return request.redirect("/my") | ||
|
||
return self._show_aeroo_report( | ||
record=invoice, template=template, download=download | ||
) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0"?> | ||
<odoo noupdate="1"> | ||
|
||
<record id="aeroo_invoice_report" model="ir.actions.report"> | ||
<field name="name">Aeroo Invoice Report</field> | ||
<field name="type">ir.actions.report</field> | ||
<field name="model">account.move</field> | ||
<field name="report_name">aeroo_invoice_report</field> | ||
<field name="report_type">aeroo</field> | ||
<field name="aeroo_in_format">odt</field> | ||
<field name="aeroo_out_format_id" ref="report_aeroo.aeroo_mimetype_pdf_odt" /> | ||
<field name="aeroo_template_source">file</field> | ||
<field name="aeroo_lang_eval">o.partner_id.lang</field> | ||
<field name="aeroo_country_eval">o.partner_id.country_id</field> | ||
<field name="aeroo_template_path">report_aeroo_invoice/demo/invoice.odt</field> | ||
<field name="attachment_use" eval="True" /> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * report_aeroo_invoice | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-11-08 08:05+0000\n" | ||
"PO-Revision-Date: 2024-11-08 08:05+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: report_aeroo_invoice | ||
#: model:ir.actions.report,name:report_aeroo_invoice.aeroo_invoice_report | ||
#: model:ir.model.fields,field_description:report_aeroo_invoice.field_res_config_settings__aeroo_invoice_template_id | ||
msgid "Aeroo Invoice Report" | ||
msgstr "Rapport de facture Aeroo" | ||
|
||
#. module: report_aeroo_invoice | ||
#: model_terms:ir.ui.view,arch_db:report_aeroo_invoice.res_config_settings_form_with_aeroo_invoice_template | ||
msgid "Aeroo Invoice Template" | ||
msgstr "Modèle de facture Aeroo" | ||
|
||
#. module: report_aeroo_invoice | ||
#: model:ir.model,name:report_aeroo_invoice.model_res_config_settings | ||
msgid "Config Settings" | ||
msgstr "Paramètres de configuration" | ||
|
||
#. module: report_aeroo_invoice | ||
#: model:ir.model,name:report_aeroo_invoice.model_account_move | ||
msgid "Journal Entry" | ||
msgstr "Pièce comptable" | ||
|
||
#. module: report_aeroo_invoice | ||
#: model_terms:ir.ui.view,arch_db:report_aeroo_invoice.res_config_settings_form_with_aeroo_invoice_template | ||
msgid "Main report template used for generating customer invoices." | ||
msgstr "" | ||
"Modèle de rapport principal utilisé pour générer les factures clients." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/gpl). | ||
|
||
from . import account_move | ||
from . import res_config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/gpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class AccountMove(models.Model): | ||
|
||
_inherit = "account.move" | ||
|
||
def action_invoice_print(self): | ||
"""Print the invoice using the aeroo invoice template if it is defined. | ||
If the aeroo invoice report is not setup, fallback to the qweb template. | ||
""" | ||
report = self.env.ref( | ||
"report_aeroo_invoice.aeroo_invoice_report", raise_if_not_found=False | ||
) | ||
if report: | ||
return report.report_action(self) | ||
else: | ||
return super().invoice_print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/gpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ResConfigSettingsWithAerooInvoiceTemplate(models.TransientModel): | ||
|
||
_inherit = "res.config.settings" | ||
|
||
aeroo_invoice_template_id = fields.Many2one( | ||
"ir.actions.report", | ||
"Aeroo Invoice Report", | ||
domain="[('report_type', '=', 'aeroo'), ('model', '=', 'account.move')]", | ||
) | ||
|
||
@api.model | ||
def get_values(self): | ||
res = super().get_values() | ||
template = self.env.ref( | ||
"report_aeroo_invoice.aeroo_invoice_report", raise_if_not_found=False | ||
) | ||
res["aeroo_invoice_template_id"] = template.id if template else False | ||
return res | ||
|
||
@api.model | ||
def set_values(self): | ||
super().set_values() | ||
if self.aeroo_invoice_template_id: | ||
self._update_aeroo_invoice_template() | ||
else: | ||
self._empty_aeroo_invoice_template() | ||
|
||
def _update_aeroo_invoice_template(self): | ||
ref = self.env["ir.model.data"].search( | ||
[ | ||
("module", "=", "report_aeroo_invoice"), | ||
("name", "=", "aeroo_invoice_report"), | ||
], | ||
limit=1, | ||
) | ||
|
||
if ref: | ||
ref.res_id = self.aeroo_invoice_template_id.id | ||
else: | ||
self.env["ir.model.data"].create( | ||
{ | ||
"module": "report_aeroo_invoice", | ||
"name": "aeroo_invoice_report", | ||
"model": "ir.actions.report", | ||
"res_id": self.aeroo_invoice_template_id.id, | ||
"noupdate": True, | ||
} | ||
) | ||
|
||
def _empty_aeroo_invoice_template(self): | ||
self.env["ir.model.data"].search( | ||
[ | ||
("module", "=", "report_aeroo_invoice"), | ||
("name", "=", "aeroo_invoice_report"), | ||
] | ||
).unlink() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component, useRef } from '@odoo/owl'; | ||
import { registerPublicWidget } from 'web.public.widget'; | ||
import { PortalSidebar } from 'portal.PortalSidebar'; | ||
|
||
class AccountPortalSidebar extends PortalSidebar { | ||
setup() { | ||
super.setup(); | ||
this.sidebarRef = useRef("sidebar"); | ||
} | ||
} | ||
|
||
|
||
registerPublicWidget({ | ||
selector: '.o_portal_invoice_sidebar', | ||
Component: AccountPortalSidebar, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/gpl). | ||
|
||
from . import test_res_config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/gpl). | ||
|
||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestResConfigSettingsWithAerooReport(TransactionCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.wizard = cls.env["res.config.settings"].create({}) | ||
cls.wizard.get_values() | ||
cls.report = cls.env.ref("report_aeroo_invoice.aeroo_invoice_report") | ||
|
||
def test_empty_aeroo_invoice_template_id(self): | ||
self.assertEqual(self.wizard.aeroo_invoice_template_id, self.report) | ||
self.wizard.aeroo_invoice_template_id = None | ||
self.wizard.execute() | ||
self.wizard = self.env["res.config.settings"].create({}) | ||
self.assertFalse(self.wizard.aeroo_invoice_template_id) | ||
|
||
def test_change_aeroo_invoice_template_id(self): | ||
self.assertEqual(self.wizard.aeroo_invoice_template_id, self.report) | ||
report_copy = self.report.copy({"report_name": "new_aeroo_invoice_report"}) | ||
self.wizard.aeroo_invoice_template_id = report_copy | ||
self.wizard.execute() | ||
self.assertEqual(self.wizard.aeroo_invoice_template_id, report_copy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
|
||
<template id="portal_invoice_page" name="Portal Invoice With PDF Report" inherit_id="account.portal_invoice_page"> | ||
<xpath expr="//iframe" position="replace"> | ||
<object | ||
t-att-data="invoice.get_portal_url(report_type='pdf', anchor='toolbar=0')" type="application/pdf" | ||
width="100%" height="100%" | ||
style="min-height: 800px" | ||
/> | ||
</xpath> | ||
<xpath expr="//div[hasclass('o_portal_html_loader')]" position="replace" /> | ||
</template> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
|
||
<record id="res_config_settings_form_with_aeroo_invoice_template" model="ir.ui.view"> | ||
<field name="name">Account Config With Aeroo Invoice Template</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="account.res_config_settings_view_form" /> | ||
<field name="arch" type="xml"> | ||
<div id="invoicing_settings" position="inside"> | ||
<div class="col-xs-12 col-md-6 o_setting_box"> | ||
<div class="o_setting_left_pane" /> | ||
<div class="o_setting_right_pane"> | ||
<label string="Aeroo Invoice Template" for="aeroo_invoice_template_id" /> | ||
<div class="text-muted"> | ||
Main report template used for generating customer invoices. | ||
</div> | ||
<div class="content-group"> | ||
<field name="aeroo_invoice_template_id" options="{'no_create': True}" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</field> | ||
</record> | ||
|
||
</odoo> |