8ab5f3979b
There is a deduplication in ir.attachment, but it's only for FS-stored content *and* it only deduplicates storage not models (as there are access rights issues involved). The goal here is to always return the same attachment when a user uploads the exact same image multiple times (because it's simpler or whatever). Initially tried to use a binary field & digest(), but search() blows up because it tries to utf-8 encode raw binary data. So use char & hexdigest instead. _compute_checksum returns None if the provided attachment data does not look like a website image attachment. Unhandled: multiple existing matches, maybe a UNIQUE constraint on the checksum field would be a good idea just in case. cherrypicked from saas-3's xmo@openerp.com-20140303153855-5f2l8v0jq2mgb26f which had to be backed out (as the patch adds a new stored field) bzr revid: xmo@openerp.com-20140304133117-r88p9zl2tc9tsh75 |
||
---|---|---|
.. | ||
controllers | ||
data | ||
models | ||
security | ||
static | ||
tests | ||
views | ||
__init__.py | ||
__openerp__.py |