From 3396814a0903e49dc3005b72f80fd7ed33d3dd83 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 2 Mar 2017 09:18:32 +0100 Subject: [PATCH] Remove module account_invoice_del_attachment_cancel (native feature on v10 --- .../__init__.py | 23 -------- .../__manifest__.py | 44 -------------- .../account_invoice.py | 57 ------------------- 3 files changed, 124 deletions(-) delete mode 100644 account_invoice_del_attachment_cancel/__init__.py delete mode 100644 account_invoice_del_attachment_cancel/__manifest__.py delete mode 100644 account_invoice_del_attachment_cancel/account_invoice.py diff --git a/account_invoice_del_attachment_cancel/__init__.py b/account_invoice_del_attachment_cancel/__init__.py deleted file mode 100644 index f391d3e..0000000 --- a/account_invoice_del_attachment_cancel/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Account Invoice Del Attachment Cancel module for OpenERP -# Copyright (C) 2015 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from . import account_invoice diff --git a/account_invoice_del_attachment_cancel/__manifest__.py b/account_invoice_del_attachment_cancel/__manifest__.py deleted file mode 100644 index 4f04e10..0000000 --- a/account_invoice_del_attachment_cancel/__manifest__.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Account Invoice Del Attachment Cancel module for Odoo -# Copyright (C) 2015 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - - -{ - 'name': 'Account Invoice Delete Attachment on Cancel', - 'version': '0.1', - 'category': 'Accounting & Finance', - 'license': 'AGPL-3', - 'summary': 'Delete the attachment on the invoice when it is set back to draft', - 'description': """ -Account Invoice Delete Attachment on Cancel -=========================================== - -When a customer invoice is validated, on the first generation of the invoice report, a copy of the report is stored as attachment on the invoice. After that, every time a user asks for the Invoice report, it will be taken from the attachment. But, when a customer invoice/refund is cancelled, set back to draft, modified and re-validated, the Invoice report is still the old PDF file, which is often raised as a bug by the users. - -With this module, when a customer invoice/refund is set back to draft, the attachment is deleted. - -This module has been written by Alexis de Lattre from Akretion . - """, - 'author': 'Akretion', - 'website': 'http://www.akretion.com', - 'depends': ['account'], - 'installable': False, -} diff --git a/account_invoice_del_attachment_cancel/account_invoice.py b/account_invoice_del_attachment_cancel/account_invoice.py deleted file mode 100644 index 3861d7c..0000000 --- a/account_invoice_del_attachment_cancel/account_invoice.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Account Invoice Del Attachment Cancel module for Odoo -# Copyright (C) 2015 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp import models, api, _ - - -class AccountInvoice(models.Model): - _inherit = 'account.invoice' - - @api.multi - def invoice_filename_to_match(self): - return 'INV%.pdf' - - @api.multi - def action_cancel_draft(self): - res = super(AccountInvoice, self).action_cancel_draft() - iao = self.env['ir.attachment'] - for invoice in self: - # search for attachments - if 'out' in invoice.type: - filename_to_match = invoice.invoice_filename_to_match() - attachs = iao.search([ - ('res_id', '=', invoice.id), - ('res_model', '=', self._name), - ('type', '=', 'binary'), - ('datas_fname', '=like', filename_to_match), - ]) - if len(attachs) == 1: - # delete attachment - attach = attachs[0] - attach_name = attach.name - # I need sudo() because the user that has the right to - # do a "back2draft" on an invoice may not have the right - # to delete an account.invoice - attachs.sudo().unlink() - invoice.message_post( - _('Attachement %s has been deleted') % attach_name) - return res