Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Abranes
Copy link
Member

@Abranes Abranes commented Nov 27, 2017

Hello,
With the latest version when you try to export a current view where is a m2m field we get an error.
To reproduce go to Sales --> Products --> Product variants, select any number of records and 'Export Current View', then:
export_current_view_error
(Tryed on runbot)
To fix this we implemented a case in the web_export_view.js for the m2m fields and in the controller.py we get the correct value acording to the m2m values.

Copy link
Member

@hbrunn hbrunn left a comment

Choose a reason for hiding this comment

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

I left comments what to change if you insist on this approach.

I think we'll be better off if you do what the client does (that's the trick of this module: Generate it the way the client presents it): https://github.com/OCA/OCB/blob/8.0/addons/web/static/src/js/view_list.js#L1109 You might have to slip in an inbetween step where you gather all ids of all many2many fields in the export to read

record = new instance.web.list.Record(record).toForm();
$.each(view.visible_columns, function() {
export_row.push(
this.type != 'integer' && this.type != 'float' ?
Copy link
Member

Choose a reason for hiding this comment

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

why don't you just add your exclusion here?

request.env[cell['relation']].browse(cell['ids'])
)
)
if isinstance(cell, dict) else cell
Copy link
Member

Choose a reason for hiding this comment

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

don't guess stuff. Extend the protocol that it also passes the field names being exported. From this you can decide where to do anything at all and that relation to use. And don't copy around data, the id lists are references, you you can just replace those.

@yajo yajo added this to the 8.0 milestone Nov 30, 2017
@hbrunn
Copy link
Member

hbrunn commented Nov 30, 2017

in #816 I fix this the way I propose and a few other issues, so I'd suggest to close this and review the latter.

@hbrunn hbrunn closed this Nov 30, 2017
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.

3 participants