[ADD] account: convert account_validate_account_move wizard to osv_memory wizard
bzr revid: psi@tinyerp.co.in-20100415045002-s9arwlzl4el1gtjm
This commit is contained in:
parent
ddcdd48fee
commit
1588c6af13
|
@ -65,6 +65,7 @@ module named account_voucherss
|
|||
'wizard/account_state_open_view.xml',
|
||||
'wizard/account_journal_select_view.xml',
|
||||
'wizard/account_change_currency_view.xml',
|
||||
'wizard/account_validate_move_view.xml',
|
||||
'project/wizard/project_account_analytic_line_view.xml',
|
||||
'account_view.xml',
|
||||
'account_end_fy.xml',
|
||||
|
|
|
@ -90,10 +90,10 @@
|
|||
|
||||
|
||||
<!-- account.move validate -->
|
||||
<wizard id="wizard_validate_account_moves" menu="False" model="account.move" name="account.move.validate" string="Validate Ledger Postings"/>
|
||||
<!-- <wizard id="wizard_validate_account_moves" menu="False" model="account.move" name="account.move.validate" string="Validate Ledger Postings"/>
|
||||
<menuitem action="wizard_validate_account_moves" id="menu_validate_account_moves" parent="account.menu_finance_periodical_processing" type="wizard"/>
|
||||
|
||||
<wizard id="wizard_validate_account_moves_line" menu="True" model="account.move.line" name="account.move_line.validate" string="Validate Ledger Postings"/>
|
||||
<wizard id="wizard_validate_account_moves_line" menu="True" model="account.move.line" name="account.move_line.validate" string="Validate Ledger Postings"/>-->
|
||||
|
||||
<!-- Use Models -->
|
||||
<wizard string="Create Entries From Models" model="account.model" name="account_use_models" menu="False" id="wizard_account_use_model"/>
|
||||
|
|
|
@ -47,7 +47,7 @@ import wizard_account_duplicate
|
|||
import account_chart
|
||||
import wizard_move_line_select
|
||||
|
||||
import wizard_validate_account_move
|
||||
import account_validate_account_move
|
||||
import wizard_use_model
|
||||
|
||||
import account_state_open
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class account_central_journal(osv.osv_memory):
|
||||
_name = 'account.central.journal'
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class account_general_journal(osv.osv_memory):
|
||||
_name = 'account.general.journal'
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class account_print_journal(osv.osv_memory):
|
||||
_name = 'account.print.journal'
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
|
||||
import netsvc
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
# -*- 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
class validate_account_move(osv.osv_memory):
|
||||
_name = "validate.account.move"
|
||||
_description = "Validate Account Move"
|
||||
_columns = {
|
||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
|
||||
'period_id': fields.many2one('account.period', 'Period', required=True, domain=[('state','<>','done')]),
|
||||
}
|
||||
|
||||
def validate_move(self, cr, uid, ids, context=None):
|
||||
obj_move = self.pool.get('account.move')
|
||||
if context is None:
|
||||
context = {}
|
||||
data = self.read(cr, uid, ids)[0]
|
||||
ids_move = obj_move.search(cr, uid, [('state','=','draft'),('journal_id','=',data['journal_id']),('period_id','=',data['period_id'])])
|
||||
if not ids_move:
|
||||
raise osv.except_osv(_('Warning'), _('Specified Journal does not have any account move entries in draft state for this period'))
|
||||
obj_move.button_validate(cr, uid, ids_move, context)
|
||||
return {}
|
||||
|
||||
validate_account_move()
|
||||
|
||||
class validate_account_move_lines(osv.osv_memory):
|
||||
_name = "validate.account.move.lines"
|
||||
_description = "Validate Account Move Lines"
|
||||
|
||||
def validate_move_lines(self, cr, uid, ids, context=None):
|
||||
obj_move_line = self.pool.get('account.move.line')
|
||||
obj_move = self.pool.get('account.move')
|
||||
move_ids = []
|
||||
if context is None:
|
||||
context = {}
|
||||
data_line = obj_move_line.browse(cr, uid, context['active_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 osv.except_osv(_('Warning'), _('Selected Entry Lines does not have any account move enties in draft state'))
|
||||
obj_move.button_validate(cr, uid, move_ids, context)
|
||||
return {}
|
||||
validate_account_move_lines()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!--Account Moves-->
|
||||
<record id="validate_account_move_view" model="ir.ui.view">
|
||||
<field name="name">Validate Account Move</field>
|
||||
<field name="model">validate.account.move</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Validate Account Entries">
|
||||
<separator string="Select Period and Journal for Validation" colspan="4"/>
|
||||
<field name="journal_id"/>
|
||||
<newline/>
|
||||
<field name="period_id"/>
|
||||
<separator string="Information" colspan="4"/>
|
||||
<label string="All draft account entries in this journal and period will be validated. It means you won't be able to modify their accouting fields." colspan="4"/>
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-open" string="Validate" name="validate_move" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_validate_account_move" model="ir.actions.act_window">
|
||||
<field name="name">Open Journal</field>
|
||||
<field name="res_model">validate.account.move</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="validate_account_move_view"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
name="Validate Ledger Postings"
|
||||
parent="account.menu_finance_periodical_processing"
|
||||
action="action_validate_account_move"
|
||||
id="menu_validate_account_moves"
|
||||
/>
|
||||
|
||||
<!--Account Move lines-->
|
||||
<record id="validate_account_move_line_view" model="ir.ui.view">
|
||||
<field name="name">Validate Ledger Postings</field>
|
||||
<field name="model">validate.account.move.lines</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Validate Moves">
|
||||
<separator string="Validate Ledger Postings" colspan="4"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="validate_move_lines" string="Validate" type="object" icon="gtk-go-forward" default_focus="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_validate_account_move_line" model="ir.actions.act_window">
|
||||
<field name="name">Validate Ledger Postings</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">validate.account.move.lines</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="validate_account_move_line_view"/>
|
||||
<field name="context">{'record_id' : active_id}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="event_registration_values">
|
||||
<field name="model_id" ref="account.model_account_move_line" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Validate Ledger Postings</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_validate_account_move_line'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.move.line</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,89 +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 wizard
|
||||
from osv import osv
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
|
||||
_journal_form = '''<?xml version="1.0"?>
|
||||
<form string="Validate Account Entries">
|
||||
<separator string="Select Period and Journal for Validation" colspan="4"/>
|
||||
<field name="journal_id"/>
|
||||
<newline/>
|
||||
<field name="period_id"/>
|
||||
<separator string="Information" colspan="4"/>
|
||||
<label string="All draft account entries in this journal and period will be validated. It means you won't be able to modify their accouting fields." colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
_journal_fields = {
|
||||
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
|
||||
'period_id': {'string':'Period', 'type':'many2one', 'relation':'account.period', 'required':True, 'domain':"[('state','<>','done')]"},
|
||||
}
|
||||
|
||||
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']),('period_id','=',data['form']['period_id'])])
|
||||
if not ids_move:
|
||||
raise wizard.except_wizard(_('Warning'), _('Specified Journal does not have any account move entries in draft state for this period'))
|
||||
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', 'gtk-cancel'),('validate','Validate', 'gtk-ok')]}
|
||||
},
|
||||
'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 Entry 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')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue