-
-
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
[MIG] web_export_view: Migration to 11.0 #798
Conversation
9a6d554
to
a851831
Compare
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 looks good, but no runbot yet to test. Functionally OK too.
Thanks for the good explanation on the migration job, BTW.
Remember to squash all translation commits in one please.
quick tests on runbot by exporting some contacts: works fine ;) |
@JBF91 as for the labels, what about these 2 options:
|
a851831
to
f17bcda
Compare
@JBF91 I see... In any case the whole JS here is kind of a trick ;) Maybe you can collect fields into this._rpc({
model: view.modelName,
method: 'fields_get',
args: [self.fieldnames],
}).done(function (export_fields) {
session.get_file({
url: '/web/export/xls_view',
data: {data: JSON.stringify({
model: view.modelName,
headers: _.map(export_fields, function(field){ return field['string']; }),
rows: export_rows
})},
complete: $.unblockUI
});
}) kind of... :) Anyway, you have a "plan B" in case the JS fails: if you still send the header as field names you can call |
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 ok
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 review and test 👍
Is this exporting the whole set or not yet? It's important to keep that behavior, as Odoo export works that way and now people expect this also to work that way. |
I hacked the all records export into 8 in #785, and then had to fix a lot of stuff in https://github.com/OCA/web/pull/816/files in case that helps (probably won't given the js changes) |
What is progress on this migration? |
@okuryan Well this was working fine (two months ago) afaik, just a thing that @pedrobaeza suggested, to add an extra feature that exports all records (everypage) if all the records in the main page are selected. (Don't know if that's a good idea, to give every user who has access to a list of records exports it so easily, you already have base export functionality for that.) |
I fix the column problem with this (11.0 Enterprise):
Change th[title] with .o_column_sortable:eq |
Module works when exporting as admin but results in a traceback when exporting as a user:
EDIT: |
While exporting the list view generated by the OCA tax balance module:
|
Please send useful tracebacks: https://github.com/odoo/odoo/wiki/Contributing#tracebacks |
if (this.tag == 'field' && (this.attrs.widget === undefined || this.attrs.widget != 'handle')) { | ||
// non-fields like `_group` or buttons | ||
export_columns_keys.push(column_index); | ||
export_columns_names.push(view.$el.find('.o_list_view > thead > tr> th[title]:eq('+column_index+')')[0].textContent); |
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 found out this selector only works in debug mode.
I fixed it here acsone@bf97999
I'm not able to push on your repo @JBF91 but you can cherry pick my commit.
This commit also fixes errors when a column is not sortable, this is related to last @CasVissers reported error.
Few tests passed, everything OK with @benwillig commit cherry picked. |
I pushed an other commit here acsone@88f0e42. When exporting, numbers formatted with a float time widget are changed from '01:00' to '0100', this commit fixes this behavior. |
headers: export_columns_names, | ||
rows: export_rows | ||
})}, | ||
complete: $.unblockUI |
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.
Can you please add error handler ?
error: c.rpc_error.bind(c),
'c' will be crash manager.
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 fast way of testing the error binding?
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.
May b you can raise a warning or traceback from /web/export/xls_view route and it will be handled via crashmanager => error: c.rpc_error.bind(c)
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.
Functional review Ok.
As @MeetKD recommended, added CrashManager. I think this is ready to merge. |
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.
It seems you accidentally introduced a lint error.
@@ -7,6 +7,7 @@ | |||
import json | |||
import odoo.http as http | |||
from odoo.http import request | |||
from odoo import exceptions |
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 needed
Tested local and works ok. I don't if someone else have this little issue, but I need to restart Odoo because list view get a javascript error |
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.
LGTM
* Compatibility with Werkzeug 0.9.3 * Export of first one2many field works again * Parsing of float values
… a thousand separator is used.
… with the original index used in the native excel export
Monetary fields were being exported empty because the parsing failed. In the way of correctly exporting them as numbers, this chunk of code's performance has been improved.
* Retrieve all columns even if they are not sortable. Prevent to get select record column * Prevent to process float time numbers as real numbers during the export
0686557
to
14eb14c
Compare
14eb14c
to
9662e81
Compare
As there's no better option for now than exporting what is shown in the view, let's continue with the merge. |
We have been using it for a short while now in a production environment with no noticeable issues. |
A proposal for the Migration of web_export_view to 11.0 . Some notes about the changes and the problems I've found:
Odoo 11.0 changes some attrs in the rendering of HTML. We do not longer have auxiliar attributes like "data-id" or "data-field" very useful in the older "web_export_view" wich uses "data-field" attrs to get the column keys. I've changed it for a column index (fast and ugly workaround, but do the trick).
CONS: Couldn't get the columns Strings in the XLS header, it exports the technical name of the field instead the string.
PD: As @pedrobaeza recommend me I was triying to migrate it with the new 8.0 feature, wich exports all the dataset if all the rows are checked instead of only the first page (just like the odoo export base behaviour) but couldn't find the right way to get all item id's since we don't longer have "data-id".
Changes resume: