-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
[18.0][MIG] mis_builder: Migration to 18.0 #652
base: 18.0
Are you sure you want to change the base?
Conversation
And refine a defaultdict declaration in AEP. The previous version was not giving wrong results, but this one will be more robust.
Currently translated at 100.0% (280 of 280 strings) Translation: mis-builder-17.0/mis-builder-17.0-mis_builder Translate-URL: https://translation.odoo-community.org/projects/mis-builder-17-0/mis-builder-17-0-mis_builder/zh_CN/
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.
Hello, thanks for this migration.
Lots of nice things! I need some time to look closer at the multi company part.
My main worry is the search_fetch which I think make the code less readable for little performance benefit.
As a side note (no need to change), in general I prefer to see mechanical changes such as replacing _
by self.env._
in separate commits to make review a bit easier.
self._account_model.with_company(company) | ||
.search(acc_domain_with_company) | ||
.ids | ||
) |
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.
Why is this necessary?
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.
- When searching for accounts by code, we only search for accounts by code within a single company
Example: We have two accounts in different companies with the same code. When we search by code, even though we add [("company_ids", "in", self.companies.ids)]
, the result includes only one account per company when with_company is used.
@@ -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 |
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.
Not sure we want to use the context for this. Maybe we should and company_id in self.companies.ids
in the domain instead.
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.
I have tried it, but its testcase failed:
domain = list(domain) + domain_by_mode[mode]
domain.append(("account_id", "in", self._map_account_ids[key]))
domain.append(("company_id", "in", self.companies.ids))
if additional_move_line_filter:
domain.extend(additional_move_line_filter)
# fetch sum of debit/credit, grouped by account_id
_logger.debug("read_group domain: %s", domain)
try:
accs = aml_model.read_group(
domain,
["debit", "credit", "account_id", "company_id"],
["account_id", "company_id"],
lazy=False,
)
2024-12-10 04:32:45,052 42839 ERROR odoo odoo.addons.mis_builder.tests.test_aep: FAIL: TestAEP.test_aep_basic
Traceback (most recent call last):
File "/home/chau/code/oca/oca-18.0/mis-builder/mis_builder/tests/test_aep.py", line 166, in test_aep_basic
self.assertEqual(self._eval("balp[][('account_id.code', '=', '400AR')]"), 100)
AssertionError: AccountingNone != 100
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.
Thanks for the explanation.
I started investigating this. And oh my... the SQL query that is now emitted by this read_group is very complex and I have serious doubts about its performance. Need to find time to dig deeper.
@@ -896,7 +911,15 @@ def drilldown(self, arg): | |||
expr = arg.get("expr") | |||
account_id = arg.get("account_id") | |||
if period_id and expr and AEP.has_account_var(expr): | |||
period = self.env["mis.report.instance.period"].browse(period_id) | |||
period = self.env["mis.report.instance.period"].search_fetch( |
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.
I see the performance benefit of search_fetch but we should balance it's use against maintainability. For small tables such as this one, the performance benefit is not worth the reduced maintainability and readability. Can you please revert these?
@@ -133,6 +132,10 @@ def check_positive_val(self): | |||
hide_always_inherit = fields.Boolean(default=True) | |||
hide_always = fields.Boolean(default=False) | |||
|
|||
_sql_constraints = [ | |||
("style_name_event_uniq", "unique(name)", "Style name should be unique") | |||
] |
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.
This constraint seems unrelated to the migration? Better have it in a separate PR.
mis_builder/readme/CREDITS.md
Outdated
@@ -0,0 +1 @@ | |||
The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp. |
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.
I'm not fan of this kind of marketing.
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.
I think it's legit in this case to promote that funding, and we created that section for this goal. C2C is contributing in this case this way. It's true that we need to be aware when migrating to another version to remove it, but it's fair enough to put it.
1862431
to
5035e05
Compare
I'm aware of the optimization that search_fetch brings, but it comes at a cost of code that is harder to read, and also the optimization benefit is easily lost when later modifying the code to read another field as it's easy to forget to add the new field to the search_fetch call. So I think we should reserve these for places where it really matters. It is anyway unrelated to the migration. Could you remove these search_fetch changes, and possibly open another PR if you think it is important in some places, so we can discuss it separately from the migration? Could you also move the constraint on style name to a separate PR? It is also unrelated to the migration and it will be easier for me to track the backports if it is separated. Thanks for moving the self.env._ part to a separate commit! I'll look closer at the multicompany parts soon. |
I think |
Yes, it is in a separate commit, that is fine. I'm not asking to have it in a separate PR. |
I don't think it should go in a separate commit as said. |
Should I create PR for 17.0 or 18.0? |
@chaule97 as you prefer. Even 16.0 if you like. |
5035e05
to
bc34ec2
Compare
My reasoning is that it's similar to the changes done by pre-commit. Mechanical changes done by odoo-module-migrator are best in a separate commit and keep the changes done by a human in a distinct commit. |
Well, I do that changes by hand, not using odoo-module-migrator, but then let's normalize this into a commit |
Anyway, thinking twice, at the end, odoo-module-migrator is doing the same job as you as human, so we differentiate them? What we want is to have all the changes needed for a migration in one place (or is it only me that this is what I want to check while reviewing a migration - among other things, of course -?) |
By that reasaoning, why then requiring a separate commit for pre-commit changes? |
pre-commit changes are only syntactic or tool-related ones. They can be mostly ignored. These other changes involves framework changes and other modifications that may affect with more probability with the features/functioning of the module. |
display_name
, so I override the_search_display_name
method inmis.report.kpi.expression
.reporting-engine
module, thereport_type
field inreport_type
model has a new value xlsx. However, the test_report in odoo 18 can't examine it. I have to addwith self.assertLogs("odoo.tools.test_reports", level="WARNING"):
to ignore the warning.