replace 'domain' with 'context_domain' in 'ir.action.act_window'

This commit is contained in:
Frederik Jaeckel 2023-12-10 14:58:38 +01:00
parent d9b1d793e3
commit 21828b296d
4 changed files with 53 additions and 2 deletions

View file

@ -10,6 +10,7 @@ from .currency import Currency
from .evaluation_context import EvaluationContext
from .evaluation_wizard import OpenChartWizard
from .investment import InvestmentEvaluation, InvestmentLine
from .ir import Rule, IrActWindow
def register():
@ -18,6 +19,8 @@ def register():
Evaluation,
EvaluationLine,
EvaluationContext,
Rule,
IrActWindow,
module='cashbook_report', type_='model')
Pool.register(
OpenChartWizard,

View file

@ -221,7 +221,7 @@ class Evaluation(sequence_ordered(), ModelSQL, ModelView):
'name': evaluation.name,
'res_model': 'cashbook_report.eval_line',
'usage': 'dashboard',
'domain': '[["evaluation", "=", %d]]' % evaluation.id,
'context_domain': '[["evaluation", "=", %d]]' % evaluation.id,
}])
dashb_actview, = ActView.create([{

47
ir.py Normal file
View file

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
# This file is part of the cashbook-module from m-ds.de for Tryton.
# The COPYRIGHT file at the top level of this repository contains the
# full copyright notices and license terms.
from trytond.transaction import Transaction
from trytond.pool import PoolMeta
class Rule(metaclass=PoolMeta):
__name__ = 'ir.rule'
@classmethod
def _context_modelnames(cls):
""" list of models to add 'user_id' to context
"""
return super(Rule, cls)._context_modelnames() + [
'ir.action.act_window', 'cashbook_report.evaluation']
# end Rule
class IrActWindow(metaclass=PoolMeta):
__name__ = 'ir.action.act_window'
@classmethod
def __register__(cls, module_name):
super(IrActWindow, cls).__register__(module_name)
# migrate (6.0 --> 7.0): domain --> context_domain
records = cls.search([
('res_model', '=', 'cashbook_report.eval_line'),
('domain', '!=', None),
('context_domain', '=', None),
('context_model', '=', None)])
if records:
to_write = []
for record in records:
to_write.extend([
[record],
{
'context_domain': record.domain,
'domain': None,
}])
cls.write(*to_write)
# end IrActWindow

View file

@ -788,8 +788,9 @@ class ReportTestCase(CashbookInvestmentTestCase):
self.assertEqual(
evaluation.dashb_actwin.usage,
'dashboard')
self.assertEqual(evaluation.dashb_actwin.domain, None)
self.assertEqual(
evaluation.dashb_actwin.domain,
evaluation.dashb_actwin.context_domain,
'[["evaluation", "=", %d]]' % evaluation.id)
# action-view
self.assertEqual(evaluation.dashb_actview.sequence, 10)