diff --git a/account_currency_reports_ux/__init__.py b/account_currency_reports_ux/__init__.py index abbf32ce..ff2e85b0 100644 --- a/account_currency_reports_ux/__init__.py +++ b/account_currency_reports_ux/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import report +from . import hooks +from . import monkey_patches diff --git a/account_currency_reports_ux/__manifest__.py b/account_currency_reports_ux/__manifest__.py index 23fe6295..14d7b0f5 100644 --- a/account_currency_reports_ux/__manifest__.py +++ b/account_currency_reports_ux/__manifest__.py @@ -40,4 +40,6 @@ 'installable': True, 'auto_install': False, 'application': False, + 'post_load': 'monkey_patches', + 'uninstall_hook': 'uninstall_hook' } diff --git a/account_currency_reports_ux/hooks.py b/account_currency_reports_ux/hooks.py new file mode 100644 index 00000000..e72478f2 --- /dev/null +++ b/account_currency_reports_ux/hooks.py @@ -0,0 +1,17 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from odoo.addons.account.report.account_invoice_report import AccountInvoiceReport + +def _revert_method(cls, name): + """ Revert the original method called ``name`` in the given class. + See :meth:`~._patch_method`. + """ + method = getattr(cls, name) + setattr(cls, name, method.origin) + + +def uninstall_hook(cr, registry): + _revert_method(AccountInvoiceReport, '_select') + _revert_method(AccountInvoiceReport, '_from') diff --git a/account_currency_reports_ux/report/account_invoice_report.py b/account_currency_reports_ux/monkey_patches.py similarity index 95% rename from account_currency_reports_ux/report/account_invoice_report.py rename to account_currency_reports_ux/monkey_patches.py index 24d25659..7b217fbd 100644 --- a/account_currency_reports_ux/report/account_invoice_report.py +++ b/account_currency_reports_ux/monkey_patches.py @@ -1,8 +1,9 @@ from odoo import models, api +from odoo.addons.account.report.account_invoice_report import AccountInvoiceReport -class AccountInvoiceReport(models.Model): - _inherit = "account.invoice.report" +def monkey_patches(): + # monkey patch @api.model def _select(self): return ''' @@ -84,3 +85,6 @@ def _from(self): (currency_table.date_end IS NULL OR currency_table.date_end > COALESCE(line.date, NOW()))) LEFT JOIN res_company rc on rc.id=line.company_id ''' + + AccountInvoiceReport._select = _select + AccountInvoiceReport._from = _from diff --git a/account_currency_reports_ux/report/__init__.py b/account_currency_reports_ux/report/__init__.py deleted file mode 100644 index a04d063d..00000000 --- a/account_currency_reports_ux/report/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from . import account_invoice_report