From e92f023fa21c6aff09d68361dad0d1c058f6f2b7 Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Fri, 11 Jan 2013 12:49:27 +0100 Subject: [PATCH 01/11] [ADD] account_default_draft_move : Let move in draft on invoice and bank statement --- account_default_draft_move/__init__.py | 36 ++++++++++ account_default_draft_move/__openerp__.py | 48 +++++++++++++ account_default_draft_move/account.py | 69 +++++++++++++++++++ .../account_bank_statement.py | 54 +++++++++++++++ 4 files changed, 207 insertions(+) create mode 100644 account_default_draft_move/__init__.py create mode 100644 account_default_draft_move/__openerp__.py create mode 100644 account_default_draft_move/account.py create mode 100644 account_default_draft_move/account_bank_statement.py diff --git a/account_default_draft_move/__init__.py b/account_default_draft_move/__init__.py new file mode 100644 index 000000000..b259600c5 --- /dev/null +++ b/account_default_draft_move/__init__.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com) +# All Right Reserved +# +# Author : Vincent Renaville (Camptocamp) +# + +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import account +import account_bank_statement +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/account_default_draft_move/__openerp__.py b/account_default_draft_move/__openerp__.py new file mode 100644 index 000000000..75deb6961 --- /dev/null +++ b/account_default_draft_move/__openerp__.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com) +# All Right Reserved +# +# Author : Vincent Renaville (Camptocamp) +# + +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +{ + "name" : "Move in draft state by default", + "version" : "1.0", + "depends" : ["base", "account"], + "author" : "CamptoCamp", + "description": """Let move in draft on invoice and bank statement + """, + 'website': 'http://www.openerp.com', + 'init_xml': [], + 'update_xml': [ + ], + 'demo_xml': [], + 'installable': True, + 'active': False, +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py new file mode 100644 index 000000000..0eab307d4 --- /dev/null +++ b/account_default_draft_move/account.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com) +# All Right Reserved +# +# Author : Vincent Renaville (Camptocamp) +# + +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +from osv import osv, fields +from tools.translate import _ + +class account_move(osv.osv): + _inherit = "account.move" + + def post(self, cr, uid, ids, context=None): + return_value = super(account_move,self).post(cr, uid, ids, context) + if return_value: + invoice = context.get('invoice', False) + ## We test that we have an invoice in the context, in this case move net to be set to draft + ## in this condition we can cancel a invoice + if invoice: + valid_moves = self.validate(cr, uid, ids, context) + if not valid_moves: + raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured payment terms properly !\nThe latest payment term line should be of the type "Balance" !')) + cr.execute('UPDATE account_move '\ + 'SET state=%s '\ + 'WHERE id IN %s', + ('draft', tuple(valid_moves),)) + return True + + def button_cancel(self, cr, uid, ids, context=None): + for line in self.browse(cr, uid, ids, context=context): + if line.period_id.state == 'done': + raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of closed periods')) + ## Change the test of line state instead of journal type + elif line.state == 'posted': + raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.')) + if ids: + cr.execute('UPDATE account_move '\ + 'SET state=%s '\ + 'WHERE id IN %s', ('draft', tuple(ids),)) + return True + + +account_move() \ No newline at end of file diff --git a/account_default_draft_move/account_bank_statement.py b/account_default_draft_move/account_bank_statement.py new file mode 100644 index 000000000..71e6b5f51 --- /dev/null +++ b/account_default_draft_move/account_bank_statement.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com) +# All Right Reserved +# +# Author : Vincent Renaville (Camptocamp) +# + +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import time + +from osv import fields, osv +from tools.translate import _ +import decimal_precision as dp + +class account_bank_statement(osv.osv): + _inherit = "account.bank.statement" + + def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): + return_value = super(account_bank_statement,self).create_move_from_st_line(cr, uid, st_line_id, company_currency_id, st_line_number, context) + ## We receive the move created for the bank statement, we set it to draft + if return_value: + cr.execute('UPDATE account_move '\ + 'SET state=%s '\ + 'WHERE id = %s', ('draft', (return_value),)) + return return_value + + +account_bank_statement() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 57e73c7da0ac31f8eca456f2f108ea40df1c494a Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Mon, 14 Jan 2013 11:57:17 +0100 Subject: [PATCH 02/11] [FIX] regarding comment from Alexandre Fayolle @ camptocamp --- account_default_draft_move/__init__.py | 30 ++++------ account_default_draft_move/__openerp__.py | 29 ++++------ account_default_draft_move/account.py | 58 +++++++++---------- .../account_bank_statement.py | 48 ++++++--------- account_default_draft_move/i18n/de.po | 27 +++++++++ account_default_draft_move/i18n/en.po | 27 +++++++++ account_default_draft_move/i18n/es.po | 27 +++++++++ account_default_draft_move/i18n/fr.po | 27 +++++++++ 8 files changed, 173 insertions(+), 100 deletions(-) create mode 100644 account_default_draft_move/i18n/de.po create mode 100644 account_default_draft_move/i18n/en.po create mode 100644 account_default_draft_move/i18n/es.po create mode 100644 account_default_draft_move/i18n/fr.po diff --git a/account_default_draft_move/__init__.py b/account_default_draft_move/__init__.py index b259600c5..2e0d691e4 100644 --- a/account_default_draft_move/__init__.py +++ b/account_default_draft_move/__init__.py @@ -6,30 +6,22 @@ # # Author : Vincent Renaville (Camptocamp) # - -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# 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 Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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. # -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # ############################################################################## + import account import account_bank_statement # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_default_draft_move/__openerp__.py b/account_default_draft_move/__openerp__.py index 75deb6961..c2fec8c7e 100644 --- a/account_default_draft_move/__openerp__.py +++ b/account_default_draft_move/__openerp__.py @@ -6,27 +6,18 @@ # # Author : Vincent Renaville (Camptocamp) # - -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# 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 Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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. # -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # ############################################################################## diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py index 0eab307d4..ac19b1273 100644 --- a/account_default_draft_move/account.py +++ b/account_default_draft_move/account.py @@ -6,64 +6,60 @@ # # Author : Vincent Renaville (Camptocamp) # - -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# 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 Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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. # -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # ############################################################################## -from osv import osv, fields + +from openerp.osv.orm import TransientModel, fields from tools.translate import _ -class account_move(osv.osv): +class account_move(TransientModel): _inherit = "account.move" def post(self, cr, uid, ids, context=None): return_value = super(account_move,self).post(cr, uid, ids, context) if return_value: invoice = context.get('invoice', False) - ## We test that we have an invoice in the context, in this case move net to be set to draft - ## in this condition we can cancel a invoice + ## We test if the move is related to an invoice_id in order to post it with draft status if invoice: valid_moves = self.validate(cr, uid, ids, context) if not valid_moves: - raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured payment terms properly !\nThe latest payment term line should be of the type "Balance" !')) + raise osv.except_osv(_('Integrity Error !'), _('''You can not validate a non-balanced entry!\n \ + Make sure you have configured payment terms properly!\n \ + The latest payment term line should be of the type "Balance" !''')) + move_obj = self.pool.get('account.move') + move_obj.write(cr, uid, valid_moves, {'state': 'draft'}, context=context) + cr.execute('UPDATE account_move '\ 'SET state=%s '\ 'WHERE id IN %s', ('draft', tuple(valid_moves),)) - return True + return return_value def button_cancel(self, cr, uid, ids, context=None): for line in self.browse(cr, uid, ids, context=context): if line.period_id.state == 'done': - raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of closed periods')) + raise osv.except_osv(_('Error'), _('You can not modify a posted entry of closed periods')) ## Change the test of line state instead of journal type elif line.state == 'posted': - raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.')) + raise osv.except_osv(_('Error'), _('''You can not modify a posted entry of this journal!\n \ + You should set the journal to allow cancelling entries if you want to do that.''')) if ids: - cr.execute('UPDATE account_move '\ - 'SET state=%s '\ - 'WHERE id IN %s', ('draft', tuple(ids),)) + move_obj = self.pool.get('account.move') + move_obj.write(cr, uid, ids, {'state': 'draft'}, context=context) return True -account_move() \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_default_draft_move/account_bank_statement.py b/account_default_draft_move/account_bank_statement.py index 71e6b5f51..02486f3f9 100644 --- a/account_default_draft_move/account_bank_statement.py +++ b/account_default_draft_move/account_bank_statement.py @@ -6,49 +6,35 @@ # # Author : Vincent Renaville (Camptocamp) # - -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# 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 Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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. # -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # ############################################################################## import time -from osv import fields, osv +from openerp.osv.orm import TransientModel, fields from tools.translate import _ -import decimal_precision as dp -class account_bank_statement(osv.osv): +class account_bank_statement(TransientModel): _inherit = "account.bank.statement" def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): - return_value = super(account_bank_statement,self).create_move_from_st_line(cr, uid, st_line_id, company_currency_id, st_line_number, context) + move_ids = super(account_bank_statement,self).create_move_from_st_line(cr, uid, st_line_id, company_currency_id, st_line_number, context) ## We receive the move created for the bank statement, we set it to draft - if return_value: - cr.execute('UPDATE account_move '\ - 'SET state=%s '\ - 'WHERE id = %s', ('draft', (return_value),)) - return return_value - - -account_bank_statement() + if move_ids: + move_obj = self.pool.get('account.move') + move_obj.write(cr, uid, move_ids, {'state': 'draft'}, context=context) + return move_ids # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_default_draft_move/i18n/de.po b/account_default_draft_move/i18n/de.po new file mode 100644 index 000000000..6c9417f7f --- /dev/null +++ b/account_default_draft_move/i18n/de.po @@ -0,0 +1,27 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_default_draft_move +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-01-14 10:36+0000\n" +"PO-Revision-Date: 2013-01-14 10:36+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_default_draft_move +#: model:ir.model,name:account_default_draft_move.model_account_move +msgid "Account Entry" +msgstr "Account Entry" + +#. module: account_default_draft_move +#: model:ir.model,name:account_default_draft_move.model_account_bank_statement +msgid "Bank Statement" +msgstr "Bank Statement" + diff --git a/account_default_draft_move/i18n/en.po b/account_default_draft_move/i18n/en.po new file mode 100644 index 000000000..6c9417f7f --- /dev/null +++ b/account_default_draft_move/i18n/en.po @@ -0,0 +1,27 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_default_draft_move +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-01-14 10:36+0000\n" +"PO-Revision-Date: 2013-01-14 10:36+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_default_draft_move +#: model:ir.model,name:account_default_draft_move.model_account_move +msgid "Account Entry" +msgstr "Account Entry" + +#. module: account_default_draft_move +#: model:ir.model,name:account_default_draft_move.model_account_bank_statement +msgid "Bank Statement" +msgstr "Bank Statement" + diff --git a/account_default_draft_move/i18n/es.po b/account_default_draft_move/i18n/es.po new file mode 100644 index 000000000..6c9417f7f --- /dev/null +++ b/account_default_draft_move/i18n/es.po @@ -0,0 +1,27 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_default_draft_move +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-01-14 10:36+0000\n" +"PO-Revision-Date: 2013-01-14 10:36+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_default_draft_move +#: model:ir.model,name:account_default_draft_move.model_account_move +msgid "Account Entry" +msgstr "Account Entry" + +#. module: account_default_draft_move +#: model:ir.model,name:account_default_draft_move.model_account_bank_statement +msgid "Bank Statement" +msgstr "Bank Statement" + diff --git a/account_default_draft_move/i18n/fr.po b/account_default_draft_move/i18n/fr.po new file mode 100644 index 000000000..6c9417f7f --- /dev/null +++ b/account_default_draft_move/i18n/fr.po @@ -0,0 +1,27 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_default_draft_move +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-01-14 10:36+0000\n" +"PO-Revision-Date: 2013-01-14 10:36+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_default_draft_move +#: model:ir.model,name:account_default_draft_move.model_account_move +msgid "Account Entry" +msgstr "Account Entry" + +#. module: account_default_draft_move +#: model:ir.model,name:account_default_draft_move.model_account_bank_statement +msgid "Bank Statement" +msgstr "Bank Statement" + From fadd0925c73c513ab51ae83e6a4b5e03c4a5f23b Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Mon, 14 Jan 2013 11:58:42 +0100 Subject: [PATCH 03/11] [FIX] typo --- account_default_draft_move/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py index ac19b1273..c4c05f163 100644 --- a/account_default_draft_move/account.py +++ b/account_default_draft_move/account.py @@ -32,7 +32,7 @@ class account_move(TransientModel): return_value = super(account_move,self).post(cr, uid, ids, context) if return_value: invoice = context.get('invoice', False) - ## We test if the move is related to an invoice_id in order to post it with draft status + ## We test if the move is related to an invoice in order to post it with draft status if invoice: valid_moves = self.validate(cr, uid, ids, context) if not valid_moves: From d4f4442509142c5299f6e0cbe466aad650bdec3d Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Tue, 15 Jan 2013 11:04:11 +0100 Subject: [PATCH 04/11] [FIX] Missing import --- account_default_draft_move/account.py | 1 + 1 file changed, 1 insertion(+) diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py index c4c05f163..c056d77f4 100644 --- a/account_default_draft_move/account.py +++ b/account_default_draft_move/account.py @@ -23,6 +23,7 @@ from openerp.osv.orm import TransientModel, fields +from osv import osv from tools.translate import _ class account_move(TransientModel): From 8964e0a05b535c55584fd75f5fafb660d2f77a2a Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Fri, 18 Jan 2013 09:20:22 +0100 Subject: [PATCH 05/11] [FIX] Correction to fit coding standard --- account_default_draft_move/__init__.py | 13 ++++--------- account_default_draft_move/__openerp__.py | 15 ++++----------- account_default_draft_move/account.py | 16 +++++----------- .../account_bank_statement.py | 19 ++++++++----------- 4 files changed, 21 insertions(+), 42 deletions(-) diff --git a/account_default_draft_move/__init__.py b/account_default_draft_move/__init__.py index 2e0d691e4..57bf09648 100644 --- a/account_default_draft_move/__init__.py +++ b/account_default_draft_move/__init__.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com) -# All Right Reserved -# -# Author : Vincent Renaville (Camptocamp) +# Author Vincent Renaville. Copyright 2012 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 @@ -21,8 +18,6 @@ # ############################################################################## - -import account -import account_bank_statement -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +from . import account +from . import account_bank_statement +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/account_default_draft_move/__openerp__.py b/account_default_draft_move/__openerp__.py index c2fec8c7e..28f503cfc 100644 --- a/account_default_draft_move/__openerp__.py +++ b/account_default_draft_move/__openerp__.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com) -# All Right Reserved -# -# Author : Vincent Renaville (Camptocamp) +# Author Vincent Renaville. Copyright 2012 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 @@ -20,19 +17,15 @@ # along with this program. If not, see . # ############################################################################## - { "name" : "Move in draft state by default", "version" : "1.0", "depends" : ["base", "account"], - "author" : "CamptoCamp", + "author" : "Camptocamp", "description": """Let move in draft on invoice and bank statement """, - 'website': 'http://www.openerp.com', - 'init_xml': [], - 'update_xml': [ - ], - 'demo_xml': [], + 'website': 'http://www.camptocamp.com', + 'data' : [], 'installable': True, 'active': False, } diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py index c056d77f4..464c9ee14 100644 --- a/account_default_draft_move/account.py +++ b/account_default_draft_move/account.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com) -# All Right Reserved -# -# Author : Vincent Renaville (Camptocamp) +# Author Vincent Renaville. Copyright 2012 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 @@ -21,12 +18,11 @@ # ############################################################################## - -from openerp.osv.orm import TransientModel, fields -from osv import osv +from openerp.osv import fields, orm, osv from tools.translate import _ -class account_move(TransientModel): + +class account_move(orm.Model): _inherit = "account.move" def post(self, cr, uid, ids, context=None): @@ -61,6 +57,4 @@ class account_move(TransientModel): move_obj = self.pool.get('account.move') move_obj.write(cr, uid, ids, {'state': 'draft'}, context=context) return True - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/account_default_draft_move/account_bank_statement.py b/account_default_draft_move/account_bank_statement.py index 02486f3f9..ada6141c0 100644 --- a/account_default_draft_move/account_bank_statement.py +++ b/account_default_draft_move/account_bank_statement.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com) -# All Right Reserved -# -# Author : Vincent Renaville (Camptocamp) +# Author Vincent Renaville. Copyright 2012 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 @@ -21,20 +18,20 @@ # ############################################################################## -import time - -from openerp.osv.orm import TransientModel, fields +from openerp.osv import fields, orm from tools.translate import _ -class account_bank_statement(TransientModel): + +class account_bank_statement(orm.Model): _inherit = "account.bank.statement" def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): - move_ids = super(account_bank_statement,self).create_move_from_st_line(cr, uid, st_line_id, company_currency_id, st_line_number, context) + move_ids = super(account_bank_statement,self).create_move_from_st_line(cr, uid, st_line_id, + company_currency_id, + st_line_number, context) ## We receive the move created for the bank statement, we set it to draft if move_ids: move_obj = self.pool.get('account.move') move_obj.write(cr, uid, move_ids, {'state': 'draft'}, context=context) return move_ids - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From 6d75a71721c3c1ac94f9b7f4b7b83b157f6a9d6c Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Fri, 18 Jan 2013 09:46:30 +0100 Subject: [PATCH 06/11] [TYPO] removed exclamation points from error messages --- account_default_draft_move/account.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py index 464c9ee14..93e9554eb 100644 --- a/account_default_draft_move/account.py +++ b/account_default_draft_move/account.py @@ -33,9 +33,9 @@ class account_move(orm.Model): if invoice: valid_moves = self.validate(cr, uid, ids, context) if not valid_moves: - raise osv.except_osv(_('Integrity Error !'), _('''You can not validate a non-balanced entry!\n \ - Make sure you have configured payment terms properly!\n \ - The latest payment term line should be of the type "Balance" !''')) + raise osv.except_osv(_('Integrity Error'), _('''You can not validate a non-balanced entry.\n \ + Make sure you have configured payment terms properly.\n \ + The latest payment term line should be of the type "Balance".''')) move_obj = self.pool.get('account.move') move_obj.write(cr, uid, valid_moves, {'state': 'draft'}, context=context) @@ -51,10 +51,10 @@ class account_move(orm.Model): raise osv.except_osv(_('Error'), _('You can not modify a posted entry of closed periods')) ## Change the test of line state instead of journal type elif line.state == 'posted': - raise osv.except_osv(_('Error'), _('''You can not modify a posted entry of this journal!\n \ + raise osv.except_osv(_('Error'), _('''You can not modify a posted entry of this journal.\n \ You should set the journal to allow cancelling entries if you want to do that.''')) if ids: move_obj = self.pool.get('account.move') move_obj.write(cr, uid, ids, {'state': 'draft'}, context=context) return True -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 7bb515c38e0909c45d71ef5b2e74c6006fd2e310 Mon Sep 17 00:00:00 2001 From: Joel Grand-Guillaume Date: Mon, 21 Jan 2013 15:32:40 +0100 Subject: [PATCH 07/11] [IMP] Change the way moves are set to draft after invoice validation -> Use the same philosophy than in bank-statement rather than using the post method. [DEL] Remove the po file as they are empty. [DOC] Add a clearer description in the module --- account_default_draft_move/__openerp__.py | 29 ++++++++++-- account_default_draft_move/account.py | 46 +++++-------------- .../account_bank_statement.py | 13 +++--- account_default_draft_move/i18n/de.po | 27 ----------- account_default_draft_move/i18n/es.po | 27 ----------- account_default_draft_move/i18n/fr.po | 27 ----------- 6 files changed, 43 insertions(+), 126 deletions(-) delete mode 100644 account_default_draft_move/i18n/de.po delete mode 100644 account_default_draft_move/i18n/es.po delete mode 100644 account_default_draft_move/i18n/fr.po diff --git a/account_default_draft_move/__openerp__.py b/account_default_draft_move/__openerp__.py index 28f503cfc..2c8014408 100644 --- a/account_default_draft_move/__openerp__.py +++ b/account_default_draft_move/__openerp__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author Vincent Renaville. Copyright 2012 Camptocamp SA +# Author Vincent Renaville/Joel Grand-Guillaume. Copyright 2012 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 @@ -15,14 +15,35 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -# ############################################################################## { "name" : "Move in draft state by default", "version" : "1.0", - "depends" : ["base", "account"], + "depends" : ["base", "account", "account_constraints"], "author" : "Camptocamp", - "description": """Let move in draft on invoice and bank statement + 'license': 'AGPL-3', + "description": """ + + Let the generated move in draft on invoice and bank statement validation. The main reason + is to ease the user work day-to-day. At first we used account_cancel, but this module allow + to cancel posted move and that's not allowed. + + Two needs here: + + - We want to be able to cancel an invoice (as soon as move are not validated) without + making a refund. Posted move can't be canceled. + + - We want to ensure all move generated from bank statement and invoice are generated in + draft so we can still change them if needed. + + Use this module with account_constraints (find it here : https://launchpad.net/account-financial-tools + or in apps.openerp.com) and you'll get closely the same feature as account_cancel, + but with th insurance that user won't change posted move. + + The new framework will then be: always work with draft moves, allowing people to change what + they want. At the end of the period, validate all moves. Till there, you ensure no-one can change + something (or they'll need to make a refund). + """, 'website': 'http://www.camptocamp.com', 'data' : [], diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py index 93e9554eb..e10d43e00 100644 --- a/account_default_draft_move/account.py +++ b/account_default_draft_move/account.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author Vincent Renaville. Copyright 2012 Camptocamp SA +# Author Vincent Renaville/Joel Grand-Guillaume. Copyright 2012 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 @@ -15,46 +15,22 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -# ############################################################################## from openerp.osv import fields, orm, osv from tools.translate import _ -class account_move(orm.Model): - _inherit = "account.move" +class AccountInvoice(orm.Model): + _inherit = 'account.invoice' - def post(self, cr, uid, ids, context=None): - return_value = super(account_move,self).post(cr, uid, ids, context) - if return_value: - invoice = context.get('invoice', False) - ## We test if the move is related to an invoice in order to post it with draft status - if invoice: - valid_moves = self.validate(cr, uid, ids, context) - if not valid_moves: - raise osv.except_osv(_('Integrity Error'), _('''You can not validate a non-balanced entry.\n \ - Make sure you have configured payment terms properly.\n \ - The latest payment term line should be of the type "Balance".''')) - move_obj = self.pool.get('account.move') - move_obj.write(cr, uid, valid_moves, {'state': 'draft'}, context=context) + def action_move_create(self, cr, uid, ids, context=None): + """Set move line in draft state after creating them.""" + res = super(AccountInvoice,self).action_move_create(cr, uid, ids, context=context) + move_obj = self.pool.get('account.move') + for inv in self.browse(cr, uid, ids, context=context): + if inv.move_id: + move_obj.write(cr, uid, [inv.move_id.id], {'state': 'draft'}, context=context) + return res - cr.execute('UPDATE account_move '\ - 'SET state=%s '\ - 'WHERE id IN %s', - ('draft', tuple(valid_moves),)) - return return_value - - def button_cancel(self, cr, uid, ids, context=None): - for line in self.browse(cr, uid, ids, context=context): - if line.period_id.state == 'done': - raise osv.except_osv(_('Error'), _('You can not modify a posted entry of closed periods')) - ## Change the test of line state instead of journal type - elif line.state == 'posted': - raise osv.except_osv(_('Error'), _('''You can not modify a posted entry of this journal.\n \ - You should set the journal to allow cancelling entries if you want to do that.''')) - if ids: - move_obj = self.pool.get('account.move') - move_obj.write(cr, uid, ids, {'state': 'draft'}, context=context) - return True # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_default_draft_move/account_bank_statement.py b/account_default_draft_move/account_bank_statement.py index ada6141c0..8ead7acde 100644 --- a/account_default_draft_move/account_bank_statement.py +++ b/account_default_draft_move/account_bank_statement.py @@ -15,23 +15,24 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -# ############################################################################## from openerp.osv import fields, orm from tools.translate import _ -class account_bank_statement(orm.Model): +class AccountBankStatement(orm.Model): _inherit = "account.bank.statement" - def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): - move_ids = super(account_bank_statement,self).create_move_from_st_line(cr, uid, st_line_id, - company_currency_id, - st_line_number, context) + def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, + st_line_number, context=None): + move_ids = super(AccountBankStatement,self).create_move_from_st_line(cr, uid, st_line_id, + company_currency_id, + st_line_number, context) ## We receive the move created for the bank statement, we set it to draft if move_ids: move_obj = self.pool.get('account.move') move_obj.write(cr, uid, move_ids, {'state': 'draft'}, context=context) return move_ids + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/account_default_draft_move/i18n/de.po b/account_default_draft_move/i18n/de.po deleted file mode 100644 index 6c9417f7f..000000000 --- a/account_default_draft_move/i18n/de.po +++ /dev/null @@ -1,27 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * account_default_draft_move -# -msgid "" -msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-01-14 10:36+0000\n" -"PO-Revision-Date: 2013-01-14 10:36+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_default_draft_move -#: model:ir.model,name:account_default_draft_move.model_account_move -msgid "Account Entry" -msgstr "Account Entry" - -#. module: account_default_draft_move -#: model:ir.model,name:account_default_draft_move.model_account_bank_statement -msgid "Bank Statement" -msgstr "Bank Statement" - diff --git a/account_default_draft_move/i18n/es.po b/account_default_draft_move/i18n/es.po deleted file mode 100644 index 6c9417f7f..000000000 --- a/account_default_draft_move/i18n/es.po +++ /dev/null @@ -1,27 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * account_default_draft_move -# -msgid "" -msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-01-14 10:36+0000\n" -"PO-Revision-Date: 2013-01-14 10:36+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_default_draft_move -#: model:ir.model,name:account_default_draft_move.model_account_move -msgid "Account Entry" -msgstr "Account Entry" - -#. module: account_default_draft_move -#: model:ir.model,name:account_default_draft_move.model_account_bank_statement -msgid "Bank Statement" -msgstr "Bank Statement" - diff --git a/account_default_draft_move/i18n/fr.po b/account_default_draft_move/i18n/fr.po deleted file mode 100644 index 6c9417f7f..000000000 --- a/account_default_draft_move/i18n/fr.po +++ /dev/null @@ -1,27 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * account_default_draft_move -# -msgid "" -msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-01-14 10:36+0000\n" -"PO-Revision-Date: 2013-01-14 10:36+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_default_draft_move -#: model:ir.model,name:account_default_draft_move.model_account_move -msgid "Account Entry" -msgstr "Account Entry" - -#. module: account_default_draft_move -#: model:ir.model,name:account_default_draft_move.model_account_bank_statement -msgid "Bank Statement" -msgstr "Bank Statement" - From f89703f27a7481699ee2c64605c56d124fb50dd5 Mon Sep 17 00:00:00 2001 From: Joel Grand-Guillaume Date: Mon, 21 Jan 2013 15:49:48 +0100 Subject: [PATCH 08/11] [FIX] move_ids returned by create_move_from_st_line must be a list. if not make it so --- account_default_draft_move/account_bank_statement.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/account_default_draft_move/account_bank_statement.py b/account_default_draft_move/account_bank_statement.py index 8ead7acde..91499171a 100644 --- a/account_default_draft_move/account_bank_statement.py +++ b/account_default_draft_move/account_bank_statement.py @@ -29,6 +29,8 @@ class AccountBankStatement(orm.Model): move_ids = super(AccountBankStatement,self).create_move_from_st_line(cr, uid, st_line_id, company_currency_id, st_line_number, context) + if not isinstance(move_ids, (tuple, list)): + move_ids = [move_ids] ## We receive the move created for the bank statement, we set it to draft if move_ids: move_obj = self.pool.get('account.move') From f782c75279c783d723bdd1c834203d23e00e59d2 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 28 Jan 2013 10:33:17 +0100 Subject: [PATCH 09/11] [FIX] manifest's description --- account_default_draft_move/__openerp__.py | 46 ++++++++++++----------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/account_default_draft_move/__openerp__.py b/account_default_draft_move/__openerp__.py index 2c8014408..5764a5ce7 100644 --- a/account_default_draft_move/__openerp__.py +++ b/account_default_draft_move/__openerp__.py @@ -23,30 +23,32 @@ "author" : "Camptocamp", 'license': 'AGPL-3', "description": """ - - Let the generated move in draft on invoice and bank statement validation. The main reason - is to ease the user work day-to-day. At first we used account_cancel, but this module allow - to cancel posted move and that's not allowed. - - Two needs here: - - - We want to be able to cancel an invoice (as soon as move are not validated) without - making a refund. Posted move can't be canceled. - - - We want to ensure all move generated from bank statement and invoice are generated in - draft so we can still change them if needed. - - Use this module with account_constraints (find it here : https://launchpad.net/account-financial-tools - or in apps.openerp.com) and you'll get closely the same feature as account_cancel, - but with th insurance that user won't change posted move. - - The new framework will then be: always work with draft moves, allowing people to change what - they want. At the end of the period, validate all moves. Till there, you ensure no-one can change - something (or they'll need to make a refund). - +Let the generated move in draft on invoice and bank statement +validation. The main reason is to ease the user work day-to-day. At +first we used account_cancel, but this module allow to cancel posted +move and that's not allowed. + +Two needs here: + +- We want to be able to cancel an invoice (as soon as move are not + validated) without making a refund. Posted move can't be canceled. +- We want to ensure all move generated from bank statement and invoice + are generated in draft so we can still change them if needed. + +Use this module with account_constraints (find it here: +https://launchpad.net/account-financial-tools or in +http://apps.openerp.com) and you'll get closely the same feature as +account_cancel, but with the insurance that user won't change posted +move. + +The new framework will then be: always work with draft moves, allowing +people to change what they want. At the end of the period, validate all +moves. Till there, you ensure no-one can change something (or they'll +need to make a refund). + """, 'website': 'http://www.camptocamp.com', - 'data' : [], + 'data' : [], 'installable': True, 'active': False, } From a112a0abbce63faae85d15791eb4d2b19a004c19 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 28 Jan 2013 10:35:34 +0100 Subject: [PATCH 10/11] [FIX] import from openerp, remove unused import, long lines --- .../account_bank_statement.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/account_default_draft_move/account_bank_statement.py b/account_default_draft_move/account_bank_statement.py index 91499171a..f4d61457d 100644 --- a/account_default_draft_move/account_bank_statement.py +++ b/account_default_draft_move/account_bank_statement.py @@ -17,24 +17,25 @@ # along with this program. If not, see . ############################################################################## -from openerp.osv import fields, orm -from tools.translate import _ +from openerp.osv import orm +from openerp.tools.translate import _ class AccountBankStatement(orm.Model): _inherit = "account.bank.statement" - def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, - st_line_number, context=None): - move_ids = super(AccountBankStatement,self).create_move_from_st_line(cr, uid, st_line_id, - company_currency_id, - st_line_number, context) + def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, + st_line_number, context=None): + move_ids = super(AccountBankStatement,self).create_move_from_st_line( + cr, uid, st_line_id, company_currency_id, + st_line_number, context) if not isinstance(move_ids, (tuple, list)): move_ids = [move_ids] - ## We receive the move created for the bank statement, we set it to draft + # We receive the move created for the bank statement, we set it + # to draft if move_ids: move_obj = self.pool.get('account.move') - move_obj.write(cr, uid, move_ids, {'state': 'draft'}, context=context) + move_obj.write(cr, uid, move_ids, + {'state': 'draft'}, context=context) return move_ids - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From ed33ea768733994f5507c3ff38efb3647c9a8a15 Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Mon, 28 Jan 2013 12:08:35 +0100 Subject: [PATCH 11/11] [FIX] Allow to cancel invoice and bank statement and reconfirm it --- account_default_draft_move/account.py | 18 ++++++++++++++++++ .../account_bank_statement.py | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py index e10d43e00..8a2ee98fb 100644 --- a/account_default_draft_move/account.py +++ b/account_default_draft_move/account.py @@ -33,4 +33,22 @@ class AccountInvoice(orm.Model): move_obj.write(cr, uid, [inv.move_id.id], {'state': 'draft'}, context=context) return res +class AccountMove(orm.Model): + _inherit = 'account.move' + + def button_cancel(self, cr, uid, ids, context=None): + """ We rewrite function button_cancel, to allow invoice or bank statement with linked draft moved + to be canceled """ + for line in self.browse(cr, uid, ids, context=context): + if line.state == 'draft': + continue + else: + if not line.journal_id.update_posted: + raise osv.except_osv(_('Error!'), _('You cannot modify a posted entry of this journal.\nFirst you should set the journal to allow cancelling entries.')) + if ids: + cr.execute('UPDATE account_move '\ + 'SET state=%s '\ + 'WHERE id IN %s', ('draft', tuple(ids),)) + return True + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_default_draft_move/account_bank_statement.py b/account_default_draft_move/account_bank_statement.py index f4d61457d..52aed19d5 100644 --- a/account_default_draft_move/account_bank_statement.py +++ b/account_default_draft_move/account_bank_statement.py @@ -29,6 +29,15 @@ class AccountBankStatement(orm.Model): move_ids = super(AccountBankStatement,self).create_move_from_st_line( cr, uid, st_line_id, company_currency_id, st_line_number, context) + # If a bank statement line is already linked to a voucher + # we received boolean instead of voucher move ids in move_ids + bank_st_line_obj = self.pool.get('account.bank.statement.line') + voucher_obj = self.pool.get('account.voucher') + st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context) + if st_line.voucher_id: + v = voucher_obj.browse(cr, uid, st_line.voucher_id.id, context=context) + move_ids = v.move_id.id + if not isinstance(move_ids, (tuple, list)): move_ids = [move_ids] # We receive the move created for the bank statement, we set it