From ff7cd065ad46e7d6580319585f00e3fb2b1d25c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 25 Feb 2024 13:49:05 +0100 Subject: [PATCH] Add module Many2One --- trytond/trytond/ir/action.py | 5 ++++- trytond/trytond/ir/model.py | 20 ++++++++++++++----- trytond/trytond/ir/translation.py | 9 ++++++++- trytond/trytond/ir/ui/icon.py | 6 +++++- trytond/trytond/ir/ui/view.py | 3 +++ .../trytond/ir/view/action_report_form.xml | 5 +++-- trytond/trytond/ir/view/icon_view_form.xml | 4 ++-- trytond/trytond/ir/view/icon_view_list.xml | 2 +- trytond/trytond/ir/view/model_data_list.xml | 2 +- trytond/trytond/ir/view/model_field_form.xml | 4 ++-- trytond/trytond/ir/view/model_field_list.xml | 2 +- trytond/trytond/ir/view/model_form.xml | 4 ++-- trytond/trytond/ir/view/model_list.xml | 2 +- trytond/trytond/ir/view/translation_form.xml | 8 ++++---- trytond/trytond/ir/view/translation_list.xml | 3 ++- trytond/trytond/ir/view/ui_view_form.xml | 4 ++-- trytond/trytond/ir/view/ui_view_list.xml | 1 + 17 files changed, 57 insertions(+), 27 deletions(-) diff --git a/trytond/trytond/ir/action.py b/trytond/trytond/ir/action.py index 6d61ebd9ba..de82dc49c6 100644 --- a/trytond/trytond/ir/action.py +++ b/trytond/trytond/ir/action.py @@ -472,6 +472,9 @@ class ActionReport( fields.fmany2one( 'model_ref', 'model', 'ir.model,model', "Model", ondelete='CASCADE'), + fields.fmany2one( + 'module_ref', 'module', 'ir.module,name', "Module", + readonly=True, ondelete='CASCADE'), ActionMixin, ModelSQL, ModelView): "Action report" __name__ = 'ir.action.report' @@ -619,7 +622,7 @@ class ActionReport( @staticmethod def default_module(): - return Transaction().context.get('module') or '' + return Transaction().context.get('module') def get_is_custom(self, name): return bool(self.report_content_custom) diff --git a/trytond/trytond/ir/model.py b/trytond/trytond/ir/model.py index 06fa62a939..3084cd5edd 100644 --- a/trytond/trytond/ir/model.py +++ b/trytond/trytond/ir/model.py @@ -39,7 +39,12 @@ class ConditionError(ValidationError): pass -class Model(ModelSQL, ModelView): +class Model( + fields.fmany2one( + 'module_ref', 'module', 'ir.module,name', "Module", + readonly=True, ondelete='CASCADE', + help="Module in which this model is defined."), + ModelSQL, ModelView): "Model" __name__ = 'ir.model' _order_name = 'model' @@ -58,8 +63,7 @@ class Model(ModelSQL, ModelView): 'readonly': Bool(Eval('module')), }, depends=['module']) - module = fields.Char('Module', - help="Module in which this model is defined.", readonly=True) + module = fields.Char("Module", readonly=True) global_search_p = fields.Boolean('Global Search') fields = fields.One2Many('ir.model.field', 'model_ref', "Fields") _get_names_cache = Cache('ir.model.get_names') @@ -224,6 +228,10 @@ class ModelField( fields.fmany2one( 'model_ref', 'model', 'ir.model,model', "Model", required=True, ondelete='CASCADE'), + fields.fmany2one( + 'module_ref', 'module', 'ir.module,name', "Module", + readonly=True, ondelete='CASCADE', + help="Module in which this field is defined."), ModelSQL, ModelView): "Model field" __name__ = 'ir.model.field' @@ -258,8 +266,7 @@ class ModelField( 'readonly': Bool(Eval('module')), }, depends=['module']) - module = fields.Char('Module', - help="Module in which this field is defined.") + module = fields.Char("Module", readonly=True) access = fields.Boolean( "Access", states={ @@ -1268,6 +1275,9 @@ class ModelData( fields.fmany2one( 'model_ref', 'model', 'ir.model,model', "Model", required=True, ondelete='CASCADE'), + fields.fmany2one( + 'module_ref', 'module', 'ir.module,name', "Module", + required=True, ondelete='CASCADE'), ModelSQL, ModelView): "Model data" __name__ = 'ir.model.data' diff --git a/trytond/trytond/ir/translation.py b/trytond/trytond/ir/translation.py index 42d4132a31..f4057c4a5f 100644 --- a/trytond/trytond/ir/translation.py +++ b/trytond/trytond/ir/translation.py @@ -57,7 +57,14 @@ class TrytonPOFile(polib.POFile): key=lambda x: (x.msgctxt, x.msgid)) -class Translation(ModelSQL, ModelView): +class Translation( + fields.fmany2one( + 'module_ref', 'module', 'ir.module,name', "Module", + readonly=True, ondelete='CASCADE'), + fields.fmany2one( + 'overriding_module_ref', 'overriding_module', 'ir.module,name', + "Overriding Module", readonly=True), + ModelSQL, ModelView): "Translation" __name__ = "ir.translation" diff --git a/trytond/trytond/ir/ui/icon.py b/trytond/trytond/ir/ui/icon.py index 3063934450..74cbbd239c 100644 --- a/trytond/trytond/ir/ui/icon.py +++ b/trytond/trytond/ir/ui/icon.py @@ -10,7 +10,11 @@ from trytond.tools import file_open from trytond.transaction import Transaction -class Icon(sequence_ordered(), ModelSQL, ModelView): +class Icon( + fields.fmany2one( + 'module_ref', 'module', 'ir.module,name', "Module", + readonly=True, required=True, ondelete='CASCADE'), + sequence_ordered(), ModelSQL, ModelView): 'Icon' __name__ = 'ir.ui.icon' diff --git a/trytond/trytond/ir/ui/view.py b/trytond/trytond/ir/ui/view.py index 8f59e2a8c4..d38177a03e 100644 --- a/trytond/trytond/ir/ui/view.py +++ b/trytond/trytond/ir/ui/view.py @@ -37,6 +37,9 @@ class View( states={ 'invisible': Eval('type') != 'tree', }), + fields.fmany2one( + 'module_ref', 'module', 'ir.module,name', "Module", + readonly=True, ondelete='CASCADE'), ModelSQL, ModelView): "View" __name__ = 'ir.ui.view' diff --git a/trytond/trytond/ir/view/action_report_form.xml b/trytond/trytond/ir/view/action_report_form.xml index 80b25f174b..7fa03a5146 100644 --- a/trytond/trytond/ir/view/action_report_form.xml +++ b/trytond/trytond/ir/view/action_report_form.xml @@ -13,12 +13,13 @@ this repository contains the full copyright notices and license terms. -->