diff --git a/CHANGELOG b/CHANGELOG index af28b20bcc..782c0b2614 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/doc/ref/wizard.rst b/doc/ref/wizard.rst index a8944eee31..483a1df4ef 100644 --- a/doc/ref/wizard.rst +++ b/doc/ref/wizard.rst @@ -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 ====== diff --git a/trytond/wizard/__init__.py b/trytond/wizard/__init__.py index 79a16bdb3e..f5b491e460 100644 --- a/trytond/wizard/__init__.py +++ b/trytond/wizard/__init__.py @@ -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'] diff --git a/trytond/wizard/wizard.py b/trytond/wizard/wizard.py index 6d92ed3b3e..4aa0df35a1 100644 --- a/trytond/wizard/wizard.py +++ b/trytond/wizard/wizard.py @@ -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'