mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX] regarding comment from Alexandre Fayolle @ camptocamp
This commit is contained in:
@@ -6,30 +6,22 @@
|
|||||||
#
|
#
|
||||||
# Author : Vincent Renaville (Camptocamp)
|
# Author : Vincent Renaville (Camptocamp)
|
||||||
#
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# WARNING: This program as such is intended to be used by professional
|
# it under the terms of the GNU Affero General Public License as
|
||||||
# programmers who take the whole responsability of assessing all potential
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
# consequences resulting from its eventual inadequacies and bugs
|
# License, or (at your option) any later version.
|
||||||
# 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,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
import account
|
import account
|
||||||
import account_bank_statement
|
import account_bank_statement
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|||||||
@@ -6,27 +6,18 @@
|
|||||||
#
|
#
|
||||||
# Author : Vincent Renaville (Camptocamp)
|
# Author : Vincent Renaville (Camptocamp)
|
||||||
#
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# WARNING: This program as such is intended to be used by professional
|
# it under the terms of the GNU Affero General Public License as
|
||||||
# programmers who take the whole responsability of assessing all potential
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
# consequences resulting from its eventual inadequacies and bugs
|
# License, or (at your option) any later version.
|
||||||
# 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,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
|||||||
@@ -6,64 +6,60 @@
|
|||||||
#
|
#
|
||||||
# Author : Vincent Renaville (Camptocamp)
|
# Author : Vincent Renaville (Camptocamp)
|
||||||
#
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# WARNING: This program as such is intended to be used by professional
|
# it under the terms of the GNU Affero General Public License as
|
||||||
# programmers who take the whole responsability of assessing all potential
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
# consequences resulting from its eventual inadequacies and bugs
|
# License, or (at your option) any later version.
|
||||||
# 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,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from osv import osv, fields
|
|
||||||
|
from openerp.osv.orm import TransientModel, fields
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
|
|
||||||
class account_move(osv.osv):
|
class account_move(TransientModel):
|
||||||
_inherit = "account.move"
|
_inherit = "account.move"
|
||||||
|
|
||||||
def post(self, cr, uid, ids, context=None):
|
def post(self, cr, uid, ids, context=None):
|
||||||
return_value = super(account_move,self).post(cr, uid, ids, context)
|
return_value = super(account_move,self).post(cr, uid, ids, context)
|
||||||
if return_value:
|
if return_value:
|
||||||
invoice = context.get('invoice', False)
|
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
|
## We test if the move is related to an invoice_id in order to post it with draft status
|
||||||
## in this condition we can cancel a invoice
|
|
||||||
if invoice:
|
if invoice:
|
||||||
valid_moves = self.validate(cr, uid, ids, context)
|
valid_moves = self.validate(cr, uid, ids, context)
|
||||||
if not valid_moves:
|
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 '\
|
cr.execute('UPDATE account_move '\
|
||||||
'SET state=%s '\
|
'SET state=%s '\
|
||||||
'WHERE id IN %s',
|
'WHERE id IN %s',
|
||||||
('draft', tuple(valid_moves),))
|
('draft', tuple(valid_moves),))
|
||||||
return True
|
return return_value
|
||||||
|
|
||||||
def button_cancel(self, cr, uid, ids, context=None):
|
def button_cancel(self, cr, uid, ids, context=None):
|
||||||
for line in self.browse(cr, uid, ids, context=context):
|
for line in self.browse(cr, uid, ids, context=context):
|
||||||
if line.period_id.state == 'done':
|
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
|
## Change the test of line state instead of journal type
|
||||||
elif line.state == 'posted':
|
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:
|
if ids:
|
||||||
cr.execute('UPDATE account_move '\
|
move_obj = self.pool.get('account.move')
|
||||||
'SET state=%s '\
|
move_obj.write(cr, uid, ids, {'state': 'draft'}, context=context)
|
||||||
'WHERE id IN %s', ('draft', tuple(ids),))
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
account_move()
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|||||||
@@ -6,49 +6,35 @@
|
|||||||
#
|
#
|
||||||
# Author : Vincent Renaville (Camptocamp)
|
# Author : Vincent Renaville (Camptocamp)
|
||||||
#
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# WARNING: This program as such is intended to be used by professional
|
# it under the terms of the GNU Affero General Public License as
|
||||||
# programmers who take the whole responsability of assessing all potential
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
# consequences resulting from its eventual inadequacies and bugs
|
# License, or (at your option) any later version.
|
||||||
# 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,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from osv import fields, osv
|
from openerp.osv.orm import TransientModel, fields
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
import decimal_precision as dp
|
|
||||||
|
|
||||||
class account_bank_statement(osv.osv):
|
class account_bank_statement(TransientModel):
|
||||||
_inherit = "account.bank.statement"
|
_inherit = "account.bank.statement"
|
||||||
|
|
||||||
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None):
|
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
|
## We receive the move created for the bank statement, we set it to draft
|
||||||
if return_value:
|
if move_ids:
|
||||||
cr.execute('UPDATE account_move '\
|
move_obj = self.pool.get('account.move')
|
||||||
'SET state=%s '\
|
move_obj.write(cr, uid, move_ids, {'state': 'draft'}, context=context)
|
||||||
'WHERE id = %s', ('draft', (return_value),))
|
return move_ids
|
||||||
return return_value
|
|
||||||
|
|
||||||
|
|
||||||
account_bank_statement()
|
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|||||||
27
account_default_draft_move/i18n/de.po
Normal file
27
account_default_draft_move/i18n/de.po
Normal file
@@ -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"
|
||||||
|
|
||||||
27
account_default_draft_move/i18n/en.po
Normal file
27
account_default_draft_move/i18n/en.po
Normal file
@@ -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"
|
||||||
|
|
||||||
27
account_default_draft_move/i18n/es.po
Normal file
27
account_default_draft_move/i18n/es.po
Normal file
@@ -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"
|
||||||
|
|
||||||
27
account_default_draft_move/i18n/fr.po
Normal file
27
account_default_draft_move/i18n/fr.po
Normal file
@@ -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"
|
||||||
|
|
||||||
Reference in New Issue
Block a user