[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
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user