Skip to content

Commit 54bc135

Browse files
committed
Add columns names
1 parent 05ff6c4 commit 54bc135

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

orm_mongodb.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,23 @@ def exists(self, cr, uid, ids, context=None):
253253

254254
def export_data2(self, cursor, uid, domain, limit, fields_to_export, format,
255255
context=None):
256+
def get_human_name(path):
257+
result = []
258+
obj = self
259+
for f in path.split('.'):
260+
r = obj.fields_get(cursor, uid, [f], context=context)
261+
result.append(r.get(f, {'string': f})['string'])
262+
if 'relation' in r:
263+
obj = self.pool.get(r['relation'])
264+
return ' > '.join(result)
265+
256266
ids = self.search(cursor, uid, domain, limit=limit, context=context)
257267
result = self.export_data(cursor, uid, ids, fields_to_export, context=context)
258268
import pandas as pd
259269
import base64
260270
from io import BytesIO
261-
df = pd.DataFrame(result['datas'])
271+
columns = [get_human_name(f) for f in fields_to_export]
272+
df = pd.DataFrame(result['datas'], columns=columns)
262273
# Respect the columns order
263274
buf = BytesIO()
264275
if format == 'csv':

0 commit comments

Comments
 (0)