[IMP] base: add a many2one from ir.ui.view to model
When using the view "edit view" on the interface as administrator, the user can see and modify the model of the view as a string, but cannot navigate to the model easily or edit the model field by selecting the model in a list. This pull request adds the possibility to view and edit the model field as a many2one. closes odoo/odoo#105356 Task-id: 3007619 Signed-off-by: Raphael Collet <rco@odoo.com>
This commit is contained in:
@@ -277,6 +277,7 @@ actual arch.
|
||||
* if True, the view always extends its parent
|
||||
* if False, the view currently does not extend its parent but can be enabled
|
||||
""")
|
||||
model_id = fields.Many2one("ir.model", string="Model of the view", compute='_compute_model_id', inverse='_inverse_compute_model_id')
|
||||
|
||||
@api.depends('arch_db', 'arch_fs', 'arch_updated')
|
||||
@api.depends_context('read_arch_from_file', 'lang')
|
||||
@@ -370,6 +371,15 @@ actual arch.
|
||||
data = self.env['ir.model.data'].sudo().search(domain)
|
||||
return [('id', 'in', data.mapped('res_id'))]
|
||||
|
||||
@api.depends('model')
|
||||
def _compute_model_id(self):
|
||||
for record in self:
|
||||
record.model_id = self.env['ir.model']._get(record.model)
|
||||
|
||||
def _inverse_compute_model_id(self):
|
||||
for record in self:
|
||||
record.model = record.model_id.model
|
||||
|
||||
def _compute_xml_id(self):
|
||||
xml_ids = collections.defaultdict(list)
|
||||
domain = [('model', '=', 'ir.ui.view'), ('res_id', 'in', self.ids)]
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
<field name="model"/>
|
||||
<field name="model" invisible="True"/>
|
||||
<field name="model_id"/>
|
||||
<field name="priority"/>
|
||||
<field name="active" widget="boolean_toggle"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user