title: How to convert attachment file to different format in odoo?
body: <p>How to add an observer on attachment upload in odoo to check for a certain file type and to do operation on this file? For example to convert to another format on upload.</p>
  <p>EDIT</p>
  <p><code>values</code> variable that is modified in my code still has no effect in <code>addons/web/controllers/main.py:upload_attachment()</code>, as there file storage variable is an old, unmodified still.</p>
  <p>EDIT2</p>
  <p>Here I have added the error from when I try to change the name of the file uploaded in the custom function. Because in the method <code>addons/web/controllers/main.py:upload_attachment()</code> old upload file name persists.</p>
  <pre><code>ERROR odoo13 odoo.addons.web.controllers.main: Fail to upload attachment docum2.doc 
  Traceback (most recent call last):
    File &quot;/home/computer/13-ver-odoo/addons/web/controllers/main.py&quot;, line 1512, in upload_attachment
      attachment = Model.create({
    File &quot;&lt;decorator-gen-94&gt;&quot;, line 2, in create
    File &quot;/home/computer/13-ver-odoo/odoo/api.py&quot;, line 314, in _model_create_single
      return create(self, arg)
    File &quot;/home/computer/13-ver-odoo/local-addons/crm_checklist/models/ir_attachment.py&quot;, line 54, in create
      return super(IrAttachment, self).create(values)
    File &quot;&lt;decorator-gen-39&gt;&quot;, line 2, in create
    File &quot;/home/computer/13-ver-odoo/odoo/api.py&quot;, line 335, in _model_create_multi
      return create(self, [arg])
    File &quot;/home/computer/13-ver-odoo/odoo/addons/base/models/ir_attachment.py&quot;, line 515, in create
      values.update(self._get_datas_related_values(values.pop('datas'), values['mimetype']))
    File &quot;/home/computer/13-ver-odoo/odoo/addons/base/models/ir_attachment.py&quot;, line 212, in _get_datas_related_values
      bin_data = base64.b64decode(data) if data else b''
    File &quot;/usr/lib/python3.8/base64.py&quot;, line 80, in b64decode
      s = _bytes_from_decode_data(s)
    File &quot;/usr/lib/python3.8/base64.py&quot;, line 45, in _bytes_from_decode_data
      raise TypeError(&quot;argument should be a bytes-like object or ASCII &quot;
  TypeError: argument should be a bytes-like object or ASCII string, not 'tuple'
  </code></pre>