Add model Many2One on ir.ui.view
This commit is contained in:
@@ -5,13 +5,13 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_dashboard">
|
||||
<field name="model"></field>
|
||||
<field name="model" eval="None"/>
|
||||
<field name="type">board</field>
|
||||
<field name="name">dashboard</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window" id="act_dashboard">
|
||||
<field name="name">Dashboard</field>
|
||||
<field name="res_model"></field>
|
||||
<field name="res_model" eval="None"/>
|
||||
<field name="type">ir.action.act_window</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_dashboard_view1">
|
||||
|
||||
@@ -939,7 +939,7 @@ class ActionActWindowView(
|
||||
view = fields.Many2One(
|
||||
'ir.ui.view', "View", required=True, ondelete='CASCADE',
|
||||
domain=[
|
||||
('model', '=', Eval('model')),
|
||||
('model', '=', Eval('model', None)),
|
||||
])
|
||||
act_window = fields.Many2One('ir.action.act_window', 'Action',
|
||||
ondelete='CASCADE')
|
||||
|
||||
@@ -23,10 +23,13 @@ class XMLError(ValidationError):
|
||||
pass
|
||||
|
||||
|
||||
class View(ModelSQL, ModelView):
|
||||
class View(
|
||||
fields.fmany2one(
|
||||
'model_ref', 'model', 'ir.model,model', "Model",
|
||||
ondelete='CASCADE'),
|
||||
ModelSQL, ModelView):
|
||||
"View"
|
||||
__name__ = 'ir.ui.view'
|
||||
_rec_name = 'model'
|
||||
model = fields.Char('Model', states={
|
||||
'required': Eval('type') != 'board',
|
||||
})
|
||||
@@ -102,9 +105,13 @@ class View(ModelSQL, ModelView):
|
||||
|
||||
def get_rec_name(self, name):
|
||||
return '%s (%s)' % (
|
||||
self.model,
|
||||
self.model_ref.rec_name,
|
||||
self.inherit.rec_name if self.inherit else self.type_string)
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
return [('model_ref.rec_name', *clause[1:])]
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('ir.act_view_show')
|
||||
def show(cls, views):
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<!-- 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="model_ref"/>
|
||||
<field name="model_ref"/>
|
||||
<label name="type"/>
|
||||
<field name="type"/>
|
||||
<label name="inherit"/>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="priority" optional="1"/>
|
||||
<field name="model" expand="2"/>
|
||||
<field name="model_ref" expand="2"/>
|
||||
<field name="type"/>
|
||||
<field name="inherit" expand="1" optional="0"/>
|
||||
<field name="domain" expand="1" optional="1"/>
|
||||
|
||||
Reference in New Issue
Block a user