*added a new functionnality to allow the user to set the state of the account_move from draft to validate (and existing account_move_lines related). This functionnality
can be called from: ** a list of account_move_lines ** a menuitem in Financial Management\Periodical Processing\Validate Account Moves: it asks for a journal and set the state of all draft account_moves of this journal to validate. *overwritten the name_get of the account_move in order to display the name with a star * before it if its state is in draft bzr revid: qdp-2933c3b426bc6fcaf73f5941469eadba0e0862f4
This commit is contained in:
parent
b1c64bcf14
commit
b9af6d0521
|
@ -575,6 +575,20 @@ class account_move(osv.osv):
|
|||
_name = "account.move"
|
||||
_description = "Account Entry"
|
||||
|
||||
def name_get(self, cursor, user, ids, context=None):
|
||||
if not len(ids):
|
||||
return []
|
||||
res=[]
|
||||
data_move = self.pool.get('account.move').browse(cursor,user,ids)
|
||||
for move in data_move:
|
||||
if move.state=='draft':
|
||||
name = '*' + move.name
|
||||
else:
|
||||
name = move.name
|
||||
res.append((move.id, name))
|
||||
return res
|
||||
|
||||
|
||||
def _get_period(self, cr, uid, context):
|
||||
periods = self.pool.get('account.period').find(cr, uid)
|
||||
if periods:
|
||||
|
|
|
@ -444,7 +444,7 @@ class account_move_line(osv.osv):
|
|||
if not total:
|
||||
return self.reconcile(cr, uid, merges+unmerge, context=context)
|
||||
r_id = self.pool.get('account.move.reconcile').create(cr, uid, {
|
||||
'type': type,
|
||||
'type': type,
|
||||
'line_partial_ids': map(lambda x: (4,x,False), merges+unmerge)
|
||||
})
|
||||
self.pool.get('account.move.reconcile').reconcile_partial_check(cr, uid, [r_id] + merges_rec, context=context)
|
||||
|
@ -518,14 +518,14 @@ class account_move_line(osv.osv):
|
|||
|
||||
writeoff_line_ids = self.search(cr, uid, [('move_id', '=', writeoff_move_id), ('account_id', '=', account_id)])
|
||||
ids += writeoff_line_ids
|
||||
|
||||
|
||||
r_id = self.pool.get('account.move.reconcile').create(cr, uid, {
|
||||
#'name': date,
|
||||
'type': type,
|
||||
#'name': date,
|
||||
'type': type,
|
||||
'line_id': map(lambda x: (4,x,False), ids),
|
||||
'line_partial_ids': map(lambda x: (3,x,False), ids)
|
||||
})
|
||||
# the id of the move.reconcile is written in the move.line (self) by the create method above
|
||||
# the id of the move.reconcile is written in the move.line (self) by the create method above
|
||||
# because of the way the line_id are defined: (4, x, False)
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for id in ids:
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
name="account.budget.spread"
|
||||
menu="False"
|
||||
id="wizard_budget_spread"/>
|
||||
|
||||
|
||||
<!-- close year, period, journal -->
|
||||
<wizard
|
||||
string="Close a fiscal year"
|
||||
|
@ -52,7 +52,7 @@
|
|||
action="wizard_automatic_reconcile"
|
||||
type="wizard"
|
||||
id="menu_automatic_reconcile"/>
|
||||
|
||||
|
||||
<!-- manual reconcile -->
|
||||
<wizard
|
||||
string="Reconcile Entries"
|
||||
|
@ -112,7 +112,7 @@
|
|||
id="menu_generate_subscription"/>
|
||||
|
||||
<!-- Aged partner balance -->
|
||||
<wizard
|
||||
<wizard
|
||||
string="Aged partner balance"
|
||||
model="res.partner"
|
||||
name="account.aged.trial.balance"
|
||||
|
@ -123,9 +123,9 @@
|
|||
action="wizard_aged_trial_balance"
|
||||
type="wizard"
|
||||
id="menu_aged_trial_balance"/>
|
||||
|
||||
|
||||
<!-- report-related wizards -->
|
||||
<wizard
|
||||
<wizard
|
||||
string="Partner balance"
|
||||
model="res.partner"
|
||||
name="account.partner.balance.report"
|
||||
|
@ -136,8 +136,8 @@
|
|||
action="wizard_partner_balance_report"
|
||||
type="wizard"
|
||||
id="menu_partner_balance"/>
|
||||
|
||||
<wizard
|
||||
|
||||
<wizard
|
||||
string="Partner ledger"
|
||||
model="res.partner"
|
||||
name="account.third_party_ledger.report"
|
||||
|
@ -148,8 +148,8 @@
|
|||
action="wizard_third_party_ledger"
|
||||
type="wizard"
|
||||
id="menu_third_party_ledger"/>
|
||||
|
||||
<wizard
|
||||
|
||||
<wizard
|
||||
string="Budget"
|
||||
model="account.budget.post"
|
||||
name="account.budget.report"
|
||||
|
@ -161,21 +161,21 @@
|
|||
name="account.account.balance.report"
|
||||
keyword="client_print_multi"
|
||||
id="wizard_balance_report"/>
|
||||
<wizard
|
||||
<wizard
|
||||
string="General ledger"
|
||||
model="account.account"
|
||||
name="account.general.ledger.report"
|
||||
keyword="client_print_multi"
|
||||
id="wizard_general_ledger_report"/>
|
||||
|
||||
<wizard
|
||||
<wizard
|
||||
string="Confirm draft invoices"
|
||||
model="account.invoice"
|
||||
name="account.invoice.state.confirm"
|
||||
keyword="client_action_multi"
|
||||
multi="True"
|
||||
id="wizard_invoice_state_confirm"/>
|
||||
<wizard
|
||||
<wizard
|
||||
string="Cancel selected invoices"
|
||||
model="account.invoice"
|
||||
name="account.invoice.state.cancel"
|
||||
|
@ -191,5 +191,25 @@
|
|||
id="wizard_account_duplicate"
|
||||
keyword="tree_but_action"/>
|
||||
|
||||
<!-- account.move validate -->
|
||||
<wizard
|
||||
string="Validate Account Moves"
|
||||
model="account.move"
|
||||
name="account.move.validate"
|
||||
menu="False"
|
||||
id="wizard_validate_account_moves"/>
|
||||
<menuitem
|
||||
name="Financial Management/Periodical Processing/Validate Account Moves"
|
||||
action="wizard_validate_account_moves"
|
||||
type="wizard"
|
||||
id="menu_validate_account_moves"/>
|
||||
|
||||
<wizard
|
||||
string="Validate Account Moves"
|
||||
model="account.move.line"
|
||||
name="account.move_line.validate"
|
||||
menu="True"
|
||||
id="wizard_validate_account_moves_line"/>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
|
@ -502,6 +502,9 @@ class account_invoice(osv.osv):
|
|||
move['period_id'] = inv.period_id.id
|
||||
for i in line:
|
||||
i[2]['period_id'] = inv.period_id.id
|
||||
|
||||
print 'move: ', move
|
||||
|
||||
move_id = self.pool.get('account.move').create(cr, uid, move)
|
||||
# make the invoice point to that move
|
||||
self.write(cr, uid, [inv.id], {'move_id': move_id})
|
||||
|
|
|
@ -56,3 +56,5 @@ import wizard_invoice_state
|
|||
import wizard_account_duplicate
|
||||
import wizard_account_chart
|
||||
import wizard_move_line_select
|
||||
|
||||
import wizard_validate_account_move
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# 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 wizard
|
||||
from osv import osv
|
||||
import pooler
|
||||
|
||||
_journal_form = '''<?xml version="1.0"?>
|
||||
<form string="Standard entries">
|
||||
<field name="journal_id"/>
|
||||
</form>'''
|
||||
_journal_fields = {
|
||||
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
|
||||
}
|
||||
|
||||
def _validate_move(self, cr, uid, data, context={}):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
move_obj = pool.get('account.move')
|
||||
ids_move = move_obj.search(cr,uid,[('state','=','draft'),('journal_id','=',data['form']['journal_id'])])
|
||||
if not ids_move:
|
||||
raise wizard.except_wizard('Warning', 'Specified Journal does not have any account move enties in draft state')
|
||||
res = move_obj.button_validate(cr, uid, ids_move, context)
|
||||
return {}
|
||||
|
||||
class validate_account_move(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('validate','Validate')]}
|
||||
},
|
||||
'validate': {
|
||||
'actions': [_validate_move],
|
||||
'result': {'type': 'state', 'state':'end'}
|
||||
},
|
||||
}
|
||||
validate_account_move('account.move.validate')
|
||||
|
||||
def _validate_move_lines(self, cr, uid, data, context={}):
|
||||
move_ids = []
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
move_line_obj = pool.get('account.move.line')
|
||||
move_obj = pool.get('account.move')
|
||||
data_line = move_line_obj.browse(cr,uid,data['ids'],context)
|
||||
for line in data_line:
|
||||
if line.move_id.state=='draft':
|
||||
move_ids.append(line.move_id.id)
|
||||
move_ids = list(set(move_ids))
|
||||
if not move_ids:
|
||||
raise wizard.except_wizard('Warning', 'Selected Move lines does not have any account move enties in draft state')
|
||||
res = move_obj.button_validate(cr, uid, move_ids, context)
|
||||
return {}
|
||||
|
||||
class validate_account_move_lines(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_validate_move_lines],
|
||||
'result': {'type': 'state', 'state':'end'}
|
||||
},
|
||||
}
|
||||
validate_account_move_lines('account.move_line.validate')
|
Loading…
Reference in New Issue