From 3916c59f88533b493500ea38bbffe156a33c3fad Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 25 Jun 2015 09:16:41 +0200 Subject: [PATCH] [ADD] locking move module --- account_move_locking/README.rst | 52 ++++++++ account_move_locking/__init__.py | 21 ++++ account_move_locking/__openerp__.py | 31 +++++ account_move_locking/account.py | 53 ++++++++ account_move_locking/account_view.xml | 16 +++ .../i18n/account_move_locking.pot | 116 ++++++++++++++++++ account_move_locking/i18n/fr.po | 116 ++++++++++++++++++ account_move_locking/wizard/__init__.py | 21 ++++ .../wizard/account_lock_account_move.py | 62 ++++++++++ .../wizard/account_lock_move_view.xml | 41 +++++++ 10 files changed, 529 insertions(+) create mode 100644 account_move_locking/README.rst create mode 100644 account_move_locking/__init__.py create mode 100644 account_move_locking/__openerp__.py create mode 100644 account_move_locking/account.py create mode 100644 account_move_locking/account_view.xml create mode 100644 account_move_locking/i18n/account_move_locking.pot create mode 100644 account_move_locking/i18n/fr.po create mode 100644 account_move_locking/wizard/__init__.py create mode 100644 account_move_locking/wizard/account_lock_account_move.py create mode 100644 account_move_locking/wizard/account_lock_move_view.xml diff --git a/account_move_locking/README.rst b/account_move_locking/README.rst new file mode 100644 index 000000000..bb90786b0 --- /dev/null +++ b/account_move_locking/README.rst @@ -0,0 +1,52 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Module name +=========== + +This module add the ability to lock move for modification + +Configuration +============= + + + +Usage +===== +In order the locked the move you need to follow this process + * You need to post your move, with the standard wizard Post Journal Entries + (Invoicing -> Periodic Processing -> Draft Entries -> Post Journal Entries) + * After the you can use the wizard Lock Journal Entries + (Invoicing -> Periodic Processing -> Draft Entries -> Lock Journal Entries) + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + + +Credits +======= + +Contributors +------------ + +* Vincent renaville + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/account_move_locking/__init__.py b/account_move_locking/__init__.py new file mode 100644 index 000000000..e0df21635 --- /dev/null +++ b/account_move_locking/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Vincent Renaville. Copyright 2015 Camptocamp SA +# +# 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 +from . import wizard diff --git a/account_move_locking/__openerp__.py b/account_move_locking/__openerp__.py new file mode 100644 index 000000000..c832a9a87 --- /dev/null +++ b/account_move_locking/__openerp__.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Vincent Renaville. +# Copyright 2015 Camptocamp SA +# +# 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": "Move locked to prevent modification", + "version": "1.0", + "depends": ["base", "account"], + "author": "Camptocamp,Odoo Community Association (OCA)", + 'license': 'AGPL-3', + 'website': 'http://www.camptocamp.com', + 'data': ['account_view.xml', + 'wizard/account_lock_move_view.xml'], + 'installable': True, +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_move_locking/account.py b/account_move_locking/account.py new file mode 100644 index 000000000..3e1956eac --- /dev/null +++ b/account_move_locking/account.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Vincent Renaville. +# Copyright 2015 Camptocamp SA +# +# 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, fields, api, exceptions, _ + + +class AccountMove(models.Model): + _inherit = 'account.move' + + locked = fields.Boolean('Locked', readonly=True) + + @api.multi + def write(self, vals): + for move in self: + if move.locked: + raise exceptions.Warning(_('Move Locked!'), + move.name) + return super(AccountMove, self).write(vals) + + @api.multi + def unlink(self): + for move in self: + if move.locked: + raise exceptions.Warning(_('Move Locked!'), + move.name) + return super(AccountMove, self).unlink() + + @api.multi + def button_cancel(self): + # Cancel a move was done directly in SQL + # so we need to test manualy if the move is locked + for move in self: + if move.locked: + raise exceptions.Warning(_('Move Locked!'), + move.name) + return super(AccountMove, self).button_cancel() diff --git a/account_move_locking/account_view.xml b/account_move_locking/account_view.xml new file mode 100644 index 000000000..cbcebb132 --- /dev/null +++ b/account_move_locking/account_view.xml @@ -0,0 +1,16 @@ + + + + + account.move.form.locked + account.move + + + + + + + + + + \ No newline at end of file diff --git a/account_move_locking/i18n/account_move_locking.pot b/account_move_locking/i18n/account_move_locking.pot new file mode 100644 index 000000000..f330edb07 --- /dev/null +++ b/account_move_locking/i18n/account_move_locking.pot @@ -0,0 +1,116 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_locking +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-25 06:47+0000\n" +"PO-Revision-Date: 2015-06-25 06:47+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_move_locking +#: model:ir.model,name:account_move_locking.model_account_move +msgid "Account Entry" +msgstr "" + +#. module: account_move_locking +#: view:lock.account.move:account_move_locking.lock_account_move_view +msgid "Approve" +msgstr "" + +#. module: account_move_locking +#: view:lock.account.move:account_move_locking.lock_account_move_view +msgid "Cancel" +msgstr "" + +#. module: account_move_locking +#: field:lock.account.move,create_uid:0 +msgid "Created by" +msgstr "" + +#. module: account_move_locking +#: field:lock.account.move,create_date:0 +msgid "Created on" +msgstr "" + +#. module: account_move_locking +#: field:lock.account.move,id:0 +msgid "ID" +msgstr "" + +#. module: account_move_locking +#: field:lock.account.move,journal_ids:0 +msgid "Journal" +msgstr "" + +#. module: account_move_locking +#: field:lock.account.move,write_uid:0 +msgid "Last Updated by" +msgstr "" + +#. module: account_move_locking +#: field:lock.account.move,write_date:0 +msgid "Last Updated on" +msgstr "" + +#. module: account_move_locking +#: model:ir.model,name:account_move_locking.model_lock_account_move +msgid "Lock Account Move" +msgstr "" + +#. module: account_move_locking +#: model:ir.actions.act_window,name:account_move_locking.action_lock_account_move +#: model:ir.ui.menu,name:account_move_locking.menu_lock_account_moves +#: view:lock.account.move:account_move_locking.lock_account_move_view +msgid "Lock Journal Entries" +msgstr "" + +#. module: account_move_locking +#: field:account.move,locked:0 +msgid "Locked" +msgstr "" + +#. module: account_move_locking +#: code:addons/account_move_locking/account.py:33 +#: code:addons/account_move_locking/account.py:41 +#: code:addons/account_move_locking/account.py:51 +#, python-format +msgid "Move Locked!" +msgstr "" + +#. module: account_move_locking +#: code:addons/account_move_locking/wizard/account_lock_account_move.py:49 +#, python-format +msgid "No move to locked found" +msgstr "" + +#. module: account_move_locking +#: field:lock.account.move,period_ids:0 +msgid "Period" +msgstr "" + +#. module: account_move_locking +#: code:addons/account_move_locking/wizard/account_lock_account_move.py:46 +#, python-format +msgid "Unposted move in period/jounal selected, please post it before locking them" +msgstr "" + +#. module: account_move_locking +#: code:addons/account_move_locking/wizard/account_lock_account_move.py:46 +#: code:addons/account_move_locking/wizard/account_lock_account_move.py:49 +#, python-format +msgid "Warning!" +msgstr "" + +#. module: account_move_locking +#: view:lock.account.move:account_move_locking.lock_account_move_view +msgid "or" +msgstr "" + diff --git a/account_move_locking/i18n/fr.po b/account_move_locking/i18n/fr.po new file mode 100644 index 000000000..33c7cf59a --- /dev/null +++ b/account_move_locking/i18n/fr.po @@ -0,0 +1,116 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_locking +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-25 06:47+0000\n" +"PO-Revision-Date: 2015-06-25 06:47+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_move_locking +#: model:ir.model,name:account_move_locking.model_account_move +msgid "Account Entry" +msgstr "Entrée comptable" + +#. module: account_move_locking +#: view:lock.account.move:account_move_locking.lock_account_move_view +msgid "Approve" +msgstr "Valider" + +#. module: account_move_locking +#: view:lock.account.move:account_move_locking.lock_account_move_view +msgid "Cancel" +msgstr "Annuler" + +#. module: account_move_locking +#: field:lock.account.move,create_uid:0 +msgid "Created by" +msgstr "Créé par" + +#. module: account_move_locking +#: field:lock.account.move,create_date:0 +msgid "Created on" +msgstr "Créé le" + +#. module: account_move_locking +#: field:lock.account.move,id:0 +msgid "ID" +msgstr "ID" + +#. module: account_move_locking +#: field:lock.account.move,journal_ids:0 +msgid "Journal" +msgstr "Journal" + +#. module: account_move_locking +#: field:lock.account.move,write_uid:0 +msgid "Last Updated by" +msgstr "Dernière modification par" + +#. module: account_move_locking +#: field:lock.account.move,write_date:0 +msgid "Last Updated on" +msgstr "Dernière modification le" + +#. module: account_move_locking +#: model:ir.model,name:account_move_locking.model_lock_account_move +msgid "Lock Account Move" +msgstr "Verrouiller mouvement comptable" + +#. module: account_move_locking +#: model:ir.actions.act_window,name:account_move_locking.action_lock_account_move +#: model:ir.ui.menu,name:account_move_locking.menu_lock_account_moves +#: view:lock.account.move:account_move_locking.lock_account_move_view +msgid "Lock Journal Entries" +msgstr "Verrouiler les écritues comptables" + +#. module: account_move_locking +#: field:account.move,locked:0 +msgid "Locked" +msgstr "Verouillé" + +#. module: account_move_locking +#: code:addons/account_move_locking/account.py:33 +#: code:addons/account_move_locking/account.py:41 +#: code:addons/account_move_locking/account.py:51 +#, python-format +msgid "Move Locked!" +msgstr "Ecriture verrouillée" + +#. module: account_move_locking +#: code:addons/account_move_locking/wizard/account_lock_account_move.py:49 +#, python-format +msgid "No move to locked found" +msgstr "Pas d'écriture à verrouiller" + +#. module: account_move_locking +#: field:lock.account.move,period_ids:0 +msgid "Period" +msgstr "Période" + +#. module: account_move_locking +#: code:addons/account_move_locking/wizard/account_lock_account_move.py:46 +#, python-format +msgid "Unposted move in period/jounal selected, please post it before locking them" +msgstr "Ecritures non postées dans la sélection journal/période, Il faut poster les écritures avant de les verrouiller" + +#. module: account_move_locking +#: code:addons/account_move_locking/wizard/account_lock_account_move.py:46 +#: code:addons/account_move_locking/wizard/account_lock_account_move.py:49 +#, python-format +msgid "Warning!" +msgstr "Attention!" + +#. module: account_move_locking +#: view:lock.account.move:account_move_locking.lock_account_move_view +msgid "or" +msgstr "ou" + diff --git a/account_move_locking/wizard/__init__.py b/account_move_locking/wizard/__init__.py new file mode 100644 index 000000000..648d27324 --- /dev/null +++ b/account_move_locking/wizard/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Vincent Renaville. +# Copyright 2015 Camptocamp SA +# +# 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_lock_account_move diff --git a/account_move_locking/wizard/account_lock_account_move.py b/account_move_locking/wizard/account_lock_account_move.py new file mode 100644 index 000000000..6a2e554fd --- /dev/null +++ b/account_move_locking/wizard/account_lock_account_move.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Vincent Renaville. +# Copyright 2015 Camptocamp SA +# +# 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 fields, models, api, _, exceptions + + +class lock_account_move(models.TransientModel): + _name = "lock.account.move" + _description = "Lock Account Move" + + journal_ids = fields.Many2many('account.journal', + rel='wizard_lock_account_move_journal', + string='Journal', + required=True) + period_ids = fields.Many2many('account.period', + rel='wizard_lock_account_move_period', + string='Period', + required=True, + domain=[('state', '<>', 'done')]) + + @api.multi + def lock_move(self, data): + obj_move = self.env['account.move'] + draft_move = obj_move.search([('state', '=', 'draft'), + ('journal_id', + 'in', + self.journal_ids.ids), + ('period_id', 'in', + self.period_ids.ids)], + order='date') + if draft_move: + raise exceptions.Warning(_('Warning!'), + _('Unposted move in period/jounal \ + selected, please post it before \ + locking them')) + move = obj_move.search([('state', '=', 'posted'), + ('locked', '=', False), + ('journal_id', 'in', self.journal_ids.ids), + ('period_id', 'in', self.period_ids.ids)], + order='date') + if not move: + raise exceptions.Warning(_('Warning!'), + _('No move to locked found')) + move.write({'locked': True}) + return {'type': 'ir.actions.act_window_close'} diff --git a/account_move_locking/wizard/account_lock_move_view.xml b/account_move_locking/wizard/account_lock_move_view.xml new file mode 100644 index 000000000..823072932 --- /dev/null +++ b/account_move_locking/wizard/account_lock_move_view.xml @@ -0,0 +1,41 @@ + + + + + + + lock Journal Entries + lock.account.move + +
+ + + + +
+
+
+
+
+ + + Lock Journal Entries + lock.account.move + form + form + + new + + + + +
+