Skip to content
Snippets Groups Projects
Commit 8276fb58 authored by Denis Ledoux's avatar Denis Ledoux
Browse files

[FIX] export: add the context in the export

In some cases, the data dispalyed in a list depends on the context
This context needs to be passed to the export method, so the exported data reflects correctly the data from the list view
parent 6b8af731
No related branches found
No related tags found
No related merge requests found
......@@ -1606,16 +1606,18 @@ class ExportFormat(object):
@openerpweb.httprequest
def index(self, req, data, token):
params = simplejson.loads(data)
model, fields, ids, domain, import_compat = \
operator.itemgetter('model', 'fields', 'ids', 'domain',
'import_compat')(
simplejson.loads(data))
params)
Model = req.session.model(model)
ids = ids or Model.search(domain, 0, False, False, req.context)
context = dict(req.context or {}, **params.get('context', {}))
ids = ids or Model.search(domain, 0, False, False, context)
field_names = map(operator.itemgetter('name'), fields)
import_data = Model.export_data(ids, field_names, req.context).get('datas',[])
import_data = Model.export_data(ids, field_names, context).get('datas',[])
if import_compat:
columns_headers = field_names
......
......@@ -389,6 +389,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
fields: exported_fields,
ids: ids_to_export,
domain: this.dataset.domain,
context: this.dataset.context,
import_compat: !!this.$el.find("#import_compat").val(),
})},
complete: instance.web.unblockUI,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment