Add StateReport to Wizard

issue4896
review19361002
This commit is contained in:
Cédric Krier
2015-08-14 17:58:47 +02:00
parent 09345debbd
commit a6c0702bd1
4 changed files with 40 additions and 3 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add StateReport to Wizard
* Allow to override ModelSQL._table
* Allow to import backend from entry points
* Add reversed operators to PYSON expressions
+9
View File
@@ -172,6 +172,15 @@ Instance methods are:
Returns the `ir.action` definition.
===========
StateReport
===========
.. class:: StateReport(report_name)
A :class:`StateReport` is a :class:`StateAction` which find the report
action by name instead of `XML` id.
======
Button
======
+6 -2
View File
@@ -1,5 +1,9 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from .wizard import Wizard, StateView, StateTransition, StateAction, Button
from .wizard import Wizard
from .wizard import StateView, StateTransition, StateAction, StateReport
from .wizard import Button
__all__ = ['Wizard', 'StateView', 'StateTransition', 'StateAction', 'Button']
__all__ = ['Wizard',
'StateView', 'StateTransition', 'StateAction', 'StateReport',
'Button']
+24 -1
View File
@@ -1,7 +1,9 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
__all__ = ['Wizard', 'StateView', 'StateTransition', 'StateAction', 'Button']
__all__ = ['Wizard',
'StateView', 'StateTransition', 'StateAction', 'StateReport',
'Button']
try:
import simplejson as json
@@ -146,6 +148,27 @@ class StateAction(StateTransition):
return Action.get_action_values(action.type, [action.id])[0]
class StateReport(StateAction):
'An report state of a wizard'
def __init__(self, report_name):
super(StateReport, self).__init__(None)
self.report_name = report_name
def get_action(self):
'Return report definition'
pool = Pool()
ActionReport = pool.get('ir.action.report')
Action = pool.get('ir.action')
action_reports = ActionReport.search([
('report_name', '=', self.report_name),
])
assert action_reports, '%s not found' % self.report_name
action_report = action_reports[0]
action = action_report.action
return Action.get_action_values(action.type, [action.id])[0]
class Wizard(WarningErrorMixin, URLMixin, PoolBase):
start_state = 'start'
end_state = 'end'