Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
19811 มุมมอง

I'd like to upload 2 files to my models directory, code below:

file1= fields.Binary("Upload file1")
file2 =fields.Binary("Upload file2")

<field name="file1" filename="file1_name"/>
<field name="file2" filename="file2_name"/>

after I get my 2 files into my models directory which is not the case I'd like to pass these files to my function:

start(file1_name,file2_name)

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello,
You have to define one char field to save a binary file.
In your case :

Py File:
file1 = fields.Binary("Upload file1")
file1_name = fields.Char('File Name1')
file2 = fields.Binary("Upload file2")

file2_name = fields.Char('File Name2')

XML File :
<field name="file1" filename="file1_name"/>
<field name="file1_name" invisible="1"/>
<field name="file2" filename="file2_name"/>
<field name="file2_name" invisible="1"/>

Hope it will works for you.
Thanks.
อวตาร
ละทิ้ง
ผู้เขียน

Well the problem is that I cant have those files saved to my models directory, thus I get this error when I pass each file's name to the function:

FileNotFoundError: [Errno 2] No such file or directory:

I have googled it and I have found that the files uploaded will be stored in the database but I want them to be saved to my models directory

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ค. 22
9577
1
มิ.ย. 21
2774
[SOLVED] Get related field แก้ไขแล้ว
2
ก.พ. 21
299
5
ก.ย. 20
14709
How to install new module in Odoo 11 แก้ไขแล้ว
4
มิ.ย. 20
50138