Add foreign keys for model and field to view tree state

This commit is contained in:
Cédric Krier committed 2024-08-27 10:57:26 +02:00
1 parent a4a97c9369
commit 2d12c5ce74
3 files changed
+20 -7

No files matched your search

+11 -1
View File
@@ -639,7 +639,17 @@ class ViewTreeOptional(
cls.create(to_create)
class ViewTreeState(ModelSQL, ModelView):
class ViewTreeState(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
required=True, ondelete='CASCADE'),
fields.fmany2one(
'child_field', 'child_name,model', 'ir.model.field,name,model',
"Child Field", ondelete='CASCADE',
domain=[
('model', '=', Eval('model')),
]),
ModelSQL, ModelView):
'View Tree State'
__name__ = 'ir.ui.view_tree_state'
_rec_name = 'model'
@@ -2,16 +2,19 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="model"/>
<field name="model"/>
<label name="user"/>
<field name="user"/>
<label name="model_ref"/>
<field name="model_ref"/>
<label name="domain"/>
<field name="domain"/>
<label name="child_name"/>
<field name="child_name"/>
<label name="child_field"/>
<field name="child_field"/>
<separator name="nodes" colspan="4"/>
<field name="nodes" colspan="4"/>
<separator name="selected_nodes" colspan="4"/>
<field name="selected_nodes" colspan="4"/>
</form>
@@ -3,7 +3,7 @@
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="user" expand="1"/>
<field name="model" expand="1"/>
<field name="model_ref" expand="1"/>
<field name="domain" expand="1"/>
<field name="child_name"/>
<field name="child_field"/>
</tree>