Add module account_invoice_del_attachment_cancel
Add .gitignore
This commit is contained in:
56
.gitignore
vendored
Normal file
56
.gitignore
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
bin/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
|
||||||
|
# Pycharm
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Mr Developer
|
||||||
|
.mr.developer.cfg
|
||||||
|
.project
|
||||||
|
.pydevproject
|
||||||
|
|
||||||
|
# Rope
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# Backup files
|
||||||
|
*~
|
||||||
|
*.swp
|
||||||
23
account_invoice_del_attachment_cancel/__init__.py
Normal file
23
account_invoice_del_attachment_cancel/__init__.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Account Invoice Del Attachment Cancel module for OpenERP
|
||||||
|
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||||
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
from . import account_invoice
|
||||||
45
account_invoice_del_attachment_cancel/__openerp__.py
Normal file
45
account_invoice_del_attachment_cancel/__openerp__.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Account Invoice Del Attachment Cancel module for OpenERP
|
||||||
|
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||||
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
'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 cancelled',
|
||||||
|
'description': """
|
||||||
|
Account Invoice Delete Attachment on Cancel
|
||||||
|
===========================================
|
||||||
|
|
||||||
|
When an 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 you a user asks for the Invoice report, it will be taken from the attachment.
|
||||||
|
|
||||||
|
With this module, when an invoice is cancelled, the attachment is deleted.
|
||||||
|
|
||||||
|
Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com> for any help or question about this module.
|
||||||
|
""",
|
||||||
|
'author': 'Akretion',
|
||||||
|
'website': 'http://www.akretion.com',
|
||||||
|
'depends': ['account'],
|
||||||
|
'data': [],
|
||||||
|
'installable': True,
|
||||||
|
}
|
||||||
53
account_invoice_del_attachment_cancel/account_invoice.py
Normal file
53
account_invoice_del_attachment_cancel/account_invoice.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Account Invoice Del Attachment Cancel module for OpenERP
|
||||||
|
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||||
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
from openerp.osv import orm
|
||||||
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
|
|
||||||
|
class AccountInvoice(orm.Model):
|
||||||
|
_inherit = 'account.invoice'
|
||||||
|
|
||||||
|
def action_cancel(self, cr, uid, ids, context=None):
|
||||||
|
res = super(AccountInvoice, self).action_cancel(
|
||||||
|
cr, uid, ids, context=context)
|
||||||
|
iao = self.pool['ir.attachment']
|
||||||
|
for invoice in self.browse(cr, uid, ids, context=context):
|
||||||
|
# search for attachments
|
||||||
|
if 'out' in invoice.type:
|
||||||
|
attach_ids = iao.search(
|
||||||
|
cr, uid, [
|
||||||
|
('res_id', '=', invoice.id),
|
||||||
|
('res_model', '=', self._name),
|
||||||
|
('type', '=', 'binary'),
|
||||||
|
('datas_fname', '=like', 'INV%.pdf'),
|
||||||
|
], context=context)
|
||||||
|
if len(attach_ids) == 1:
|
||||||
|
# delete attachment
|
||||||
|
attach = iao.browse(
|
||||||
|
cr, uid, attach_ids[0], context=context)
|
||||||
|
attach_name = attach.name
|
||||||
|
iao.unlink(cr, uid, attach_ids, context=context)
|
||||||
|
self.message_post(
|
||||||
|
cr, uid, invoice.id,
|
||||||
|
_('Attachement %s has been deleted') % attach_name)
|
||||||
|
return res
|
||||||
Reference in New Issue
Block a user