Skip to content

Commit 83d0cd5

Browse files
committed
[MIG] mis_builder: Migration to 19.0
1 parent fd504a9 commit 83d0cd5

20 files changed

Lines changed: 168 additions & 204 deletions

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
exclude: |
22
(?x)
33
# NOT INSTALLABLE ADDONS
4-
^mis_builder/|
54
^mis_builder_budget/|
65
^mis_builder_demo/|
76
# END NOT INSTALLABLE ADDONS

mis_builder/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ MIS Builder
2121
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2222
:alt: License: AGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmis--builder-lightgray.png?logo=github
24-
:target: https://github.com/OCA/mis-builder/tree/18.0/mis_builder
24+
:target: https://github.com/OCA/mis-builder/tree/19.0/mis_builder
2525
:alt: OCA/mis-builder
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/mis-builder-18-0/mis-builder-18-0-mis_builder
27+
:target: https://translation.odoo-community.org/projects/mis-builder-19-0/mis-builder-19-0-mis_builder
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/mis-builder&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/mis-builder&target_branch=19.0
3131
:alt: Try me on Runboat
3232

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

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

@@ -790,6 +790,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
790790

791791
|maintainer-sbidoul|
792792

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

795795
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

mis_builder/__manifest__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
{
55
"name": "MIS Builder",
6-
"version": "18.0.1.8.0",
6+
"version": "19.0.1.0.0",
77
"category": "Reporting",
88
"summary": """
99
Build 'Management Information System' Reports and Dashboards
1010
""",
11-
"author": "ACSONE SA/NV, " "Odoo Community Association (OCA)",
11+
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",
1212
"website": "https://github.com/OCA/mis-builder",
1313
"depends": [
1414
"account",
@@ -41,7 +41,7 @@
4141
],
4242
},
4343
"qweb": ["static/src/xml/mis_report_widget.xml"],
44-
"installable": False,
44+
"installable": True,
4545
"application": True,
4646
"license": "AGPL-3",
4747
"development_status": "Production/Stable",

mis_builder/migrations/18.0.1.3.0/post-migration.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

mis_builder/models/aep.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from odoo import fields
99
from odoo.exceptions import UserError
10-
from odoo.models import expression
10+
from odoo.fields import Domain
1111
from odoo.tools.float_utils import float_is_zero
1212
from odoo.tools.safe_eval import datetime, dateutil, safe_eval, time
1313

@@ -184,7 +184,7 @@ def _account_codes_to_domain(self, account_codes):
184184
elems.append([("code", "=like", account_code)])
185185
else:
186186
elems.append([("code", "=", account_code)])
187-
return tuple(expression.OR(elems))
187+
return tuple(Domain.OR(elems))
188188

189189
def _parse_match_object(self, mo):
190190
"""Split a match object corresponding to an accounting variable
@@ -285,7 +285,7 @@ def done_parsing(self):
285285
# separately.
286286
account_ids = []
287287
for company in self.companies:
288-
acc_domain_with_company = expression.AND(
288+
acc_domain_with_company = Domain.AND(
289289
[acc_domain, [("company_ids", "=", company.id)]]
290290
)
291291
account_ids += (
@@ -328,7 +328,7 @@ def get_aml_domain_for_expr(self, expr, date_from, date_to, account_id=None):
328328
account_ids = set()
329329
account_ids.update(self._account_ids_by_acc_domain[acc_domain])
330330
if not account_id:
331-
aml_domain.append(("account_id", "in", tuple(account_ids)))
331+
aml_domain.append(("account_id", "in", list(account_ids)))
332332
else:
333333
# filter on account_id
334334
if account_id in account_ids:
@@ -341,15 +341,17 @@ def get_aml_domain_for_expr(self, expr, date_from, date_to, account_id=None):
341341
aml_domain.append(("debit", "<>", 0.0))
342342
elif fld_name:
343343
aml_domain.append((fld_name, "!=", False))
344-
aml_domains.append(expression.normalize_domain(aml_domain))
344+
aml_domains.append(aml_domain)
345345
if mode not in date_domain_by_mode:
346346
date_domain_by_mode[mode] = self.get_aml_domain_for_dates(
347347
date_from, date_to, mode
348348
)
349349
assert aml_domains
350350
# TODO we could do this for more precision:
351351
# AND(OR(aml_domains[mode]), date_domain[mode]) for each mode
352-
return expression.OR(aml_domains) + expression.OR(date_domain_by_mode.values())
352+
return Domain.AND(
353+
[Domain.OR(aml_domains), Domain.OR(list(date_domain_by_mode.values()))]
354+
)
353355

354356
def get_aml_domain_for_dates(self, date_from, date_to, mode):
355357
if mode == self.MODE_VARIATION:
@@ -384,7 +386,7 @@ def get_aml_domain_for_dates(self, date_from, date_to, mode):
384386
("date", "<", fields.Date.to_string(fy_date_from)),
385387
("account_id.include_initial_balance", "=", False),
386388
]
387-
return expression.normalize_domain(domain)
389+
return Domain(domain)
388390

389391
def _get_company_rates(self, date):
390392
# get exchange rates for each company with its rouding

mis_builder/models/mis_kpi_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from odoo import api, fields, models
77
from odoo.exceptions import UserError
8-
from odoo.osv import expression
8+
from odoo.fields import Domain
99

1010
ACC_SUM = "sum"
1111
ACC_AVG = "avg"
@@ -79,7 +79,7 @@ def _query_kpi_data(self, date_from, date_to, base_domain):
7979
dt_to = fields.Date.from_string(date_to)
8080
# all data items within or overlapping [date_from, date_to]
8181
date_domain = [("date_from", "<=", date_to), ("date_to", ">=", date_from)]
82-
domain = expression.AND([date_domain, base_domain])
82+
domain = Domain(date_domain) & Domain(base_domain)
8383
res = defaultdict(float)
8484
res_avg = defaultdict(list)
8585
for item in self.search(domain):

mis_builder/models/mis_report.py

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from odoo import api, fields, models
1515
from odoo.exceptions import UserError, ValidationError
16+
from odoo.fields import Domain
1617
from odoo.tools.safe_eval import (
1718
datetime as safe_datetime,
1819
)
@@ -292,13 +293,10 @@ class MisReportKpiExpression(models.Model):
292293
# TODO FIXME set readonly=True when onchange('subkpi_ids') below works
293294
subkpi_id = fields.Many2one("mis.report.subkpi", readonly=False, ondelete="cascade")
294295

295-
_sql_constraints = [
296-
(
297-
"subkpi_kpi_unique",
298-
"unique(subkpi_id, kpi_id)",
299-
"Sub KPI must be used once and only once for each KPI",
300-
)
301-
]
296+
_subkpi_kpi_unique = models.Constraint(
297+
"unique(subkpi_id, kpi_id)",
298+
"Sub KPI must be used once and only once for each KPI",
299+
)
302300

303301
@api.depends(
304302
"kpi_id.description",
@@ -324,22 +322,18 @@ def _compute_display_name(self):
324322
def _search_display_name(self, operator, value):
325323
if "." in value:
326324
kpi_name, subkpi_name = value.split(".", 1)
327-
name_search_domain = [
328-
"|",
329-
"|",
330-
"&",
331-
("kpi_id.name", "=", kpi_name),
332-
("subkpi_id.name", operator, subkpi_name),
333-
("kpi_id.description", operator, value),
334-
("subkpi_id.description", operator, value),
335-
]
325+
name_search_domain = (
326+
(
327+
Domain("kpi_id.name", "=", kpi_name)
328+
& Domain("subkpi_id.name", operator, subkpi_name)
329+
)
330+
| Domain("kpi_id.description", operator, value)
331+
| Domain("subkpi_id.description", operator, value)
332+
)
336333
else:
337-
name_search_domain = [
338-
"|",
339-
("kpi_id.name", operator, value),
340-
("kpi_id.description", operator, value),
341-
]
342-
334+
name_search_domain = Domain("kpi_id.name", operator, value) | Domain(
335+
"kpi_id.description", operator, value
336+
)
343337
return name_search_domain
344338

345339

@@ -619,7 +613,7 @@ def _fetch_queries(self, date_from, date_to, get_additional_query_filter=None):
619613
v = data[0][field_name]
620614
except KeyError:
621615
_logger.error(
622-
"field %s not found in read_group " "for %s; not summable?",
616+
"field %s not found in read_group for %s; not summable?",
623617
field_name,
624618
model._name,
625619
)

mis_builder/models/mis_report_instance.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from odoo import api, fields, models
1212
from odoo.exceptions import UserError, ValidationError
13+
from odoo.fields import Domain
1314

1415
from .aep import AccountingExpressionProcessor as AEP
1516
from .expression_evaluator import ExpressionEvaluator
@@ -289,19 +290,20 @@ def _compute_dates(self):
289290

290291
_order = "sequence, id"
291292

292-
_sql_constraints = [
293-
("duration", "CHECK (duration>0)", "Wrong duration, it must be positive!"),
294-
(
295-
"normalize_factor",
296-
"CHECK (normalize_factor>0)",
297-
"Wrong normalize factor, it must be positive!",
298-
),
299-
(
300-
"name_unique",
301-
"unique(name, report_instance_id)",
302-
"Period name should be unique by report",
303-
),
304-
]
293+
_duration = models.Constraint(
294+
"CHECK(duration > 0)",
295+
"Wrong duration, it must be positive!",
296+
)
297+
298+
_normalize_factor = models.Constraint(
299+
"CHECK(normalize_factor > 0)",
300+
"Wrong normalize factor, it must be positive!",
301+
)
302+
303+
_name_unique = models.Constraint(
304+
"unique(name, report_instance_id)",
305+
"Period name should be unique by report",
306+
)
305307

306308
@api.depends("source", "report_instance_id.report_id.move_lines_source")
307309
def _compute_source_aml_model_id(self):
@@ -423,17 +425,15 @@ def _check_mode_source(self):
423425
if rec.mode == MODE_NONE:
424426
raise DateFilterRequired(
425427
self.env._(
426-
"A date filter is mandatory for this source "
427-
"in column %s.",
428+
"A date filter is mandatory for this source in column %s.",
428429
rec.name,
429430
)
430431
)
431432
elif rec.source in (SRC_SUMCOL, SRC_CMPCOL):
432433
if rec.mode != MODE_NONE:
433434
raise DateFilterForbidden(
434435
self.env._(
435-
"No date filter is allowed for this source "
436-
"in column %s.",
436+
"No date filter is allowed for this source in column %s.",
437437
rec.name,
438438
)
439439
)
@@ -460,8 +460,7 @@ def _check_source_cmpcol(self):
460460
):
461461
raise ValidationError(
462462
self.env._(
463-
"Columns to compare must belong to the same report "
464-
"in %s",
463+
"Columns to compare must belong to the same report in %s",
465464
rec.name,
466465
)
467466
)
@@ -499,7 +498,7 @@ def _compute_pivot_date(self):
499498
sequence = fields.Integer(default=10)
500499
description = fields.Char(related="report_id.description")
501500
date = fields.Date(
502-
string="Base date", help="Report base date " "(leave empty to use current date)"
501+
string="Base date", help="Report base date (leave empty to use current date)"
503502
)
504503
pivot_date = fields.Date(compute="_compute_pivot_date")
505504
report_id = fields.Many2one("mis.report", required=True, string="Report")
@@ -765,9 +764,7 @@ def get_views(self, views, options=None):
765764
context.get("from_dashboard")
766765
and context.get("active_model") == "mis.report.instance"
767766
):
768-
view_id = self.env.ref(
769-
"mis_builder." "mis_report_instance_result_view_form"
770-
)
767+
view_id = self.env.ref("mis_builder.mis_report_instance_result_view_form")
771768
mis_report_form_view = view_id and [view_id.id, "form"]
772769
for view in views:
773770
if view and view[1] == "form":
@@ -778,7 +775,7 @@ def get_views(self, views, options=None):
778775

779776
def preview(self):
780777
self.ensure_one()
781-
view_id = self.env.ref("mis_builder." "mis_report_instance_result_view_form")
778+
view_id = self.env.ref("mis_builder.mis_report_instance_result_view_form")
782779
return {
783780
"type": "ir.actions.act_window",
784781
"res_model": "mis.report.instance",
@@ -980,7 +977,9 @@ def drilldown(self, arg):
980977
period.date_to,
981978
account_id,
982979
)
983-
domain.extend(period._get_additional_move_line_filter())
980+
additional_domain = period._get_additional_move_line_filter()
981+
if additional_domain:
982+
domain = Domain.AND([domain, additional_domain])
984983
views = self._get_drilldown_model_views(period.source_aml_model_name)
985984
return {
986985
"name": self._get_drilldown_action_name(arg),

0 commit comments

Comments
 (0)