auswertung: dashboard-window aktualisieren bei änderung der auswertung
This commit is contained in:
parent
c0432d609d
commit
f06eacbadc
3 changed files with 98 additions and 2 deletions
|
@ -193,10 +193,13 @@ class Evaluation(sequence_ordered(), ModelSQL, ModelView):
|
||||||
ActWin = pool.get('ir.action.act_window')
|
ActWin = pool.get('ir.action.act_window')
|
||||||
ActView = pool.get('ir.action.act_window.view')
|
ActView = pool.get('ir.action.act_window.view')
|
||||||
Evaluation2 = pool.get('cashbook_report.evaluation')
|
Evaluation2 = pool.get('cashbook_report.evaluation')
|
||||||
|
try :
|
||||||
cls.uiview_delete(evaluations)
|
DashboardAction = pool.get('dashboard.action')
|
||||||
|
except:
|
||||||
|
DashboardAction = None
|
||||||
|
|
||||||
to_write_eval = []
|
to_write_eval = []
|
||||||
|
to_write_dbaction = []
|
||||||
for evaluation in evaluations:
|
for evaluation in evaluations:
|
||||||
with Transaction().set_context({
|
with Transaction().set_context({
|
||||||
'_check_access': False,
|
'_check_access': False,
|
||||||
|
@ -226,6 +229,24 @@ class Evaluation(sequence_ordered(), ModelSQL, ModelView):
|
||||||
'dashb_actview': dashb_actview.id,
|
'dashb_actview': dashb_actview.id,
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
# prepare update dasboard-action
|
||||||
|
if DashboardAction is not None:
|
||||||
|
if evaluation.dashb_actwin:
|
||||||
|
db_actions = DashboardAction.search([
|
||||||
|
('act_window.id', '=', evaluation.dashb_actwin.id),
|
||||||
|
])
|
||||||
|
if len(db_actions) > 0:
|
||||||
|
to_write_dbaction.extend([
|
||||||
|
db_actions,
|
||||||
|
{
|
||||||
|
'act_window': dashb_actwin.id,
|
||||||
|
}])
|
||||||
|
|
||||||
|
if len(to_write_dbaction) > 0:
|
||||||
|
DashboardAction.write(*to_write_dbaction)
|
||||||
|
|
||||||
|
cls.uiview_delete(evaluations)
|
||||||
|
|
||||||
if len(to_write_eval) > 0:
|
if len(to_write_eval) > 0:
|
||||||
Evaluation2.write(*to_write_eval)
|
Evaluation2.write(*to_write_eval)
|
||||||
|
|
||||||
|
|
|
@ -531,6 +531,79 @@ class ReportTestCase(CashbookTestCase):
|
||||||
'types': [('add', [x.id for x in Types.search([])])],
|
'types': [('add', [x.id for x in Types.search([])])],
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
@with_transaction()
|
||||||
|
def test_report_check_update_of_actionviews(self):
|
||||||
|
""" create 3x cashbooks, add evaluation, check created
|
||||||
|
form + actionview
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Evaluation = pool.get('cashbook_report.evaluation')
|
||||||
|
try :
|
||||||
|
DashboardAction = pool.get('dashboard.action')
|
||||||
|
except:
|
||||||
|
print('\n--== Module "dashboard" not installed ==--')
|
||||||
|
DashboardAction = None
|
||||||
|
|
||||||
|
books = self.prep_report_3books()
|
||||||
|
|
||||||
|
company = self.prep_company()
|
||||||
|
with Transaction().set_context({
|
||||||
|
'company': company.id,
|
||||||
|
}):
|
||||||
|
evaluation, = Evaluation.create([{
|
||||||
|
'name': 'Evaluation 1',
|
||||||
|
'cashbooks': [('add', [x.id for x in books])],
|
||||||
|
}])
|
||||||
|
|
||||||
|
# add dashboard-action
|
||||||
|
if DashboardAction is not None:
|
||||||
|
dbaction, = DashboardAction.create([{
|
||||||
|
'user': Transaction().user,
|
||||||
|
'act_window': evaluation.dashb_actwin.id,
|
||||||
|
}])
|
||||||
|
self.assertEqual(dbaction.user.rec_name, 'Administrator')
|
||||||
|
self.assertEqual(dbaction.act_window.name, 'Evaluation 1')
|
||||||
|
|
||||||
|
self.assertEqual(evaluation.dtype, 'cashbooks')
|
||||||
|
self.assertEqual(evaluation.chart, 'pie')
|
||||||
|
self.assertEqual(evaluation.legend, True)
|
||||||
|
self.assertEqual(evaluation.maincolor, 'default')
|
||||||
|
self.assertEqual(evaluation.bgcolor, '#ffffc0')
|
||||||
|
self.assertEqual(evaluation.currency.code, 'EUR')
|
||||||
|
|
||||||
|
# check uiview
|
||||||
|
self.assertEqual(evaluation.ui_view_chart.model, 'cashbook_report.eval_line')
|
||||||
|
self.assertEqual(evaluation.ui_view_chart.module, 'cashbook_report')
|
||||||
|
self.assertEqual(evaluation.ui_view_chart.priority, 10)
|
||||||
|
self.assertEqual(evaluation.ui_view_chart.type, 'graph')
|
||||||
|
# action-window for dashbord
|
||||||
|
self.assertEqual(evaluation.dashb_actwin.name, 'Evaluation 1')
|
||||||
|
self.assertEqual(evaluation.dashb_actwin.res_model,
|
||||||
|
'cashbook_report.eval_line')
|
||||||
|
self.assertEqual(evaluation.dashb_actwin.usage,
|
||||||
|
'dashboard')
|
||||||
|
self.assertEqual(evaluation.dashb_actwin.domain,
|
||||||
|
'[["evaluation", "=", %d]]' % evaluation.id)
|
||||||
|
# action-view
|
||||||
|
self.assertEqual(evaluation.dashb_actview.sequence, 10)
|
||||||
|
self.assertEqual(evaluation.dashb_actview.view.id,
|
||||||
|
evaluation.ui_view_chart.id)
|
||||||
|
self.assertEqual(evaluation.dashb_actview.act_window.id,
|
||||||
|
evaluation.dashb_actwin.id)
|
||||||
|
|
||||||
|
# update evaluation, this wil re-create the view/act-window
|
||||||
|
# and update the dashboard-view, without removing it
|
||||||
|
old_win_id = evaluation.dashb_actwin.id
|
||||||
|
Evaluation.write(*[
|
||||||
|
[evaluation],
|
||||||
|
{
|
||||||
|
'name': 'Evaluation 1a',
|
||||||
|
}])
|
||||||
|
self.assertTrue(old_win_id != evaluation.dashb_actwin.id)
|
||||||
|
|
||||||
|
if DashboardAction is not None:
|
||||||
|
self.assertEqual(DashboardAction.search_count([]), 1)
|
||||||
|
|
||||||
@with_transaction()
|
@with_transaction()
|
||||||
def test_report_chart_pie_book_red(self):
|
def test_report_chart_pie_book_red(self):
|
||||||
""" create 3x cashbooks, add bookings,
|
""" create 3x cashbooks, add bookings,
|
||||||
|
|
|
@ -3,6 +3,8 @@ version=6.0.2
|
||||||
depends:
|
depends:
|
||||||
res
|
res
|
||||||
cashbook
|
cashbook
|
||||||
|
extras_depend:
|
||||||
|
dashboard
|
||||||
xml:
|
xml:
|
||||||
icon.xml
|
icon.xml
|
||||||
message.xml
|
message.xml
|
||||||
|
|
Loading…
Reference in a new issue