From 873c4aa2e34ae08edd7ace79f7cef445fae71398 Mon Sep 17 00:00:00 2001 From: Felipe Garcia Suez Date: Thu, 1 Aug 2024 18:39:03 +0000 Subject: [PATCH] [ADD] account_ux: added l10n_ar_ux report closes ingadhoc/account-financial-tools#541 Related: ingadhoc/odoo-argentina#880 Signed-off-by: rov-adhoc --- account_ux/README.rst | 1 + account_ux/__init__.py | 1 + account_ux/__manifest__.py | 3 +- account_ux/reports/__init__.py | 5 ++ .../reports/account_invoice_report_view.xml | 58 +++++++++++++++++++ account_ux/reports/invoice_report.py | 43 ++++++++++++++ 6 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 account_ux/reports/__init__.py create mode 100644 account_ux/reports/account_invoice_report_view.xml create mode 100644 account_ux/reports/invoice_report.py diff --git a/account_ux/README.rst b/account_ux/README.rst index 3827880ba..2a691e070 100644 --- a/account_ux/README.rst +++ b/account_ux/README.rst @@ -47,6 +47,7 @@ Several Improvements to accounting: #. Make Debit Note Origin field visible and editable by the user in the account.move form view. This will help to link new debit notes with the original invoice when this ones were not created from invoices "Add Debit Note" action button directly. #. Add field 'ref' in view_account_payment_tree. #. On payments, fix the use case where a journal is only suitable for one kind of operation (lets said inbound) and it is selected but then the user selects "outbound" type. Without this fix, the journals remains selected +#. Upgraded Invoice Analysis report, tree view added and new fields Installation ============ diff --git a/account_ux/__init__.py b/account_ux/__init__.py index 6c1e1357a..7f567bf8b 100644 --- a/account_ux/__init__.py +++ b/account_ux/__init__.py @@ -2,5 +2,6 @@ # For copyright and license notices, see __manifest__.py file in module root # directory ############################################################################## +from . import reports from . import models from . import wizards diff --git a/account_ux/__manifest__.py b/account_ux/__manifest__.py index 5c75bb413..ddaf8bb76 100644 --- a/account_ux/__manifest__.py +++ b/account_ux/__manifest__.py @@ -19,7 +19,7 @@ ############################################################################## { 'name': 'Account UX', - 'version': "17.0.1.9.0", + 'version': "17.0.2.0.0", 'category': 'Accounting', 'sequence': 14, 'summary': '', @@ -46,6 +46,7 @@ 'views/account_account_views.xml', 'views/account_move_views.xml', 'views/account_payment_views.xml', + 'reports/account_invoice_report_view.xml', ], 'demo': [ ], diff --git a/account_ux/reports/__init__.py b/account_ux/reports/__init__.py new file mode 100644 index 000000000..d0f0eb015 --- /dev/null +++ b/account_ux/reports/__init__.py @@ -0,0 +1,5 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from . import invoice_report diff --git a/account_ux/reports/account_invoice_report_view.xml b/account_ux/reports/account_invoice_report_view.xml new file mode 100644 index 000000000..24b22e9e1 --- /dev/null +++ b/account_ux/reports/account_invoice_report_view.xml @@ -0,0 +1,58 @@ + + + + + account.invoice.report.tree + account.invoice.report + + + + state == 'draft' + state == 'cancel' + + + + + + + + + + + + + + + + + + account.invoice.report.search + account.invoice.report + + + + + + + + + + + account.invoice.report.pivot + account.invoice.report + + + + + + + + + + account.invoice.report + tree,graph,pivot + {'search_default_current':1} + + + + diff --git a/account_ux/reports/invoice_report.py b/account_ux/reports/invoice_report.py new file mode 100644 index 000000000..1befc37d2 --- /dev/null +++ b/account_ux/reports/invoice_report.py @@ -0,0 +1,43 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo import models, fields + + +class AccountInvoiceReport(models.Model): + + _inherit = 'account.invoice.report' + + # agregamos widgets monetary, referencia a company currency en string y help + price_subtotal = fields.Monetary( + currency_field='company_currency_id', string="Untaxed Total (CC)", help="Untaxed Total in company currency") + price_total = fields.Monetary(string='Total', currency_field='invoice_currency_id') + price_average = fields.Monetary( + currency_field='company_currency_id', string='Average Price (CC)', help="Average Price in company currency") + # creamos nuevos campos para tener descuentos, vinculos e importes en moneda de compañía + total_cc = fields.Monetary( + string='Total (CC)', readonly=True, help="Untaxed Total in company currency", + currency_field='company_currency_id') + invoice_currency_id = fields.Many2one('res.currency', string='Invoice Currency', readonly=True) + line_id = fields.Many2one('account.move.line', string='Journal Item', readonly=True) + price_subtotal_ic = fields.Monetary('Untaxed Total', readonly=True, currency_field='invoice_currency_id',) + price_unit = fields.Monetary('Unit Price', readonly=True, currency_field='invoice_currency_id',) + discount = fields.Float('Discount (%)', readonly=True) + discount_amount = fields.Monetary( + 'Discount Amount', readonly=True, group_operator="sum", currency_field='invoice_currency_id',) + + _depends = {'account.move.line': ['price_unit', 'discount']} + + def _select(self): + return super()._select() + """, + line.price_unit, + line.id as line_id, + move.currency_id as invoice_currency_id, + line.discount, + line.price_unit * line.quantity * line.discount/100 * + (CASE WHEN move + .move_type IN ('in_refund','out_refund','in_receipt') THEN -1 ELSE 1 END) as discount_amount, + -line.balance * (line.price_total / NULLIF(line.price_subtotal, 0.0)) AS total_cc, + line.price_subtotal * (CASE WHEN move.move_type IN ('in_refund', 'out_invoice') THEN 1 ELSE -1 END) as price_subtotal_ic + """ + + def _group_by(self): + return super()._group_by() + ", move.invoice_currency_id"