I want to write a module which gets an excel file as input and do some process based on excel data. How can I achieve this? Thanks in advance.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
This is mostly related to python and not Odoo. If you just google, you will get lots of options and code to read the data from excel.
https://www.geeksforgeeks.org/reading-excel-file-using-python/
https://datatofish.com/read_excel/
For the input, create a wizard and add a binary field in which you can load the excel file, and then using any python library, you can read the data from that excel.
Can you be more specific about odoo part?
You need to create a wizard and a binary field to take the file as an input and then using python lib, read the data from the file.
and How can I process the file that I uploaded?
Instead of coding I have started using android productivity office apps. Microsoft 365 is the best solution.
Hi,
To load an excel file and read its data and to create record inside the odoo database, you can refer this module, which creates chart of account from excel. See this: Import Chart of Accounts from CSV or Excel File
Relevant part of the code, that reads data from excel.
try:
fp = tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx")
fp.write(binascii.a2b_base64(self.File_slect))
fp.seek(0)
values = {}
workbook = xlrd.open_workbook(fp.name)
sheet = workbook.sheet_by_index(0)
except:
raise Warning(_("Invalid file!"))
for row_no in range(sheet.nrows):
val = {}
if row_no <= 0:
fields = map(lambda row: row.value.encode('utf-8'), sheet.row(row_no))
else:
line = list(map(lambda row: isinstance(row.value, bytes) and row.value.encode('utf-8') or str(row.value),
sheet.row(row_no)))
values.update({'code': line[0],
'name': line[1],
'user': line[2],
'tax': line[3],
'tag': line[4],
'group': line[5],
'currency': line[6],
'reconcile': line[7],
'deprecat': line[8],
})
res = self.create_chart_accounts(values)
Thanks
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
3
thg 11 20
|
4913 | ||
|
2
thg 8 22
|
6361 | ||
|
4
thg 5 24
|
2841 | ||
|
2
thg 10 23
|
3390 | ||
|
1
thg 12 21
|
4615 |
I also don't want to save it in database.