Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2442 Lượt xem

Hi,

i want to build a custom module which reads the content of a csv file an store the content into a database. Is there a posbilitie to use the file open dialog which is used from the standard import mechanisam of odoo.

best regerad

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Hi,

in this case the file is completely stored in the database. The idea is not store the file in the database. Is it possible to have "input_csv" only local in the method to have the possibilty to read the content of the file.

thanks


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You should add a binary field  to your project model like this:

class MyModule(models.Model):
     _name = 'my.module'
     input_csv = fields.Binary('Select a CSV file:')

Remember to add the field to your XML view file.

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi,

in this case the file is completely stored in the database. The idea is not store the file in the database. Is it possible to have "input_csv" only local in the method to have the possibilty to read the content of the file.

thanks

I'm not absolutely sure I'm quite right about this but you can check addons/base_import/models/base_import.py for more info. There is also a binary field for the imported file so I think you can either inherit from this model or just empty the field after you script is through.