This question has been flagged

On my production server some of attachments started to give error "File Not Found". I investigated further in database and found some directories were missing from filestore. I checked directores at "~/local/share/Odoo/filestore/db_name/directory"(given by  store_fname column of ir_attachment table). I am having no idea how it can happen? nobody has access to server to delete them.Is it possible someone could delete those directory (even Admin) from Odoo Interface? I Think No because filenames and attachment links are still active on Odoo. 

Is it possible some other attachment replacing whole directory? I think not because some directores are completly missing not just files inside them. if Yes in which case?

Any clue what could have happened?

Thanks in Advance.

Avatar
Discard

Attachments can certainly be deleted from the Odoo interface. An attachment is just like any other record in the system, it can be deleted by those who have permission. This may not be happening in your case, but you can definitely delete attachments from within Odoo. Admin is a special user who has no permission restrictions so can delete many record types bypassing any rules.

Author

@Ray Carnes: Yes I know attachment can be deleted what I meant that can they be deleted from interface while keeping attachment link active? In documents attachments links are alive and when I try to download it says "File Not Found".

Best Answer

Hi,

I've got the same problem: for unknown reason, one of the subdirectory of the filestore suddenly "disappeared"

My question is : CAN WE TRUST ODOO ?!!!?

Thanks

Avatar
Discard
Best Answer

In Odoo V11,
In order to fix the problem, you have to override the method `_file_write` in the `ir.attachment` class as following:

class Attachment(models.Model):
_inherit = 'ir.attachment'

@api.model
def _file_write(self, value, checksum):
bin_value = base64.b64decode(value)
fname, full_path = self._get_path(bin_value, checksum)
if not os.path.exists(full_path):
try:
with open(full_path, 'wb') as fp:
fp.write(bin_value)

except IOError:
_logger.info("_file_write writing %s", full_path, exc_info=True)
# add fname to checklist, in case the transaction aborts

# Fixed the place the following line in order to fix the bug
self._mark_for_gc(fname)
return fname
Avatar
Discard