Browse Source

change way to open new cursor

12.0-mig-module_prototyper_last
Florian da Costa 8 years ago
committed by David Beal
parent
commit
2afb06da22
  1. 1
      attachment_base_synchronize/__openerp__.py
  2. 332
      attachment_base_synchronize/i18n/fr.po
  3. 26
      attachment_base_synchronize/models/attachment.py

1
attachment_base_synchronize/__openerp__.py

@ -11,6 +11,7 @@
'category': 'Generic Modules', 'category': 'Generic Modules',
'depends': [ 'depends': [
'base', 'base',
'mail',
], ],
'data': [ 'data': [
'views/attachment_view.xml', 'views/attachment_view.xml',

332
attachment_base_synchronize/i18n/fr.po

@ -1,243 +1,319 @@
# Translation of Odoo Server. # Translation of Odoo Server.
# This file contains the translation of the following modules: # This file contains the translation of the following modules:
# * attachment_metadata
# * attachment_base_synchronize
# #
# Translators:
# Christophe CHAUVET <christophe.chauvet@gmail.com>, 2016
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: server-tools (8.0)\n"
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-17 02:42+0000\n"
"PO-Revision-Date: 2016-06-23 09:22+0000\n"
"Last-Translator: Christophe CHAUVET <christophe.chauvet@gmail.com>\n"
"Language-Team: French (http://www.transifex.com/oca/OCA-server-tools-8-0/language/fr/)\n"
"POT-Creation-Date: 2016-08-10 16:34+0000\n"
"PO-Revision-Date: 2016-08-10 16:34+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Plural-Forms: \n"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Attachment" msgid "Attachment"
msgstr "Pièce jointe" msgstr "Pièce jointe"
#. module: attachment_metadata
#: field:ir.attachment.metadata,name:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_name
msgid "Attachment Name" msgid "Attachment Name"
msgstr "Nom de la pièce jointe" msgstr "Nom de la pièce jointe"
#. module: attachment_metadata
#: field:ir.attachment.metadata,attachment_id:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_local_url
msgid "Attachment URL"
msgstr "Lien de la pièce jointe"
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_attachment_id
msgid "Attachment id" msgid "Attachment id"
msgstr "ID de la pièce jointe" msgstr "ID de la pièce jointe"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_tree
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_tree
msgid "Attachments" msgid "Attachments"
msgstr "Pièces jointes" msgstr "Pièces jointes"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Binary" msgid "Binary"
msgstr "Binaire" msgstr "Binaire"
#. module: attachment_metadata
#: help:ir.attachment.metadata,type:0
msgid "Binary File or URL"
msgstr "Fichier binaire ou URL"
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_checksum
msgid "Checksum/SHA1"
msgstr "Somme de Contrôle/SHA1"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#: field:ir.attachment.metadata,company_id:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_company_id
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Company" msgid "Company"
msgstr "Société" msgstr "Société"
#. module: attachment_metadata
#: field:ir.attachment.metadata,create_uid:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_create_uid
msgid "Created by" msgid "Created by"
msgstr "Créé par" msgstr "Créé par"
#. module: attachment_metadata
#: field:ir.attachment.metadata,create_date:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_create_date
msgid "Created on" msgid "Created on"
msgstr "Créé le" msgstr "Créé le"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Creation Month" msgid "Creation Month"
msgstr ""
msgstr "Mois de création"
#. module: attachment_metadata
#: field:ir.attachment.metadata,db_datas:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_db_datas
msgid "Database Data" msgid "Database Data"
msgstr "Données de la base de données" msgstr "Données de la base de données"
#. module: attachment_metadata
#: field:ir.attachment.metadata,description:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_description
msgid "Description" msgid "Description"
msgstr "Description" msgstr "Description"
#. module: attachment_metadata
#: field:ir.attachment.metadata,display_name:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_display_name
msgid "Display Name" msgid "Display Name"
msgstr "Nom affiché"
msgstr "Afficher le nom"
#. module: attachment_base_synchronize
#: selection:ir.attachment.metadata,state:0
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Done"
msgstr "Terminé"
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_attachment_improved_form
msgid "Error"
msgstr "Erreur"
#. module: attachment_metadata
#: field:ir.attachment.metadata,external_hash:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_external_hash
msgid "External hash" msgid "External hash"
msgstr "Empreinte externe" msgstr "Empreinte externe"
#. module: attachment_metadata
#: field:ir.attachment.metadata,datas:0
#. module: attachment_base_synchronize
#: selection:ir.attachment.metadata,state:0
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Failed"
msgstr "Échec"
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_datas
msgid "File Content" msgid "File Content"
msgstr "Contenu du fichier" msgstr "Contenu du fichier"
#. module: attachment_metadata
#: field:ir.attachment.metadata,datas_fname:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_datas_fname
msgid "File Name" msgid "File Name"
msgstr "Nom du fichier"
msgstr "Nom de Fichier"
#. module: attachment_metadata
#: field:ir.attachment.metadata,file_size:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_file_size
msgid "File Size" msgid "File Size"
msgstr "Taille du fichier" msgstr "Taille du fichier"
#. module: attachment_metadata
#: code:addons/attachment_metadata/models/attachment.py:43
#. module: attachment_base_synchronize
#: code:addons/attachment_base_synchronize/models/attachment.py:53
#, python-format #, python-format
msgid ""
"File corrupted: Something was wrong with the retrieved file, please relaunch"
" the task."
msgstr "Fichier corrompu: Quelque chose ne va pas lors de la récupération du fichier, veuillez relancer la tâche."
msgid "File corrupted: Something was wrong with the retrieved file, please relaunch the task."
msgstr "Fichier corrompu: Quelque chose s'est mal passé pendant la récupération du fichier, relancez la tache.."
#. module: attachment_metadata
#: help:ir.attachment.metadata,external_hash:0
msgid ""
"File hash comes from the external owner of the file.\n"
#. module: attachment_base_synchronize
#: model:ir.model.fields,help:attachment_base_synchronize.field_ir_attachment_metadata_external_hash
msgid "File hash comes from the external owner of the file.\n"
"If provided allow to check than downloaded file is the exact copy of the original file."
msgstr "File hash comes from the external owner of the file.\n"
"If provided allow to check than downloaded file is the exact copy of the original file." "If provided allow to check than downloaded file is the exact copy of the original file."
msgstr ""
#. module: attachment_metadata
#: help:ir.attachment.metadata,internal_hash:0
msgid ""
"File hash computed with file data to be compared to external hash when "
"provided."
msgstr ""
#. module: attachment_base_synchronize
#: model:ir.model.fields,help:attachment_base_synchronize.field_ir_attachment_metadata_internal_hash
msgid "File hash computed with file data to be compared to external hash when provided."
msgstr "File hash computed with file data to be compared to external hash when provided."
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#: field:ir.attachment.metadata,file_type:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_file_type
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "File type" msgid "File type"
msgstr "Type de fichier" msgstr "Type de fichier"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Filter on my documents" msgid "Filter on my documents"
msgstr "Filtrer sur mes documents" msgstr "Filtrer sur mes documents"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Group By" msgid "Group By"
msgstr "Grouper par"
msgstr "Regrouper par"
#. module: attachment_metadata
#: field:ir.attachment.metadata,id:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_id
msgid "ID" msgid "ID"
msgstr "ID"
msgstr "Identifiant"
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_index_content
msgid "Indexed Content"
msgstr "Contenu Indexé"
#. module: attachment_metadata
#: field:ir.attachment.metadata,internal_hash:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_internal_hash
msgid "Internal hash" msgid "Internal hash"
msgstr "Empreinte interne" msgstr "Empreinte interne"
#. module: attachment_metadata
#: field:ir.attachment.metadata,__last_update:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_public
msgid "Is public document"
msgstr "Est un document public"
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata___last_update
msgid "Last Modified on" msgid "Last Modified on"
msgstr "Dernière modification le" msgstr "Dernière modification le"
#. module: attachment_metadata
#: field:ir.attachment.metadata,write_uid:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_write_uid
msgid "Last Updated by" msgid "Last Updated by"
msgstr "Mis à jour par"
msgstr "Dernière mise à jour par"
#. module: attachment_metadata
#: field:ir.attachment.metadata,write_date:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_write_date
msgid "Last Updated on" msgid "Last Updated on"
msgstr "Mis à jour le"
msgstr "Dernière mise à jour le"
#. module: attachment_metadata
#: help:ir.attachment.metadata,attachment_id:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,help:attachment_base_synchronize.field_ir_attachment_metadata_attachment_id
msgid "Link to ir.attachment model " msgid "Link to ir.attachment model "
msgstr "Lien ver le modèle ir.attachment" msgstr "Lien ver le modèle ir.attachment"
#. module: attachment_metadata
#: model:ir.actions.act_window,name:attachment_metadata.action_attachment
#: model:ir.ui.menu,name:attachment_metadata.menu_ir_attachment
#. module: attachment_base_synchronize
#: model:ir.actions.act_window,name:attachment_base_synchronize.action_attachment
#: model:ir.ui.menu,name:attachment_base_synchronize.menu_ir_attachment
msgid "Meta data Attachments" msgid "Meta data Attachments"
msgstr "Méta données des pièces jointes"
msgstr "Meta data Attachments"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_mimetype
msgid "Mime Type"
msgstr "Type Mime"
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "My Document(s)" msgid "My Document(s)"
msgstr "Mes docuement(s)"
msgstr "Mes Documents"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Owner" msgid "Owner"
msgstr "Propriétaire" msgstr "Propriétaire"
#. module: attachment_metadata
#: field:ir.attachment.metadata,res_id:0
#. module: attachment_base_synchronize
#: selection:ir.attachment.metadata,state:0
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Pending"
msgstr "En attente"
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_res_field
msgid "Resource Field"
msgstr "Champ ressource"
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_res_id
msgid "Resource ID" msgid "Resource ID"
msgstr "ID de l'enregistrement" msgstr "ID de l'enregistrement"
#. module: attachment_metadata
#: field:ir.attachment.metadata,res_model:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_res_model
msgid "Resource Model" msgid "Resource Model"
msgstr ""
msgstr "Modèle de la ressource"
#. module: attachment_metadata
#: field:ir.attachment.metadata,res_name:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_res_name
msgid "Resource Name" msgid "Resource Name"
msgstr "Nom de l'enregistrement" msgstr "Nom de l'enregistrement"
#. module: attachment_metadata
#: field:ir.attachment.metadata,store_fname:0
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_attachment_improved_form
msgid "Run"
msgstr "Run"
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_attachment_improved_form
msgid "Set to Done"
msgstr "Marquer comme terminé"
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_state
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "State"
msgstr "État"
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_state_message
msgid "State message"
msgstr "Message"
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_store_fname
msgid "Stored Filename" msgid "Stored Filename"
msgstr "Nom de fichier stocké" msgstr "Nom de fichier stocké"
#. module: attachment_metadata
#: help:ir.attachment.metadata,res_model:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_sync_date
msgid "Sync date"
msgstr "Sync date"
#. module: attachment_base_synchronize
#: model:ir.model.fields,help:attachment_base_synchronize.field_ir_attachment_metadata_res_model
msgid "The database object this attachment will be attached to" msgid "The database object this attachment will be attached to"
msgstr ""
msgstr "L'objet de la base de données auquel cette pièce jointe sera attachée"
#. module: attachment_metadata
#: help:ir.attachment.metadata,file_type:0
msgid ""
"The file type determines an import method to be used to parse and transform "
"data before their import in ERP"
msgstr ""
#. module: attachment_base_synchronize
#: model:ir.model.fields,help:attachment_base_synchronize.field_ir_attachment_metadata_file_type
msgid "The file type determines an import method to be used to parse and transform data before their import in ERP or an export"
msgstr "Le type de fichier détermine la méthode d'import à utiliser pour parser le fichier et transformer les données avant l'import dans l'ERP"
#. module: attachment_metadata
#: help:ir.attachment.metadata,res_id:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,help:attachment_base_synchronize.field_ir_attachment_metadata_res_id
msgid "The record id this is attached to" msgid "The record id this is attached to"
msgstr ""
msgstr "L'identifiant de l'enregistrement qui y est attaché"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#: field:ir.attachment.metadata,type:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_type
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "Type" msgid "Type"
msgstr "Type" msgstr "Type"
#. module: attachment_metadata
#: view:ir.attachment.metadata:attachment_metadata.view_external_attachment_search
#. module: attachment_base_synchronize
#: model:ir.ui.view,arch_db:attachment_base_synchronize.view_external_attachment_search
msgid "URL" msgid "URL"
msgstr "URL" msgstr "URL"
#. module: attachment_metadata
#: field:ir.attachment.metadata,url:0
#. module: attachment_base_synchronize
#: model:ir.model.fields,field_description:attachment_base_synchronize.field_ir_attachment_metadata_url
msgid "Url" msgid "Url"
msgstr "Url" msgstr "Url"
#. module: attachment_base_synchronize
#: model:ir.model.fields,help:attachment_base_synchronize.field_ir_attachment_metadata_type
msgid "You can either upload a file from your computer or copy/paste an internet link to your file"
msgstr "Vous pouvez, soit télécharger un fichier à partir de votre ordinateur soit copier / coller un lien Internet vers votre fichier"
#. module: attachment_base_synchronize
#: model:ir.model,name:attachment_base_synchronize.model_ir_attachment_metadata
msgid "ir.attachment.metadata"
msgstr "ir.attachment.metadata"

26
attachment_base_synchronize/models/attachment.py

@ -4,7 +4,7 @@
from openerp import models, fields, api, _ from openerp import models, fields, api, _
from openerp.exceptions import Warning as UserError from openerp.exceptions import Warning as UserError
from openerp import sql_db
import openerp
import hashlib import hashlib
from base64 import b64decode from base64 import b64decode
import logging import logging
@ -15,6 +15,7 @@ _logger = logging.getLogger(__name__)
class IrAttachmentMetadata(models.Model): class IrAttachmentMetadata(models.Model):
_name = 'ir.attachment.metadata' _name = 'ir.attachment.metadata'
_inherits = {'ir.attachment': 'attachment_id'} _inherits = {'ir.attachment': 'attachment_id'}
_inherit = ['mail.thread']
internal_hash = fields.Char( internal_hash = fields.Char(
store=True, compute='_compute_hash', store=True, compute='_compute_hash',
@ -68,26 +69,25 @@ class IrAttachmentMetadata(models.Model):
Run the process for each attachment metadata Run the process for each attachment metadata
""" """
for attachment in self: for attachment in self:
new_cr = sql_db.db_connect(self.env.cr.dbname).cursor()
with api.Environment.manage(): with api.Environment.manage():
attachment.env = api.Environment(new_cr, self.env.uid,
self.env.context)
with openerp.registry(self.env.cr.dbname).cursor() as new_cr:
new_env = api.Environment(
new_cr, self.env.uid, self.env.context)
attach = attachment.with_env(new_env)
try: try:
attachment._run()
attach._run()
except Exception, e: except Exception, e:
attachment.env.cr.rollback()
attach.env.cr.rollback()
_logger.exception(e) _logger.exception(e)
attachment.write(
attach.write(
{ {
'state': 'failed', 'state': 'failed',
'state_message': unicode(e)
'state_message': e,
}) })
attachment.env.cr.commit()
attach.env.cr.commit()
else: else:
attachment.write({'state': 'done'})
attachment.env.cr.commit()
finally:
attachment.env.cr.close()
attach.write({'state': 'done'})
attach.env.cr.commit()
return True return True
@api.multi @api.multi

Loading…
Cancel
Save