mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[ADD] account_default_draft_move : Let move in draft on invoice and bank statement
This commit is contained in:
36
account_default_draft_move/__init__.py
Normal file
36
account_default_draft_move/__init__.py
Normal file
@@ -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:
|
||||||
|
|
||||||
48
account_default_draft_move/__openerp__.py
Normal file
48
account_default_draft_move/__openerp__.py
Normal file
@@ -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:
|
||||||
69
account_default_draft_move/account.py
Normal file
69
account_default_draft_move/account.py
Normal file
@@ -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()
|
||||||
54
account_default_draft_move/account_bank_statement.py
Normal file
54
account_default_draft_move/account_bank_statement.py
Normal file
@@ -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:
|
||||||
Reference in New Issue
Block a user