Comment joindre un fichier sur Odoo?
Pour joindre un fichier sur Odoo à partir de la vue form, il suffit d'utiliser le champs fields.Binary pour sauvegarder le fichier en question et le champs fields.Char pour enregistrer le nom du fichier. Ensuite, vous pourrez les insérer dans votre vue form.
Voici un exemple illustratif
Dans le modèle Python
[from odoo import fields, models]{style="font-family: "courier new", courier, monospace;"}
[
]{style="font-family: "courier new", courier, monospace;"}[
]{style="font-family: "courier new", courier, monospace;"}[class ExempleFichier(models.Model):]{style="font-family: "courier new", courier, monospace;"}
[ ]{style="font-family: "courier new", courier, monospace;"}
[ _name = 'exemple.fichier']{style="font-family: "courier new", courier, monospace;"}
[ ]{style="font-family: "courier new", courier, monospace;"}
[ fichier = fields.Binary(string=_("Joindre votre fichier"), track_visibility="onchange")]{style="font-family: "courier new", courier, monospace;"}
[ nom_fichier = fields.Char(string=_("Nom du fichier"), track_visibility="onchange")]{style="font-family: "courier new", courier, monospace;"}
Côté XML
[<field name="fichier" filename="]{style="font-family: "courier new", courier, monospace;"}[nom_fichier]{style="font-family: "courier new", courier, monospace;"}[" widget="download_link" />]{style="font-family: "courier new", courier, monospace;"}
[<field name="nom_fichier" invisible="1"/>]{style="font-family: "courier new", courier, monospace;"}