From 2332b4c55c48939079c1e54258c56df3f8db821f Mon Sep 17 00:00:00 2001 From: Ravi Patel Date: Tue, 24 May 2016 15:52:41 +0530 Subject: [PATCH 1/2] [MOV] document: Reorganise module directory. --- addons/document/__openerp__.py | 2 +- addons/document/views/{document.xml => document_templates.xml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename addons/document/views/{document.xml => document_templates.xml} (100%) diff --git a/addons/document/__openerp__.py b/addons/document/__openerp__.py index 8ea5e002415..add1d60f177 100644 --- a/addons/document/__openerp__.py +++ b/addons/document/__openerp__.py @@ -12,7 +12,7 @@ Attachments list and document indexation """, 'depends': ['web'], 'data': [ - 'views/document.xml', + 'views/document_templates.xml', ], 'installable': True, 'auto_install': False, diff --git a/addons/document/views/document.xml b/addons/document/views/document_templates.xml similarity index 100% rename from addons/document/views/document.xml rename to addons/document/views/document_templates.xml From 65b3c683b19907e6334b8ee56d41b9d244c36fc1 Mon Sep 17 00:00:00 2001 From: Ravi Patel Date: Thu, 26 May 2016 18:47:58 +0530 Subject: [PATCH 2/2] [MIG] document: Migrated to new API. --- addons/document/__openerp__.py | 1 - addons/document/models/ir_attachment.py | 15 ++++++++------- addons/document/views/document_templates.xml | 6 ++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/addons/document/__openerp__.py b/addons/document/__openerp__.py index add1d60f177..337e6557b72 100644 --- a/addons/document/__openerp__.py +++ b/addons/document/__openerp__.py @@ -15,5 +15,4 @@ Attachments list and document indexation 'views/document_templates.xml', ], 'installable': True, - 'auto_install': False, } diff --git a/addons/document/models/ir_attachment.py b/addons/document/models/ir_attachment.py index efa244f0dfa..7480a657ff6 100644 --- a/addons/document/models/ir_attachment.py +++ b/addons/document/models/ir_attachment.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. import logging -import zipfile +import pyPdf import xml.dom.minidom +import zipfile + from StringIO import StringIO -import pyPdf - -from openerp.osv import osv +from odoo import api, models _logger = logging.getLogger(__name__) FTYPES = ['docx', 'pptx', 'xlsx', 'opendoc', 'pdf'] @@ -35,7 +35,7 @@ def textToString(element): return buff -class IrAttachment(osv.osv): +class IrAttachment(models.Model): _inherit = 'ir.attachment' def _index_docx(self, bin_data): @@ -117,10 +117,11 @@ class IrAttachment(osv.osv): pass return buf - def _index(self, cr, uid, bin_data, datas_fname, mimetype): + @api.model + def _index(self, bin_data, datas_fname, mimetype): for ftype in FTYPES: buf = getattr(self, '_index_%s' % ftype)(bin_data) if buf: return buf - return super(IrAttachment, self)._index(cr, uid, bin_data, datas_fname, mimetype) + return super(IrAttachment, self)._index(bin_data, datas_fname, mimetype) diff --git a/addons/document/views/document_templates.xml b/addons/document/views/document_templates.xml index 813ed7b7bd7..abb2d13f2fc 100644 --- a/addons/document/views/document_templates.xml +++ b/addons/document/views/document_templates.xml @@ -1,10 +1,8 @@ - - + - - +