new implementation for the server action

* add wizard for the print action creation

bzr revid: mga@mga-laptop-20081008064651-41sxiwcwh0223p4e
This commit is contained in:
Mantavya Gajjar 2008-10-08 12:16:51 +05:30
parent 794d44fb0b
commit 062c4ac8a5
4 changed files with 101 additions and 2 deletions

View File

@ -1099,6 +1099,7 @@
<page string="Python Code" attrs="{'invisible':[('state','!=','python')]}">
<separator colspan="4" string="Python code"/>
<field name="code" colspan="4" nolabel="1" />
<button string="Create Action" name="%(wizard_server_action_create)d" type="action"/>
</page>
<page string="Trigger" attrs="{'invisible':[('state','!=','trigger')]}">

View File

@ -28,6 +28,6 @@
#
##############################################################################
import wizard_menu
import create_action
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,92 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# 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
import pooler
import time
action_type = '''<?xml version="1.0"?>
<form string="Select Action Type">
<field name="type"/>
</form>'''
action_type_fields = {
'type': {'string':"Start date",'type':'selection','required':True ,'selection':[('ir.actions.report.xml','Open Report')]},
}
report_action = '''<?xml version="1.0"?>
<form string="Select Report">
<field name="report" colspan="4"/>
</form>'''
report_action_fields = {
'report': {'string':"Select Report",'type':'many2one','relation':'ir.actions.report.xml', 'required':True},
}
class create_action(wizard.interface):
def _create_report_action(self, cr, uid, data, context={}):
pool = pooler.get_pool(cr.dbname)
reports = pool.get('ir.actions.report.xml')
form = data['form']
rpt = reports.browse(cr, uid, form['report'])
action = """
action = {
'type': 'ir.actions.report.xml',
'model':'%s',
'report_name': '%s',
'ids': context['active_ids'],
}""" % (rpt.model, rpt.report_name)
obj = pool.get('ir.actions.server')
obj.write(cr, uid, data['ids'], {'code':action})
return {}
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':action_type,'fields':action_type_fields, 'state':[('step_1','Next'),('end','Close')]}
},
'step_1': {
'actions': [],
'result': {'type':'form', 'arch':report_action,'fields':report_action_fields, 'state':[('create','Create'),('end','Close')]}
},
'create': {
'actions': [_create_report_action],
'result': {'type':'state', 'state':'end'}
},
}
create_action('server.action.create')

View File

@ -28,6 +28,12 @@
</field>
</record>
<act_window context="{'model_id': active_id}" id="act_menu_create" name="Create Menu" res_model="wizard.ir.model.menu.create" target="new" view_mode="form"/>
<wizard
id="wizard_server_action_create"
model="ir.actions.server"
name="server.action.create"
string="Create Action"
menu="False"
/>
</data>
</openerp>