Skip to content
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

Merged
merged 23 commits into from
Feb 4, 2018
Merged

[11.0] migration #67

merged 23 commits into from
Feb 4, 2018

Conversation

sbidoul
Copy link
Member

@sbidoul sbidoul commented Jan 5, 2018

TODO:

  • This PR requires [FIX] web: issue when id field is present in x2m form odoo/odoo#21944. It's merged in saas-16, wait until it's forward ported to 11.0.
  • investigate some changes in mis_builder_template.xml wrt v10
  • drilldown is broken because the arguments is sent as string to the backend, probably due to a change in the js framework, the conversion to json must take place here
  • investigate changes in the definition of fields seq1, seq2 in mis_kpi_data.py: these should remain related as in v10, or is there an ORM bug?

@sbidoul sbidoul changed the title [11.0] 11.0 migration [11.0] migration Jan 5, 2018
@sbidoul sbidoul mentioned this pull request Jan 5, 2018
7 tasks
@sbidoul sbidoul changed the base branch from 10.0 to 11.0 January 6, 2018 13:14
@sbidoul sbidoul closed this Jan 6, 2018
@sbidoul sbidoul reopened this Jan 6, 2018
@sbidoul
Copy link
Member Author

sbidoul commented Jan 6, 2018

Fixed the drilldown test and rebased.

I updated the review TODO list in the PR description.

@sbidoul sbidoul force-pushed the 11.0-dev branch 3 times, most recently from cff8425 to 99fa7b9 Compare January 7, 2018 16:12
@api.multi
def get_mis_report_view_from_id(self):
for rec in self:
return rec.get_mis_report_view_html()
Copy link
Member Author

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 = ""
Copy link
Member Author

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?

Copy link
Sponsor Member

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.

Copy link
Member Author

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?

Copy link
Sponsor Member

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.

Copy link
Member Author

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.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Sponsor Member

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.

Copy link
Member Author

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?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you suggest ?

Copy link
Member Author

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){
Copy link
Member Author

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.

Copy link
Sponsor Member

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.

Copy link
Member Author

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.

Copy link
Sponsor Member

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']">
Copy link
Member Author

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'] ?

Copy link
Sponsor Member

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.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

'val_c': '',
'style': None,
}
row_data['cells'].append(col_data)
Copy link
Member Author

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?

Copy link
Sponsor Member

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.

@sbidoul
Copy link
Member Author

sbidoul commented Jan 8, 2018

@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;
Copy link
Member Author

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).

Copy link
Sponsor Member

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.

@JordiBForgeFlow
Copy link
Sponsor Member

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?

@lasley
Copy link

lasley commented Jan 10, 2018

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.

@sbidoul
Copy link
Member Author

sbidoul commented Jan 11, 2018

@jbeficent @lasley I believe the solution I reached in this PR for the test model is simple and clean and leaves the database clean. It works because auto_init does not commit in v11 (whereas it did in 10).

@JordiBForgeFlow
Copy link
Sponsor Member

@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.

@sbidoul
Copy link
Member Author

sbidoul commented Jan 11, 2018

@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.

@JordiBForgeFlow
Copy link
Sponsor Member

@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.

@obulkin
Copy link

obulkin commented Jan 11, 2018

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:

cls.registry[cls.test_model._name]._abstract = True
cls.registry[cls.test_model._name]._auto = False

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.

@sbidoul
Copy link
Member Author

sbidoul commented Jan 13, 2018

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!

@JordiBForgeFlow
Copy link
Sponsor Member

@sbidoul Good! Thanks for your help! I will do a last review on monday.

Copy link

@simahawk simahawk left a 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>)

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',

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 :)

Copy link
Member Author

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.

<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>

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):

Copy link
Member Author

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"/>

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?

Copy link
Member Author

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?

Copy link
Member Author

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?

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? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simahawk yes (0237f59). Apparently github has difficulties showing the diff inside the conversation. But the full diff is correct.

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 😄

@astirpe
Copy link
Member

astirpe commented Jan 24, 2018

I just noticed this line:
https://github.com/OCA/mis-builder/blob/11.0-dev/mis_builder/views/mis_report_instance.xml#L93
and I would ask you to replace the old colors= syntax with the new decoration-*= way to define the colors of rows.

@sbidoul
Copy link
Member Author

sbidoul commented Jan 24, 2018

@astirpe color="red:... replaced with decoration-danger. Thanks for pointing this out.

@JordiBForgeFlow
Copy link
Sponsor Member

I am good with the proposed changes!

@sbidoul sbidoul merged commit 12b58be into 11.0 Feb 4, 2018
@sbidoul sbidoul deleted the 11.0-dev branch February 4, 2018 15:20
@astirpe
Copy link
Member

astirpe commented Feb 5, 2018

Thank you for this!
I think the default branch can be set to 11.0 ;)

@JordiBForgeFlow
Copy link
Sponsor Member

Thank you @sbidoul !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants