Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How can I change the Excel / CSV Export thousands separator and decimal mark

By
Sascha Pfeiffer
on 8/7/15, 3:24 AM 1,551 views

Hi,

In German's Excel Sheets (xls, xlsx) you need to put "," instead of "." as a decimal mark. As a result, csv files also need to look different for Germans to be opened in Excel. The seperator we use to seperate values is ";" instead of "," How do I accomplish this for the Excel Export in OpenERP 7 ?

Regards

Sascha


Im fixing this now by adjusting the neccessary files, so for further reference:

1) First step

addons/web/controllers/main.py

change:

    writer = csv.writer(fp, uoting=csv.QUOTE_ALL)

to:

    csv_internal_sep = config['csv_internal_sep']

    writer = csv.writer(fp, delimiter=csv_internal_sep, quoting=csv.QUOTE_ALL)


2) Second step

server/opener/osv/orm.py

change at the end of __export_row():


def __export_row(self, cr, uid, row, fields, context=None):

[...]

if i == len(f):

     if isinstance(r, browse_record):

          r = self.pool.get(r._table_name).name_get(cr, uid, [r.id], context=context)

          r = r and r[0] and r[0][1] or ''

    data[fpos] = tools.ustr(r or '')


return [data] + lines


to


def __export_row(self, cr, uid, row, fields, context=None):

[...]

    if i == len(f):

        if isinstance(r, browse_record):

            r = self.pool.get(r._table_name).name_get(cr, uid, [r.id], context=context)

            r = r and r[0] and r[0][1] or ''

        data[fpos] = tools.ustr(r or '')

if self.pool.get('res.users').browse(cr, uid, uid).lang == 'de_DE':

        if f[i - 1] in self._columns and self._columns[f[i - 1]]._type == 'float' \

                    or f[i - 1] in self._inherit_fields and self._inherit_fields[f[i - 1]][2]._type == 'float':

            data[fpos] = data[fpos].replace(',', '')

            data[fpos] = data[fpos].replace('.', ',')

return [data] + lines

Hope this helps whoever runs into the same problem.


0

Bole

--Bole--
2385
| 5 4 6
Zagreb | Karlovac, Croatia
--Bole--

there is only 10 kind of people the ones that understand binary ... and others

Bole
On 8/10/15, 3:53 AM

Try this: 

in your config file put folowing line:
csv_internal_sep = ;

it will set semicolon as default delimiter in csv files for import data, but i belive it will also set semicolon as delimiter fro export data.. as for thousands separator.. try setig it correcty in language settings... should work.. 


hope it helps


 

I already have both settings set this way, but they seem to be completly ignored for CSV / Excel Export

Sascha Pfeiffer
on 8/12/15, 1:57 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/7/15, 3:24 AM
Seen: 1551 times
Last updated: 8/12/15, 3:56 AM