Search code examples
pythonxmlodooodoo-13

ir.attachment in diferent model can view diferent ways


I work with file storage module and need to upload files to module. In my definition i use

class TestClass(models.TransientModel):
_name = "module_name.test_class"

  attachment_id = fields.Many2one(
    comodel_name='ir.attachment',
    string="newFileVersion",
    index=True,
    copy=False
 )

When i use in xml

<field name="attachment_id"/>

it shows input dropdown item with alredy loaded in DB files, but I need to choose files from my local computer. What I did wrong. (Sorry for bad english)


Solution

  • CZoellner, I found another one decision: in py

    file = fields.Binary("Attachment")
    file_name = fields.Char("File Name")
    

    in xml

    <field name="file" filename="file_name"/>
    <field name="file_name"/>
    

    in that case file_name store real filename as it store on the computer. And then just write() to ir.attachment right name. Reely wize mans said that to ask right question you need ton know at leest half of the answer