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

Export checkbox fields

By
Tor Asbjørn
on 3/3/14, 6:36 AM 1,311 views

Hi! When we export a list form tree-view that contains Checkbox fields it will post the value i Excel as True or False. Is it possible to make this as X(true) and blank(false)? Is it also possible to make an export option ready on the "more" menu, so that they wouldn't have to select "export all data" "excel" and the fields?

This is a export/report that will be run more than once a day, so it has to be easy to access.

0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 3/3/14, 7:02 AM

1) Based on the requirement to override export_data method and make the changes in check box values.

def export_data(self, cr, uid, ids, fields, context=None):
    checkdataindex = None
    for index, fieldlabel in enumerate(fields):
        if fieldlabel == 'check_labelname':
            checkdataindex = index
    res = super(modelclass_name, self).export_data(cr, uid, ids, fields, context=context)         
    for index, val in enumerate(res['datas']):
        if checkdataindex is not None:           
            check_date = res['datas'][index][checkdataindex] 
            if check_data=='TRUE':
                res_check_data = 'X(true)'
            else:    
                res_check_data = 'blank(false)'
            res['datas'][index][checkdataindex] = res_check_data   
    return res

2) In the Export options Select the Export field to right side and click the default options "Fields to export Save fields list" and Save as: File Name

After that Export Data easy to Access with File Name.

So, where exactly do i find this export_data method? Is it a file, in the database or in the web gui?

Provendo AS, Tor Asbjørn
on 3/3/14, 8:07 AM

export_data is ORM method. Just add the above code in py file that you have created table and column. or In another way to change the checkbox data if you using sql query using if else statement change the value of check box.

Prakash
on 3/4/14, 12:50 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

0 follower(s)

Stats

Asked: 3/3/14, 6:36 AM
Seen: 1311 times
Last updated: 3/16/15, 8:10 AM