diff --git a/bemade_add_follower_no_sendmail_default/__init__.py b/bemade_add_follower_no_sendmail_default/__init__.py new file mode 100644 index 0000000..02565c9 --- /dev/null +++ b/bemade_add_follower_no_sendmail_default/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +from . import models + + + diff --git a/bemade_add_follower_no_sendmail_default/__manifest__.py b/bemade_add_follower_no_sendmail_default/__manifest__.py new file mode 100644 index 0000000..9f654d9 --- /dev/null +++ b/bemade_add_follower_no_sendmail_default/__manifest__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +{ + "name": "Change default when adding follower", + "version": "15.0.0.0.1", + "category": "Extra Tools", + 'summary': 'Change default when adding follower', + "description": """ + Change default when adding follower + Send mail false by default + """, + "author": "Bemade", + 'website': 'https://www.bemade.org', + "depends": [ + 'mail', + ], + "data": [ + ], + "auto_install": False, + "installable": True, + 'license': 'OPL-1' +} diff --git a/bemade_add_follower_no_sendmail_default/models/__init__.py b/bemade_add_follower_no_sendmail_default/models/__init__.py new file mode 100644 index 0000000..cd332dd --- /dev/null +++ b/bemade_add_follower_no_sendmail_default/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import mail_wizard_invite diff --git a/bemade_add_follower_no_sendmail_default/models/mail_wizard_invite.py b/bemade_add_follower_no_sendmail_default/models/mail_wizard_invite.py new file mode 100644 index 0000000..986fde3 --- /dev/null +++ b/bemade_add_follower_no_sendmail_default/models/mail_wizard_invite.py @@ -0,0 +1,8 @@ +# Copyright Bemade.org +from odoo import models, fields, api + + +class MailWizardInviteDefault(models.TransientModel): + _inherit = 'mail.wizard.invite' + + send_mail = fields.Boolean(default=False, help="If true, an invitation email will be sent to the recipient") diff --git a/bemade_attachments_cleanup/__init__.py b/bemade_attachments_cleanup/__init__.py new file mode 100644 index 0000000..4027237 --- /dev/null +++ b/bemade_attachments_cleanup/__init__.py @@ -0,0 +1 @@ +from . import wizard diff --git a/bemade_attachments_cleanup/__manifest__.py b/bemade_attachments_cleanup/__manifest__.py new file mode 100644 index 0000000..2d18b49 --- /dev/null +++ b/bemade_attachments_cleanup/__manifest__.py @@ -0,0 +1,22 @@ +{ + 'name': "Attachment Cleanup", + 'version': '1.0.1', + 'author': "Bemade", + 'website': "http://www.bemade.org", + 'category': 'Tools', + 'license': 'OPL-1', + 'summary': "Find and delete missing attachments", + 'description': """ + This module adds a wizard in the settings menu to find and delete missing attachments. + The wizard lists all attachments that are not found in the filestore, and allows the user to select and delete them. + Please use this tool with caution, as deleting attachments cannot be undone. + """, + 'depends': ['base'], + 'data': [ + 'wizard/attachment_cleanup_wizard_view.xml', + 'security/ir.model.access.csv', + + ], + 'installable': True, + 'application': False, +} diff --git a/bemade_attachments_cleanup/i18n/fr_CA.po b/bemade_attachments_cleanup/i18n/fr_CA.po new file mode 100644 index 0000000..5b3b39b --- /dev/null +++ b/bemade_attachments_cleanup/i18n/fr_CA.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * attachment_cleanup +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-06-08 12:00+0000\n" +"PO-Revision-Date: 2023-06-08 12:00+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: fr_CA\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" + +#. module: attachment_cleanup +#: model:ir.actions.act_window,name:attachment_cleanup.action_open_attachment_cleanup_wizard +msgid "Cleanup Attachments" +msgstr "Nettoyer les pièces jointes" + +#. module: attachment_cleanup +#: model:ir.ui.view,arch_db:attachment_cleanup.view_attachment_cleanup_wizard +msgid "Delete" +msgstr "Supprimer" + +#. module: attachment_cleanup +#: model:ir.ui.view,arch_db:attachment_cleanup.view_attachment_cleanup_wizard +msgid "Cancel" +msgstr "Annuler" + +#. module: attachment_cleanup +#: model:ir.model.fields,field_description:attachment_cleanup.field_attachment_cleanup_wizard_attachment_ids +msgid "Missing Attachments" +msgstr "Pièces jointes manquantes" diff --git a/bemade_attachments_cleanup/security/ir.model.access.csv b/bemade_attachments_cleanup/security/ir.model.access.csv new file mode 100644 index 0000000..735f299 --- /dev/null +++ b/bemade_attachments_cleanup/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_attachment_cleanup_wizard,access.attachment.cleanup.wizard,model_attachment_cleanup_wizard,base.group_system,1,1,1,1 diff --git a/bemade_attachments_cleanup/wizard/__init__.py b/bemade_attachments_cleanup/wizard/__init__.py new file mode 100644 index 0000000..c5856e0 --- /dev/null +++ b/bemade_attachments_cleanup/wizard/__init__.py @@ -0,0 +1 @@ +from . import attachment_cleanup_wizard diff --git a/bemade_attachments_cleanup/wizard/attachment_cleanup_wizard.py b/bemade_attachments_cleanup/wizard/attachment_cleanup_wizard.py new file mode 100644 index 0000000..f2446a3 --- /dev/null +++ b/bemade_attachments_cleanup/wizard/attachment_cleanup_wizard.py @@ -0,0 +1,45 @@ +from odoo import api, fields, models +import os + + +class AttachmentCleanupWizard(models.TransientModel): + _name = 'attachment.cleanup.wizard' + _description = 'Attachment Cleanup Wizard' + + attachment_ids = fields.Many2many( + 'ir.attachment', + string='Missing Attachments', + readonly=True, + help='Attachments that are not found in the filestore' + ) + + @api.model + def default_get(self, fields_list): + res = super(AttachmentCleanupWizard, self).default_get(fields_list) + + attachments_1 = self.sudo().env['ir.attachment'].search([]) + + self._cr.execute("SELECT id FROM ir_attachment WHERE company_id = %s", (self.env.company.id,)) + + attachments = self._cr.fetchall() + + filestore_location = self.env['ir.attachment']._filestore() + + missing_attachments = [] + for attachment_id in attachments: + # if attachment.id == 47984: + # print(attachment.store_fname) + attachment = self.env['ir.attachment'].browse(attachment_id) + + if attachment.store_fname: + file_path = os.path.join(filestore_location, attachment.store_fname) + if not os.path.exists(file_path): + missing_attachments.append(attachment.id) + + if missing_attachments: + res.update({'attachment_ids': [(6, 0, missing_attachments)]}) + return res + + def action_cleanup_attachments(self): + self.ensure_one() + self.attachment_ids.unlink() diff --git a/bemade_attachments_cleanup/wizard/attachment_cleanup_wizard_view.xml b/bemade_attachments_cleanup/wizard/attachment_cleanup_wizard_view.xml new file mode 100644 index 0000000..b652785 --- /dev/null +++ b/bemade_attachments_cleanup/wizard/attachment_cleanup_wizard_view.xml @@ -0,0 +1,32 @@ + + + attachment.cleanup.wizard.view + attachment.cleanup.wizard + +
+ + + + + + + + +