-
-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mis_builder] generalize auto expands #397
Open
TeoGoddet
wants to merge
3
commits into
OCA:14.0
Choose a base branch
from
TeoGoddet:expand-by-any
base: 14.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
# Copyright 2017 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def migrate(cr, version): | ||
cr.execute( | ||
""" | ||
ALTER TABLE mis_report_kpi | ||
RENAME COLUMN expression TO old_expression | ||
""" | ||
) | ||
# this migration to date_range type is partial, | ||
# actual date ranges needs to be created manually | ||
cr.execute( | ||
""" | ||
UPDATE mis_report_instance_period | ||
SET type='date_range' | ||
WHERE type='fp' | ||
""" | ||
) | ||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
old_column = "auto_expand_accounts" | ||
new_column = "auto_expand" | ||
|
||
if not openupgrade.column_exists(env.cr, "mis_report", new_column): | ||
openupgrade.rename_fields( | ||
env, | ||
[ | ||
( | ||
"mis.report", | ||
"mis_report", | ||
old_column, | ||
new_column, | ||
), | ||
], | ||
) | ||
|
||
old_column = "auto_expand_accounts_style_id" | ||
new_column = "auto_expand_style_id" | ||
|
||
if not openupgrade.column_exists(env.cr, "mis_report", new_column): | ||
openupgrade.rename_fields( | ||
env, | ||
[ | ||
( | ||
"mis.report", | ||
"mis_report", | ||
old_column, | ||
new_column, | ||
), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,13 +20,14 @@ def __init__( | |
self.aml_model = aml_model | ||
self._aep_queries_done = False | ||
|
||
def aep_do_queries(self): | ||
def aep_do_queries(self, auto_expand_col_name=None): | ||
if self.aep and not self._aep_queries_done: | ||
self.aep.do_queries( | ||
self.date_from, | ||
self.date_to, | ||
self.additional_move_line_filter, | ||
self.aml_model, | ||
auto_expand_col_name, | ||
) | ||
self._aep_queries_done = True | ||
|
||
|
@@ -50,6 +51,7 @@ def eval_expressions(self, expressions, locals_dict): | |
drilldown_args.append(None) | ||
return vals, drilldown_args, name_error | ||
|
||
# we keep it for backward compatibility | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it is not used anymore, better remove it now. |
||
def eval_expressions_by_account(self, expressions, locals_dict): | ||
if not self.aep: | ||
return | ||
|
@@ -66,3 +68,20 @@ def eval_expressions_by_account(self, expressions, locals_dict): | |
else: | ||
drilldown_args.append(None) | ||
yield account_id, vals, drilldown_args, name_error | ||
|
||
def eval_expressions_by_row_detail(self, expressions, locals_dict): | ||
if not self.aep: | ||
return | ||
exprs = [e and e.name or "AccountingNone" for e in expressions] | ||
for rdi_id, replaced_exprs in self.aep.replace_exprs_by_row_detail(exprs): | ||
vals = [] | ||
drilldown_args = [] | ||
name_error = False | ||
for expr, replaced_expr in zip(exprs, replaced_exprs): | ||
val = mis_safe_eval(replaced_expr, locals_dict) | ||
vals.append(val) | ||
if replaced_expr != expr: | ||
drilldown_args.append({"expr": expr, "row_detail": rdi_id}) | ||
else: | ||
drilldown_args.append(None) | ||
yield rdi_id, vals, drilldown_args, name_error |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: understand why we group by rdi_id and then account_id and not the contrary.