[IMP] account,account_cancel:removed the field 'Allow Cancelling Entries' only from the view
bzr revid: mtr@mtr-20100610053551-35ipuzl82v2ra9is
This commit is contained in:
parent
fe1c79107b
commit
a401c41180
|
@ -572,6 +572,7 @@ class account_journal(osv.osv):
|
|||
'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]",help="This will act as a default account for credit amount"),
|
||||
'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]",help="This will act as a default account for debit amount"),
|
||||
'centralisation': fields.boolean('Centralised counterpart', help="Check this box to determine that each entry of this journal won't create a new counterpart but will share the same counterpart. This is used in fiscal year closing."),
|
||||
'update_posted': fields.boolean('Allow Cancelling Entries',help="Check this box if you want to cancel the entries related to this journal or want to cancel the invoice related to this journal"),
|
||||
'group_invoice_lines': fields.boolean('Group invoice lines', help="If this box is checked, the system will try to group the accounting lines when generating them from invoices."),
|
||||
'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="The sequence gives the display order for a list of journals", required=True),
|
||||
'user_id': fields.many2one('res.users', 'User', help="The user responsible for this journal"),
|
||||
|
@ -994,6 +995,14 @@ class account_move(osv.osv):
|
|||
|
||||
def button_validate(self, cursor, user, ids, context=None):
|
||||
return self.post(cursor, user, ids, context=context)
|
||||
|
||||
def button_cancel(self, cr, uid, ids, context={}):
|
||||
for line in self.browse(cr, uid, ids, context):
|
||||
if not line.journal_id.update_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 len(ids):
|
||||
cr.execute('update account_move set state=%s where id =ANY(%s)',('draft',ids,))
|
||||
return True
|
||||
|
||||
def write(self, cr, uid, ids, vals, context={}):
|
||||
c = context.copy()
|
||||
|
|
|
@ -317,7 +317,7 @@
|
|||
<field name="group_invoice_lines"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Entry Controls">
|
||||
<page string="Entry Controls" groups="base.group_extended">
|
||||
<separator colspan="4" string="Accounts Type Allowed (empty for no control)"/>
|
||||
<field colspan="4" name="type_control_ids" nolabel="1"/>
|
||||
<separator colspan="4" string="Accounts Allowed (empty for no control)"/>
|
||||
|
|
|
@ -923,7 +923,13 @@ class account_invoice(osv.osv):
|
|||
account_move_obj = self.pool.get('account.move')
|
||||
invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
|
||||
for i in invoices:
|
||||
if i['payment_ids']:
|
||||
if i['move_id']:
|
||||
account_move_obj.button_cancel(cr, uid, [i['move_id'][0]])
|
||||
# delete the move this invoice was pointing to
|
||||
# Note that the corresponding move_lines and move_reconciles
|
||||
# will be automatically deleted too
|
||||
account_move_obj.unlink(cr, uid, [i['move_id'][0]])
|
||||
if i['payment_ids']:
|
||||
account_move_line_obj = self.pool.get('account.move.line')
|
||||
pay_ids = account_move_line_obj.browse(cr, uid , i['payment_ids'])
|
||||
for move_line in pay_ids:
|
||||
|
|
|
@ -19,7 +19,5 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import account_cancel
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
"depends" : ["account"],
|
||||
"author" : "Tiny",
|
||||
"category": 'Generic Modules/Accounting',
|
||||
"description": """account_cancel module covers:
|
||||
the cancellation of accounting entries and invoices""",
|
||||
"description": """It covers the cancellation of accounting entries and invoices""",
|
||||
'website': 'http://www.openerp.com',
|
||||
'init_xml': [],
|
||||
'update_xml': ['account_cancel_view.xml' ],
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import time
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
class account_journal(osv.osv):
|
||||
_inherit = "account.journal"
|
||||
_columns = {
|
||||
'update_posted': fields.boolean('Allow Cancelling Entries',help="Check this box if you want to cancel the entries related to this journal or want to cancel the invoice related to this journal")
|
||||
}
|
||||
|
||||
account_journal()
|
||||
|
||||
class account_move(osv.osv):
|
||||
_inherit = "account.move"
|
||||
_description = "Account Entry"
|
||||
|
||||
def button_cancel(self, cr, uid, ids, context={}):
|
||||
for line in self.browse(cr, uid, ids, context):
|
||||
if not line.journal_id.update_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 len(ids):
|
||||
cr.execute('update account_move set state=%s where id =ANY(%s)',('draft',ids,))
|
||||
return True
|
||||
|
||||
account_move()
|
||||
|
||||
class account_invoice(osv.osv):
|
||||
_inherit = "account.invoice"
|
||||
|
||||
def action_cancel(self, cr, uid, ids, *args):
|
||||
account_move_obj = self.pool.get('account.move')
|
||||
invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
|
||||
for i in invoices:
|
||||
if i['move_id']:
|
||||
account_move_obj.button_cancel(cr, uid, [i['move_id'][0]])
|
||||
# delete the move this invoice was pointing to
|
||||
# Note that the corresponding move_lines and move_reconciles
|
||||
# will be automatically deleted too
|
||||
account_move_obj.unlink(cr, uid, [i['move_id'][0]])
|
||||
return super(account_invoice, self).action_cancel(cr, uid, ids, *args)
|
||||
|
||||
account_invoice()
|
|
@ -12,17 +12,5 @@
|
|||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_move_form_inherit" model="ir.ui.view">
|
||||
<field name="name">account.move.form</field>
|
||||
<field name="model">account.move</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.view_move_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page[@string='Journal Entries Lines']/group/button[@name='button_validate']" position="after">
|
||||
<button name="button_cancel" states="posted" string="Cancel" type="object" icon="gtk-cancel"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue