Skip to content

Commit

Permalink
[ADD] account_ux: added l10n_ar_ux report
Browse files Browse the repository at this point in the history
closes #541

Related: ingadhoc/odoo-argentina#880
Signed-off-by: rov-adhoc <[email protected]>
  • Loading branch information
feg-adhoc committed Aug 23, 2024
1 parent 4595adb commit 873c4aa
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 1 deletion.
1 change: 1 addition & 0 deletions account_ux/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
============
Expand Down
1 change: 1 addition & 0 deletions account_ux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion account_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Account UX',
'version': "17.0.1.9.0",
'version': "17.0.2.0.0",
'category': 'Accounting',
'sequence': 14,
'summary': '',
Expand All @@ -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': [
],
Expand Down
5 changes: 5 additions & 0 deletions account_ux/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import invoice_report
58 changes: 58 additions & 0 deletions account_ux/reports/account_invoice_report_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_account_invoice_line_report_tree" model="ir.ui.view">
<field name="name">account.invoice.report.tree</field>
<field name="model">account.invoice.report</field>
<field name="inherit_id" ref="account.account_invoice_report_view_tree"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="decoration-info">state == 'draft'</attribute>
<attribute name="decoration-muted">state == 'cancel'</attribute>
</xpath>
<field name="quantity" position="after">
<field name="price_unit"/>
<field name="discount" groups="product.group_discount_per_so_line"/>
<field name="discount_amount" sum="Total" optional="hide" groups="product.group_discount_per_so_line"/>
<field name="price_subtotal_ic" sum="Total" optional="hide"/>
</field>
<field name="price_total" position="after">
<field name="price_subtotal" position="move"/>
<field name="total_cc" sum="Total"/>
<field name="invoice_currency_id" optional="hide"/>
<field name="company_currency_id" column_invisible="True"/>
</field>
</field>
</record>

<record id="view_account_invoice_report_search" model="ir.ui.view">
<field name="name">account.invoice.report.search</field>
<field name="model">account.invoice.report</field>
<field name="inherit_id" ref="account.view_account_invoice_report_search"/>
<field name="arch" type="xml">
<filter name='user' position="after">
<filter string="Journal Entry" name="groupby_move_id" context="{'group_by':'move_id'}"/>
<filter string="Invoice Currency" name="groupby_invoice_currency_id" context="{'group_by':'invoice_currency_id'}"/>
</filter>
</field>
</record>

<record id="view_account_invoice_report_pivot" model="ir.ui.view">
<field name="name">account.invoice.report.pivot</field>
<field name="model">account.invoice.report</field>
<field name="inherit_id" ref="account.view_account_invoice_report_pivot"/>
<field name="arch" type="xml">
<pivot position="attributes">
<attribute name="disable_linking"></attribute>
</pivot>
</field>
</record>

<record id="account.action_account_invoice_report_all" model="ir.actions.act_window">
<field name="res_model">account.invoice.report</field>
<field name="view_mode">tree,graph,pivot</field>
<field name="context">{'search_default_current':1}</field>
<field name="search_view_id" ref="account.view_account_invoice_report_search"/>
</record>

</odoo>
43 changes: 43 additions & 0 deletions account_ux/reports/invoice_report.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 873c4aa

Please sign in to comment.