openerp


How read excel file in odoo 9


I have data in excel file. How read that file line by line and data insert in database? Maybe add upload control and after click on button in .py file read line by line.
For example:
1 John Stern
2 Mike Hox
3 Julia Max
Any example?
In the first time, you need determinating, what package would you like used to read your excel file.
I found this website (http://www.python-excel.org/), you can found the little list of python package.
In my case I used openpyxl
import openpyxl
from openerp import models, fields, api, _
from tempfile import TemporaryFile
class ExcelReader(models.TransientModel):
_name="reader_excel"
excel_file = fields.Binary(string='Excel File')
def import_excel(self):
# Generating of the excel file to be read by openpyxl
file = self.excel_file.decode('base64')
excel_fileobj = TemporaryFile('wb+')
excel_fileobj.write(file)
excel_fileobj.seek(0)
# Create workbook
workbook = openpyxl.load_workbook(excel_fileobj, data_only=True)
# Get the first sheet of excel file
sheet = workbook[workbook.get_sheet_names()[0]]
# Iteration on each rows in excel
for row in sheet.rows:
# Get value
v1 = row[0].value
v2 = row[1].value
v3 = row[2].value
# Create your record
self.env['your_model'].creaate({'val1':v1,'val2':v2, 'val3':v3'})
It's a little example. You need adapting for your situation.

Related Links

Create a window action in a tree, possibly affecting all records
In OpenERP, how can I determine how stock from purchases are assigned to which manufacturing orders?
OpenErp 6.0 Payroll
indent using condition
how to add order name in pos receipt?
2 Threads created when double clicking in tree/list in OpenERP
Which is the best way to make automated backups?
Allow Open ERP Accounting Module Customers to login
OpenERP: modify core module
Modifying one of OpenERP's core fields using a custom module
Change field value and trigger onchange event on button press
OpenERP custom module on mobile
Create external reference id
'deposit' object has no attribute 'get_move_line'
How to store the value as "Account Receivable
Python Debugger out of sync with code

Categories

HOME
react-native
highcharts
cron
instagram
encryption
netlogo
migration
wildfly
aws-codepipeline
servicestack
unity5
mapkit
asp.net-web-api2
pstricks
apache-apex
sage
visio
apigee
access-control
konvajs
firebase-cloud-messaging
visualvm
pki
xfce
deprecation-warning
jsdata
powerpoint-vba
virtuoso
week-number
neo4jclient
street-address
layer
javapoet
cassandra-3.0
kernel-module
oracle-data-modeler
webex
xilinx-edk
spring-cloud-sleuth
smo
virsh
subtitle
tinyxml2
sift
satellite
siteminder
rate
rational-team-concert
mailman
codeigniter-restserver
nibble
grid-layout
groovy-eclipse
graphic-effects
sonarqube-5.4
octopress
youtube-javascript-api
tess-two
angular-ui-tree
offsetheight
elmah.mvc
spatialite
gcdasyncsocket
eofexception
sql-agent-job
materialized-views
jison
wunderlist
er-diagrams
cleartool
httplib
filefield
pegjs
xcode-instruments
syntactic-sugar
zurb-joyride
controltemplate
restriction
alassetslibrary
gideros
boost-spirit-karma
real-time-data
jnetpcap
windmill
ruby-on-rails-plugins
capability
custom-view
getprocaddress
generic-list
spaces
layar
juggernaut
bootclasspath
xcode4.1
rebuild
oracle8i
moss2007enterprisesearch
flashlite

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile