Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions account_ux/models/account_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
class AccountAccount(models.Model):
_inherit = "account.account"

is_monetary = fields.Boolean(default=True)
is_monetary = fields.Boolean(
store=True,
compute="_compute_is_monetary",
readonly=False,
)

@api.model
def set_non_monetary(self, company):
@api.depends("account_type")
def _compute_is_monetary(self):
"""Set is_monetary in False to the corresponding accounts taking into account the account type"""
account_types = [
"asset_non_current",
Expand All @@ -26,8 +30,8 @@ def set_non_monetary(self, company):
"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))
for rec in self:
if rec.account_type in account_types:
rec.is_monetary = False
else:
rec.is_monetary = True
10 changes: 0 additions & 10 deletions account_ux/models/account_chart_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
class AccountChartTemplate(models.AbstractModel):
_inherit = "account.chart.template"

def _load(self, template_code, company, install_demo, force_create=True):
res = super()._load(template_code, company, install_demo, force_create)
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