Skip to content

Commit a401c41

Browse files
author
mtr
committed
[IMP] account,account_cancel:removed the field 'Allow Cancelling Entries' only from the view
bzr revid: mtr@mtr-20100610053551-35ipuzl82v2ra9is
1 parent fe1c791 commit a401c41

File tree

7 files changed

+19
-82
lines changed

7 files changed

+19
-82
lines changed

addons/account/account.py

+9
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ class account_journal(osv.osv):
572572
'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"),
573573
'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"),
574574
'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."),
575+
'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"),
575576
'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."),
576577
'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="The sequence gives the display order for a list of journals", required=True),
577578
'user_id': fields.many2one('res.users', 'User', help="The user responsible for this journal"),
@@ -994,6 +995,14 @@ def post(self, cr, uid, ids, context=None):
994995

995996
def button_validate(self, cursor, user, ids, context=None):
996997
return self.post(cursor, user, ids, context=context)
998+
999+
def button_cancel(self, cr, uid, ids, context={}):
1000+
for line in self.browse(cr, uid, ids, context):
1001+
if not line.journal_id.update_posted:
1002+
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.'))
1003+
if len(ids):
1004+
cr.execute('update account_move set state=%s where id =ANY(%s)',('draft',ids,))
1005+
return True
9971006

9981007
def write(self, cr, uid, ids, vals, context={}):
9991008
c = context.copy()

addons/account/account_view.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
<field name="group_invoice_lines"/>
318318
</group>
319319
</page>
320-
<page string="Entry Controls">
320+
<page string="Entry Controls" groups="base.group_extended">
321321
<separator colspan="4" string="Accounts Type Allowed (empty for no control)"/>
322322
<field colspan="4" name="type_control_ids" nolabel="1"/>
323323
<separator colspan="4" string="Accounts Allowed (empty for no control)"/>

addons/account/invoice.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,13 @@ def action_cancel(self, cr, uid, ids, *args):
923923
account_move_obj = self.pool.get('account.move')
924924
invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
925925
for i in invoices:
926-
if i['payment_ids']:
926+
if i['move_id']:
927+
account_move_obj.button_cancel(cr, uid, [i['move_id'][0]])
928+
# delete the move this invoice was pointing to
929+
# Note that the corresponding move_lines and move_reconciles
930+
# will be automatically deleted too
931+
account_move_obj.unlink(cr, uid, [i['move_id'][0]])
932+
if i['payment_ids']:
927933
account_move_line_obj = self.pool.get('account.move.line')
928934
pay_ids = account_move_line_obj.browse(cr, uid , i['payment_ids'])
929935
for move_line in pay_ids:

addons/account_cancel/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@
1919
#
2020
##############################################################################
2121

22-
import account_cancel
23-
2422
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2523

addons/account_cancel/__openerp__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"depends" : ["account"],
2727
"author" : "Tiny",
2828
"category": 'Generic Modules/Accounting',
29-
"description": """account_cancel module covers:
30-
the cancellation of accounting entries and invoices""",
29+
"description": """It covers the cancellation of accounting entries and invoices""",
3130
'website': 'http://www.openerp.com',
3231
'init_xml': [],
3332
'update_xml': ['account_cancel_view.xml' ],

addons/account_cancel/account_cancel.py

-63
This file was deleted.

addons/account_cancel/account_cancel_view.xml

+1-13
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,5 @@
1212
</xpath>
1313
</field>
1414
</record>
15-
16-
<record id="view_move_form_inherit" model="ir.ui.view">
17-
<field name="name">account.move.form</field>
18-
<field name="model">account.move</field>
19-
<field name="type">form</field>
20-
<field name="inherit_id" ref="account.view_move_form"/>
21-
<field name="arch" type="xml">
22-
<xpath expr="/form/notebook/page[@string='Journal Entries Lines']/group/button[@name='button_validate']" position="after">
23-
<button name="button_cancel" states="posted" string="Cancel" type="object" icon="gtk-cancel"/>
24-
</xpath>
25-
</field>
26-
</record>
27-
</data>
15+
</data>
2816
</openerp>

0 commit comments

Comments
 (0)