-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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][FIX] web_pivot_computed_measure: fix fake fields in tests #3038
base: 18.0
Are you sure you want to change the base?
[18.0][FIX] web_pivot_computed_measure: fix fake fields in tests #3038
Conversation
Hi @CarlosRoca13, |
2c27331
to
509ef61
Compare
I am finding this error all the way: 2024-12-25 07:26:39,542 54005 INFO web_responsive_9 odoo.addons.web_pivot_computed_measure.tests.test_ui_pivot.TestUIPivot.test_ui: waiting for threads: [] UncaughtTypeError: Cannot read properties of undefined (reading '__computed_id') This external module was important for the test: with it being installed test failed, without it test didn't run! |
509ef61
to
1c85a7b
Compare
if (fieldDef && fieldDef.__computed_id) { | ||
const cm = this._computed_measures.find((item) => { | ||
return item.id === fieldDef.__computed_id; | ||
}); | ||
toAnalyze.push(cm.field1, cm.field2); | ||
const toEnableFields = []; | ||
if (!this.metaData.fields[cm.field1].__computed_id) { | ||
toEnableFields.push(cm.field1); | ||
} | ||
if (!this.metaData.fields[cm.field2].__computed_id) { | ||
toEnableFields.push(cm.field2); | ||
if (fieldDef) { | ||
if (fieldDef.__computed_id) { |
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.
Isn't it the same? You can use the shorter form. Anyway this change isn't needed IMO
if (fieldDef?.__computed_id)
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.
yes, sure
@@ -275,17 +288,27 @@ patch(PivotModel.prototype, { | |||
const fieldNames = Object.keys(this.metaData.fields); | |||
for (const fieldName of fieldNames) { | |||
const field = this.metaData.fields[fieldName]; | |||
if (field.__computed_id) { |
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.
Minimize the diff
if (field.__computed_id) { | |
if (field?.__computed_id) { |
} else { | ||
console.warn( | ||
`Field "${fieldName}" is missing __computed_id`, | ||
field | ||
); | ||
} | ||
} else { | ||
console.error(`Field "${fieldName}" is undefined in metaData.fields`); |
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.
Are these warnings and errors of any use? If this is a corner case where the code is executed but those variables aren't ready, probably the best thing to do is just to ignore it...
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 the test is not aligned with the code, there maybe some promises not functioning.
I tried but I failed as I am not the maintainer, I need help to improve the test case.
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.
@CarlosRoca13 is on holidays these days. Maybe when he comes back could give you some hints 😉
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.
@chienandalu yes, thanks to you too much for being interested.
Happy New Year
# Copyright 2022 Tecnativa - Carlos Roca | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
|
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.
🤔
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.
sorry sorry, I don't mean to ignore the author :)
|
||
# res_users_model_id = ( | ||
# cls.env["ir.model"].search([("model", "=", "res.users")]).id | ||
# ) | ||
# cls.env["ir.model.fields"].create( | ||
# { | ||
# "name": "x_user_year_born", | ||
# "model": "res.users", | ||
# "field_description": "Year Born", | ||
# "ttype": "integer", | ||
# "store": True, | ||
# "model_id": res_users_model_id, | ||
# } | ||
# ) | ||
# cls.env["ir.model.fields"].create( | ||
# { | ||
# "name": "x_user_year_now", | ||
# "model": "res.users", | ||
# "field_description": "Year Now", | ||
# "ttype": "integer", | ||
# "store": True, | ||
# "model_id": res_users_model_id, | ||
# } | ||
# ) | ||
|
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.
Just remove it?
# res_users_model_id = ( | |
# cls.env["ir.model"].search([("model", "=", "res.users")]).id | |
# ) | |
# cls.env["ir.model.fields"].create( | |
# { | |
# "name": "x_user_year_born", | |
# "model": "res.users", | |
# "field_description": "Year Born", | |
# "ttype": "integer", | |
# "store": True, | |
# "model_id": res_users_model_id, | |
# } | |
# ) | |
# cls.env["ir.model.fields"].create( | |
# { | |
# "name": "x_user_year_now", | |
# "model": "res.users", | |
# "field_description": "Year Now", | |
# "ttype": "integer", | |
# "store": True, | |
# "model_id": res_users_model_id, | |
# } | |
# ) |
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 am leaving my comment, as the original code is using a model and we get asked about the fields for this model.
We must create fake fields as while migrating another module errors came from the tests here.
user_year_now, and user_year_born fields
Check this PR please: #3037
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.
yeah, kinda makes sense without having an in depth look
1c85a7b
to
6512a83
Compare
@chienandalu see here:
2024-12-30 15:24:55,997 250 ERROR odoo odoo.addons.web_pivot_computed_measure.tests.test_ui_pivot: FAIL: TestUIPivot.test_ui UncaughtTypeError: Cannot read properties of undefined (reading '__computed_id') test fails, I can remove my commented code but I wanted to show you both errors |
This fix is the cause for not merging a new migration for web_responsive module to version 18.0.
The migration PR is #3037