[MERGE] Account: action_cancel on invoice method fixed , add active field with extend group on account (XRG branch)

bzr revid: mra@mra-laptop-20110106054309-9hkqjfg9b72oqfym
This commit is contained in:
Mustufa Rangwala 2011-01-06 11:13:09 +05:30
commit cc162e066c
3 changed files with 13 additions and 5 deletions

View File

@ -2,6 +2,7 @@
<openerp>
<data>
<report auto="False" id="account_general_ledger" menu="False" model="account.account" name="account.general.ledger" rml="account/report/account_general_ledger.rml" string="General Ledger"/>
<report auto="False" id="account_general_ledger_landscape" menu="False" model="account.account" name="account.general.ledger_landscape" rml="account/report/account_general_ledger.rml" string="General Ledger"/>
<report auto="False" id="account_3rdparty_ledger" menu="False" model="res.partner" name="account.third_party_ledger" rml="account/report/account_partner_ledger.rml" string="Partner Ledger"/>
<report auto="False" id="account_3rdparty_ledger_other" menu="False" model="res.partner" name="account.third_party_ledger_other" rml="account/report/account_partner_ledger_other.rml" string="Partner Ledger"/>
<report auto="False" id="account_account_balance" menu="False" model="account.account" name="account.account.balance" rml="account/report/account_balance.rml" string="Trial Balance"/>

View File

@ -179,6 +179,7 @@
<separator string="Reconcile" colspan="2"/>
<field name="reconcile"/>
</group>
<field name="active" groups="base.group_extended" />
<separator string="Default Taxes" colspan="4"/>
<field colspan="4" name="tax_ids" nolabel="1" domain="[('parent_id','=',False)]"/>
<separator string="Consolidated Children" colspan="4"/>

View File

@ -991,15 +991,13 @@ class account_invoice(osv.osv):
return True
def action_cancel(self, cr, uid, ids, *args):
context = {} # TODO: Use context from arguments
account_move_obj = self.pool.get('account.move')
invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
move_ids = [] # ones that we will need to remove
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]])
move_ids.append(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'])
@ -1007,7 +1005,15 @@ class account_invoice(osv.osv):
if move_line.reconcile_partial_id and move_line.reconcile_partial_id.line_partial_ids:
raise osv.except_osv(_('Error !'), _('You cannot cancel the Invoice which is Partially Paid! You need to unreconcile concerned payment entries!'))
# First, set the invoices as cancelled and detach the move ids
self.write(cr, uid, ids, {'state':'cancel', 'move_id':False})
if move_ids:
# second, invalidate the move(s)
account_move_obj.button_cancel(cr, uid, move_ids, context=context)
# 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, move_ids, context=context)
self._log_event(cr, uid, ids, -1.0, 'Cancel Invoice')
return True