Skip to content

Commit

Permalink
[ADD] account_ux: Moved from l10n_ar_ux and account_reports_multicurr…
Browse files Browse the repository at this point in the history
…ency is_monetary logic
  • Loading branch information
feg-adhoc committed Feb 27, 2025
1 parent 31613f3 commit 64fb61b
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
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": "18.0.1.10.0",
"version": "18.0.1.11.0",
"category": "Accounting",
"sequence": 14,
"summary": "",
Expand All @@ -39,6 +39,7 @@
"wizards/account_change_currency_views.xml",
"wizards/account_move_change_rate_views.xml",
"wizards/res_config_settings_views.xml",
"views/account_account_views.xml",
"views/account_journal_views.xml",
"views/account_move_line_views.xml",
"views/account_reconcile_views.xml",
Expand Down
3 changes: 2 additions & 1 deletion account_ux/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
# directory
##############################################################################

from . import account_account
from . import account_group
from . import account_journal
from . import account_move_line
from . import res_company
from . import res_currency_rate
from . import account_move
from . import chart_template
from . import account_chart_template
from . import account_payment
33 changes: 33 additions & 0 deletions account_ux/models/account_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import logging

from odoo import api, models, fields

_logger = logging.getLogger(__name__)


class AccountAccount(models.Model):
_inherit = "account.account"

is_monetary = fields.Boolean(default=True)

@api.model
def set_non_monetary(self, company):
"""Set is_monetary in False to the corresponding accounts taking into account the account type"""
account_types = [
"asset_non_current",
"asset_fixed",
"liability_non_current",
"equity",
"equity_unaffected",
"income",
"income_other",
"expense",
"expense_depreciation",
"expense_direct_cost",
"off_balance"
]
if accounts := self.search(
[("account_type", "in", account_types), *self.env["account.account"]._check_company_domain(company)]
).filtered(lambda x: x.company_fiscal_country_code == "AR"):
accounts.write({"is_monetary": False})
_logger.info("Is Monetary is False on %s accounts ." % (company.name))
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ def _load(self, template_code, company, install_demo):
res = super()._load(template_code, company, install_demo)
return res

def _load_data(self, data, ignore_duplicates=False):
res = super()._load_data(data, ignore_duplicates=ignore_duplicates)
if res.get("res.company"):
self.env["account.account"].set_non_monetary(res["res.company"])
return res

def _post_load_data(self, template_code, company, template_data):
super()._post_load_data(template_code, company, template_data)

Expand Down
13 changes: 13 additions & 0 deletions account_ux/views/account_account_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="account_ux_view_list" model="ir.ui.view">
<field name="name">account.account.tds.tcs.view.list.inherit</field>
<field name="model">account.account</field>
<field name="inherit_id" ref="account.view_account_list"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='account_type']" position="after">
<field name="is_monetary" optional="hide"/>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 64fb61b

Please sign in to comment.