diff options
| author | fwi-odoo <fwi@odoo.com> | 2016-07-26 12:06:35 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2016-08-03 13:42:25 +0200 |
| commit | a32c1d3c8dfd3d4684f89a6181f3a093dde26ae6 (patch) | |
| tree | 392ca984f973bbb1c50b66d1a771f6d3c488313b /addons/web_editor/models/ir_attachment.py | |
| parent | 65fbeb21f6d27068b0a598eb9c84eb35755249a7 (diff) | |
[MIG] web_editor: migrate to new api
Diffstat (limited to 'addons/web_editor/models/ir_attachment.py')
| -rw-r--r-- | addons/web_editor/models/ir_attachment.py | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/addons/web_editor/models/ir_attachment.py b/addons/web_editor/models/ir_attachment.py index 135d82bc592..0c5f0e53de8 100644 --- a/addons/web_editor/models/ir_attachment.py +++ b/addons/web_editor/models/ir_attachment.py @@ -1,36 +1,18 @@ # -*- coding: utf-8 -*- -import openerp -from openerp.osv import osv, fields +# Part of Odoo. See LICENSE file for full copyright and licensing details. -import contextlib -from sys import maxint -from openerp.http import request -import datetime -import hashlib -import time -import os +from odoo import api, models, fields -from openerp.tools import html_escape as escape, ustr, image_resize_and_sharpen, image_save_for_web -from PIL import Image -import cStringIO -import logging -logger = logging.getLogger(__name__) - - -class ir_attachment(osv.osv): +class IrAttachment(models.Model): _inherit = "ir.attachment" - def _local_url_get(self, cr, uid, ids, name, arg, context=None): - result = {} - for attach in self.browse(cr, uid, ids, context=context): - if attach.url: - result[attach.id] = attach.url - else: - result[attach.id] = '/web/image/%s?unique=%s' % (attach.id, attach.checksum) - return result + local_url = fields.Char("Attachment URL", compute='_compute_local_url') - _columns = { - 'local_url': fields.function(_local_url_get, string="Attachment URL", type='char'), - } + @api.one + def _compute_local_url(self): + if self.url: + self.local_url = self.url + else: + self.local_url = '/web/image/%s?unique=%s' % (self.id, self.checksum) |
