-
-
Notifications
You must be signed in to change notification settings - Fork 304
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
[11.0] migration #67
[11.0] migration #67
Conversation
Fixed the drilldown test and rebased. I updated the review TODO list in the PR description. |
cff8425
to
99fa7b9
Compare
@api.multi | ||
def get_mis_report_view_from_id(self): | ||
for rec in self: | ||
return rec.get_mis_report_view_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.
This return inside the loop is not correct.
to render the actual mis report instance in the html format using the | ||
widget""" | ||
for rec in self: | ||
rec.mis_report_view = "" |
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 comfortable with this dummy field. Surely there must be a better way. Why is it computed btw?
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.
You need to use a dummy field in order to be able to render the form view into this field.
I tested the various methods to render the dynamic view. The method used in v10, using the declaration of , https://github.com/OCA/mis-builder/blob/10.0/mis_builder/views/mis_report_instance.xml#L17, does not work in v11 anymore.
I tried using client actions as used in https://github.com/odoo/odoo/blob/11.0/addons/stock/views/stock_picking_views.xml#L235, but this would not let me add the view to the dashboard.
Perhaps there's another way, but I could not find 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.
Perhaps we could bind the widget to the id
field? So we could use the same widget on any m2o field that points to a mis.report.instance
?
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.
The problem is that with this approach we need to define . And it is "mis_report_view" the field that renders the full representation. I would not know how to bind the widget to the id field.
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.
But where is that mis_report_view
field computed with a real value? I can't find it in the code.
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.
The content is defined in the _render method in the JS side https://github.com/OCA/mis-builder/blob/11.0-dev/mis_builder/static/src/js/mis_builder_widget.js#L44
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.
So, the field has a widget, and the widget renders the content of this field. It really does happen to need any content from the field itself.
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 but that does not use the mis_report_view
field at all. So the widget could be bound to any field and the result would be identical?
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.
Do you suggest ?
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.
fd26f81 is a first simplification.
method: 'drilldown', | ||
args: [context.active_id, drilldown], | ||
context: context, | ||
}).then(function(result){ |
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 my understanding of the js framework, there are better, higher level, ways to invoke backend methods than _rpc
. These higher level methods were used in v10. This is probably the cause of drilldown not working.
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 seems to be the standard method to call to backend methods in v11.
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.
Ah ok then. So we need to convert the drilldown
arg to json here.
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.
Done
|
||
<td t-foreach="row['cells']" t-as="cell" | ||
t-att="{'style': cell['style'], 'title': cell['val_c']}" class="mis_builder_amount"> | ||
<t t-if="row['cells']"> |
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 this t-if row['cells']
?
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 can be removed.
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.
Removed.
mis_builder/models/kpimatrix.py
Outdated
'val_c': '', | ||
'style': None, | ||
} | ||
row_data['cells'].append(col_data) |
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.
Is this change necessary? If yes why?
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. This fix prevented errors raising when you attempted to create lines.
@jbeficent the issues with the complex domains in the view, as well as the MisKpiData tests are resolved. I still need fully dive into the js part. I've some doubts I wrote in the review comments. To be further investigated. |
_render: function () { | ||
var self = this; | ||
var context = self.getParent().state.context; | ||
var rec_id = this.recordData.id || self.getParent().state.context.active_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.
Here we must use the field value. Not sure active_id makes sense (TBC).
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.
The problem I had is when you add to the dashboard. It is in those cases where I needed. Because in the dashboard the record is not loaded. This has changed in the definition of the dashboard from v10, as far as I can tell.
I will look at this proposal from @lasley to define classes during testing OCA/maintainer-tools#242. Perhaps it is better than what we used, or vice-versa? |
It was adapted from an Acsone strategy (from Alfodoo), which originally looked very similar to the one you have here. It received a bunch of fixes from @obulkin though as the abstract models began to be implemented in descendent modules. Off the top of my head, I remember there were also some database mutations being missed that caused major headaches. |
@lasley @obulkin I also implemented @sbidoul approach here: https://github.com/OCA/server-tools/blob/11.0/base_exception/tests/common.py with success. Perhaps you can review if this proposal works better also for you and we can propose an improved template in maintainer-tools. |
@jbeficent in my tests the teardown part is useful too to avoid warnings. Note this approach is very close to what Odoo does when creating/removing custom models through the UI: that's where I found inspiration in the end. |
@sbidoul I had to remove the reardown in the other module in https://github.com/OCA/server-tools/blob/11.0/base_exception/tests/common.py, though, because it would not allow me to uninstall the module. Gave me a nasty error indicating that the model was not found in the registry. |
At a glance, it does seem like all the problematic commits have been removed from v11, so there's probably no need to put the registry into test mode in this version. However, you may still want to do something along the lines of the following:
This should prevent warnings about the model not having a table, while avoiding any errors caused by descendent code that expects it to be in the registry. At the very least, that was my experience in v10, where my first solution was also to just delete the model from the registry. |
- we use the widget qweb template mechanism as in v10 - so the widget template does not change (except a tiny improvement) - rename widget and widget template files (mis_report_widget.js, .xml) - call the asynchronous method where they belong ie in the willStart method of the widget
Rebased. @jbeficent with fb3654e I'm now satisfied with the widget. I rebased a last time, and removed the WIP tag. I think we are good now! |
@sbidoul Good! Thanks for your help! I will do a last review on monday. |
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.
Code LGTM. Just some questions...
@@ -1,10 +1,9 @@ | |||
# -*- coding: utf-8 -*- | |||
# Copyright 2014-2017 ACSONE SA/NV (<http://acsone.eu>) |
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.
you might want to raise year up to 2018 ;)
# Copyright 2014-2017 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
'name': 'MIS Builder', | ||
'version': '10.0.3.1.1', | ||
'version': '11.0.3.1.1', |
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.
by convention should be "11.0.0.0" but I understand if you want to keep internal versions in line :)
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, I do the effort of maintaining feature parity across 9 10 11 so this version number expresses that.
mis_builder/datas/ir_cron.xml
Outdated
<field eval="'_vacuum_report'" name="function"/> | ||
<field eval="'(24,)'" name="args"/> | ||
<field ref="model_mis_report_instance" name="model_id"/> | ||
<field name="code">model._vacuum_report(24, 0)</field> |
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.
hours=24
(default, BTW). The second number is? I don't see it here
def _vacuum_report(self, hours=24): |
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.
@simahawk fixed
<t t-set="matrix" t-value="o._compute_matrix()"/> | ||
<t t-set="style_obj" t-value="o.env['mis.report.style']"/> | ||
<div class="page"> | ||
<link href="/mis_builder/static/src/css/report.css" rel="stylesheet"/> |
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.
any good reason to keep the css here instead of assets?
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.
good question. @jbeficent do you know why this change was made?
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.
@simahawk is it better now?
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.
@sbidoul should I see any difference? 🤔
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.
ahh now I see it. LGTM 😄
I just noticed this line: |
Replaced by decoration-*. To be backported to 10 and 9.
@astirpe |
I am good with the proposed changes! |
Thank you for this! |
Thank you @sbidoul !! |
TODO: