Reputation: 782
When I created a product in 'product.template' that time I give the image for the particular record. So the record creates successfully but when I check the attachment of that record using Postgres.
select * from ir_attachment where res_id=107 and res_model='product.template'
After I go to attachment record and check the File Content name is blank. So When I was the download the image name is given False.
So how to resolve this issue and it is odoo default flow.
Upvotes: 0
Views: 2259
Reputation: 325
In Odoo 12
Python:
file_name = fields.Char("File Name")
attachment = fields.Binary("Image")
XML
<field name="file_name" invisible="1"/>
<field name="attachment" filename="file_name" widget="FieldBinary"/>
Upvotes: 1
Reputation: 685
In Odoo 11 this is a problem. So that you have to add an extra field for the name itself. For example;
in python
class
attachment = fields.Binary(string="Attachment", track_visibility="onchange")
fname = fields.Char(string="File Name", track_visibility="onchange")
in XML
:
<group>
<field name="attachment" filename="fname" widget="download_link" string="Attachment"/>
<field name="fname" invisible="1"/>
</group>
Try this, this will work. Don't forget to upvote and put tick mark too. Thanks in advance !
Upvotes: 1