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

V9.0: How shall I select and show some items from Excel Files?

By
vx2008
on 7/10/16, 6:08 AM 226 views

I have an excel file as below:

ID
Name
Time001
001
Bob
2016-05-10 10:40:43
002
John
2016-06-10 12:32:45
...
...
...

Now I want to import this data from this excel file and select some rows and show on Odoo; I have code as below:

# -*- coding: utf-8 -*-

from openerp import models, fields

import base64

class PunchTask(models.Model):

    _name = 'punch.task'

    _description = 'Punch task'

    datafile=fields.Binary("File")

    records=fields.Text('Selected Items')

    def action_upload(self,cr,uid,ids,context=None):

        this=self.browse(cr,uid,ids[0])

        data = base64.decodestring(this.datafile)

Then the "Datafile" can get selected Excel file and "data" can get data from the excel file;

My question is: how can I get each column's data from "data" like this:

column_1=['001','002','...']; colume_2=['Bob','John','...'];column_3=['2016-05-10 10:40:43','2016-06-10 12:32:45','...'];


Finally I want to select the rows whose "Time" is " 2016-05-10 10:40:43" or other something; and how the rows on "records".

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: 7/10/16, 6:08 AM
Seen: 226 times
Last updated: 7/10/16, 11:26 AM