Skip to content

Commit

Permalink
[MIG] mis_builder: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chaule97 committed Dec 2, 2024
1 parent b98b2da commit 06d4272
Show file tree
Hide file tree
Showing 35 changed files with 451 additions and 426 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^mis_builder/|
^mis_builder_budget/|
^mis_builder_demo/|
# END NOT INSTALLABLE ADDONS
Expand Down
17 changes: 12 additions & 5 deletions mis_builder/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ MIS Builder
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmis--builder-lightgray.png?logo=github
:target: https://github.com/OCA/mis-builder/tree/17.0/mis_builder
:target: https://github.com/OCA/mis-builder/tree/18.0/mis_builder
:alt: OCA/mis-builder
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/mis-builder-17-0/mis-builder-17-0-mis_builder
:target: https://translation.odoo-community.org/projects/mis-builder-18-0/mis-builder-18-0-mis_builder
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/mis-builder&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/mis-builder&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -698,7 +698,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/mis-builder/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/mis-builder/issues/new?body=module:%20mis_builder%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/mis-builder/issues/new?body=module:%20mis_builder%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -742,6 +742,13 @@ Contributors
- Hoang Diep <[email protected]>
- Miquel Pascual <[email protected]>
- Antoni Marroig <[email protected]>
- Chau Le <[email protected]>

Other credits
-------------

The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------
Expand All @@ -764,6 +771,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sbidoul|

This module is part of the `OCA/mis-builder <https://github.com/OCA/mis-builder/tree/17.0/mis_builder>`_ project on GitHub.
This module is part of the `OCA/mis-builder <https://github.com/OCA/mis-builder/tree/18.0/mis_builder>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
8 changes: 4 additions & 4 deletions mis_builder/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "MIS Builder",
"version": "17.0.1.0.4",
"version": "18.0.1.0.0",
"category": "Reporting",
"summary": """
Build 'Management Information System' Reports and Dashboards
Expand Down Expand Up @@ -31,14 +31,14 @@
"web.assets_backend": [
"mis_builder/static/src/components/mis_report_widget.esm.js",
"mis_builder/static/src/components/mis_report_widget.xml",
"mis_builder/static/src/components/mis_report_widget.css",
"mis_builder/static/src/components/mis_report_widget.scss",
],
"web.report_assets_common": [
"/mis_builder/static/src/css/report.css",
"mis_builder/static/src/scss/report.scss",
],
},
"qweb": ["static/src/xml/mis_report_widget.xml"],
"installable": False,
"installable": True,
"application": True,
"license": "AGPL-3",
"development_status": "Production/Stable",
Expand Down
4 changes: 1 addition & 3 deletions mis_builder/datas/ir_cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
<field name="name">Vacuum temporary reports</field>
<field name="interval_number">4</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
<field ref="model_mis_report_instance" name="model_id" />
<field name="model_id" ref="model_mis_report_instance" />
<field name="code">model._vacuum_report()</field>
<field name="active" eval="True" />
</record>
Expand Down
27 changes: 18 additions & 9 deletions mis_builder/models/aep.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
from collections import defaultdict

from odoo import _, fields
from odoo import fields
from odoo.exceptions import UserError
from odoo.models import expression
from odoo.tools.float_utils import float_is_zero
Expand Down Expand Up @@ -92,7 +92,7 @@ def __init__(self, companies, currency=None, account_model="account.account"):
self.currency = companies.mapped("currency_id")
if len(self.currency) > 1:
raise UserError(
_(
self.env._(
"If currency_id is not provided, "
"all companies must have the same currency."
)
Expand Down Expand Up @@ -192,11 +192,20 @@ def done_parsing(self):
all_account_ids = set()
for acc_domain in acc_domains:
acc_domain_with_company = expression.AND(
[acc_domain, [("company_id", "in", self.companies.ids)]]
[acc_domain, [("company_ids", "in", self.companies.ids)]]
)
account_ids = self._account_model.search(acc_domain_with_company).ids
# TODO we only search account by code with only one company
# we need to optimize it
account_ids = []
for company in self.companies:
account_ids += (
self._account_model.with_company(company)
.search(acc_domain_with_company)
.ids
)
self._account_ids_by_acc_domain[acc_domain].update(account_ids)
all_account_ids.update(account_ids)

self._map_account_ids[key] = list(all_account_ids)

@classmethod
Expand Down Expand Up @@ -341,21 +350,21 @@ def do_queries(
# fetch sum of debit/credit, grouped by account_id
_logger.debug("read_group domain: %s", domain)
try:
accs = aml_model.read_group(
accs = aml_model.with_context(
allowed_company_ids=self.companies.ids
).read_group(
domain,
["debit", "credit", "account_id", "company_id"],
["account_id", "company_id"],
lazy=False,
)
except ValueError as e:
raise UserError(
_(
self.env._(
'Error while querying move line source "%(model_name)s". '
"This is likely due to a filter or expression referencing "
"a field that does not exist in the model.\n\n"
"The technical error message is: %(exception)s. "
)
% dict(
"The technical error message is: %(exception)s. ",
model_name=aml_model._description,
exception=e,
)
Expand Down
19 changes: 9 additions & 10 deletions mis_builder/models/kpimatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging
from collections import OrderedDict, defaultdict

from odoo import _
from odoo.exceptions import UserError

from .accounting_none import AccountingNone
Expand Down Expand Up @@ -245,10 +244,9 @@ def set_values_detail_account(
self.lang, row.style_props, kpi.type, val
)
if row.kpi.multi and subcol.subkpi:
val_comment = "{}.{} = {}".format(
row.kpi.name,
subcol.subkpi.name,
row.kpi._get_expression_str_for_subkpi(subcol.subkpi),
val_comment = (
f"{row.kpi.name}.{subcol.subkpi.name} = "
f"{row.kpi._get_expression_str_for_subkpi(subcol.subkpi)}"
)
else:
val_comment = f"{row.kpi.name} = {row.kpi.expression}"
Expand Down Expand Up @@ -309,7 +307,7 @@ def compute_comparisons(self):
common_subkpis = self._common_subkpis([col, base_col])
if (col.subkpis or base_col.subkpis) and not common_subkpis:
raise UserError(
_(
self.env._(
"Columns %(descr)s and %(base_descr)s are not comparable",
descr=col.description,
base_descr=base_col.description,
Expand Down Expand Up @@ -395,11 +393,12 @@ def compute_sums(self):
common_subkpis = self._common_subkpis(sumcols)
if any(c.subkpis for c in sumcols) and not common_subkpis:
raise UserError(
_(
"Sum cannot be computed in column {} "
self.env._(
"Sum cannot be computed in column %s "
"because the columns to sum have no "
"common subkpis"
).format(label)
"common subkpis",
label,
)
)
sum_col = KpiMatrixCol(
sumcol_key,
Expand Down
12 changes: 5 additions & 7 deletions mis_builder/models/mis_kpi_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from collections import defaultdict

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.osv import expression

Expand Down Expand Up @@ -60,11 +60,9 @@ def _compute_name(self):
subkpi_name = "." + subkpi_name
else:
subkpi_name = ""
rec.name = "{}{}: {} - {}".format(
rec.kpi_expression_id.kpi_id.name,
subkpi_name,
rec.date_from,
rec.date_to,
rec.name = (
f"{rec.kpi_expression_id.kpi_id.name}{subkpi_name}: "
f"{rec.date_from} - {rec.date_to}"
)

@api.model
Expand Down Expand Up @@ -99,7 +97,7 @@ def _query_kpi_data(self, date_from, date_to, base_domain):
res_avg[item.kpi_expression_id].append((i_days, item.amount))
else:
raise UserError(
_(
self.env._(
"Unexpected accumulation method %(method)s for %(name)s.",
method=item.kpi_expression_id.kpi_id.accumulation_method,
name=item.name,
Expand Down
Loading

0 comments on commit 06d4272

Please sign in to comment.