From 9e64c49dc0fc95b5e06ae105fd66c8fce52b38cb Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Tue, 23 Aug 2022 15:45:07 +0200 Subject: [PATCH] wizard report: button gesperrt wen keine abstimmung --- wizard_runreport.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/wizard_runreport.py b/wizard_runreport.py index 4da6375..97a1ea8 100644 --- a/wizard_runreport.py +++ b/wizard_runreport.py @@ -39,6 +39,8 @@ class RunCbReportStart(ModelView): self.reconciliations = self.on_change_with_reconciliations() if len(self.reconciliations or []) > 0: self.reconciliation = self.reconciliations[0] + else : + self.reconciliation = None else : self.reconciliations = [] self.reconciliation = None @@ -66,7 +68,10 @@ class RunCbReport(Wizard): selrecon = StateView('cashbook.runrepbook.start', 'cashbook.runrepbook_view_form', [ Button(string='Cancel', state='end', icon='tryton-cancel'), - Button(string='Report', state='report_', icon='tryton-ok', default=True), + Button(string='Report', state='report_', icon='tryton-ok', default=True, + states={ + 'readonly': ~Bool(Eval('reconciliation')), + }), ]) report_ = StateReport('cashbook.reprecon') @@ -108,11 +113,14 @@ class RunCbReport(Wizard): """ run report """ # values for 'data' in report - r1 = { - 'model': self.selrecon.reconciliation.__name__, - 'id': self.selrecon.reconciliation.id, - 'ids': [self.selrecon.reconciliation.id], - } + if self.selrecon.reconciliation: + r1 = { + 'model': self.selrecon.reconciliation.__name__, + 'id': self.selrecon.reconciliation.id, + 'ids': [self.selrecon.reconciliation.id], + } + else : + r1 = {'model': '', 'id': None, 'ids': []} return action, r1 def transition_report_(self):