Display XML ID on Log window

Closes #13055
This commit is contained in:
Cédric Krier
2024-02-25 13:42:18 +01:00
parent cd3395b233
commit adb7243f0c
7 changed files with 82 additions and 3 deletions
+1
View File
@@ -1,3 +1,4 @@
* Display XML ID on Log window
* Use operators when converting PYSON to string
* Add DnD on binary and image widgets
* Allow resetting forgotten password
+35 -1
View File
@@ -767,7 +767,8 @@
record.model.execute(
'read', [[record.id],
['create_uid.rec_name', 'create_date',
'write_uid.rec_name', 'write_date']], context
'write_uid.rec_name', 'write_date',
'xml_id']], context
).then(([log]) => {
var row, cell, label, input;
@@ -802,6 +803,39 @@
input.css('text-align', 'end');
input.uniqueId();
if (log.xml_id) {
const [module, xml_id] = log.xml_id.split('.', 2);
row = jQuery('<tr/>').appendTo(body);
cell = jQuery('<td/>').css('text-align', 'end').appendTo(row);
label = jQuery('<label/>', {
'class': 'form-label',
'text': Sao.i18n.gettext("Module:"),
}).appendTo(cell);
label.uniqueId();
cell = jQuery('<td/>').appendTo(row);
input = jQuery('<input/>', {
'readonly': true,
'class': 'form-control input-sm',
'aria-labelledby': label.attr('id'),
}).val(module).appendTo(cell);
input.uniqueId();
cell = jQuery('<td/>').css('text-align', 'end').appendTo(row);
label = jQuery('<label/>', {
'class': 'form-label',
'text': Sao.i18n.gettext("XML ID:"),
}).appendTo(cell);
label.uniqueId();
cell = jQuery('<td/>').appendTo(row);
input = jQuery('<input/>', {
'readonly': true,
'class': 'form-control input-sm',
'aria-labelledby': label.attr('id'),
}).val(xml_id).appendTo(cell);
input.uniqueId();
}
[['create_uid.', Sao.i18n.gettext("Created by:"),
'create_date', Sao.i18n.gettext("Created at:")],
['write_uid.', Sao.i18n.gettext("Last Modified by:"),
+1
View File
@@ -1,3 +1,4 @@
* Display XML ID on Log window
* Use operators when converting PYSON to string
* Add contextual menu to copy cell and column
* Allow resetting forgotten password
+24 -2
View File
@@ -24,7 +24,8 @@ class Log(WinForm):
log, = RPCExecute(
'model', record.model_name, 'read', [record.id],
['create_uid.rec_name', 'create_date',
'write_uid.rec_name', 'write_date'], context=context)
'write_uid.rec_name', 'write_date',
'xml_id'], context=context)
except RPCException:
return
@@ -53,11 +54,32 @@ class Log(WinForm):
label_id.set_mnemonic_widget(entry_id)
grid.attach(label_id, 2, 1, 1, 1)
if log.get('xml_id'):
module, xml_id = log['xml_id'].split('.', 1)
entry_module = Gtk.Entry(editable=False)
entry_module.set_text(module)
grid.attach(entry_module, 1, 2, 1, 1)
label_module = Gtk.Label(
label=set_underline(_("Module:")),
use_underline=True, halign=Gtk.Align.END)
label_module.set_mnemonic_widget(entry_module)
grid.attach(label_module, 0, 2, 1, 1)
entry_xml_id = Gtk.Entry(editable=False)
entry_xml_id.set_text(xml_id)
grid.attach(entry_xml_id, 3, 2, 1, 1)
label_xml_id = Gtk.Label(
label=set_underline(_("XML ID:")),
use_underline=True, halign=Gtk.Align.END)
label_xml_id.set_mnemonic_widget(entry_xml_id)
grid.attach(label_xml_id, 2, 2, 1, 1)
for i, (user, user_label, date, date_label) in enumerate([
('create_uid.', _("Created by:"),
'create_date', _("Created at:")),
('write_uid.', _("Last Modified by:"),
'write_date', _("Last Modified at:"))], 2):
'write_date', _("Last Modified at:"))], 3):
entry_user = Gtk.Entry(editable=False, width_chars=50)
user = log.get(user)
if user:
+1
View File
@@ -1,3 +1,4 @@
* Add xml_id field on ModelStorage
* Add send_message methods
* Store model on ir.rule.group
* Store model on ir.model.button
+3
View File
@@ -52,6 +52,9 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="msg_record_name">
<field name="text">Record Name</field>
</record>
<record model="ir.message" id="msg_xml_id">
<field name="text">XML ID</field>
</record>
<record model="ir.message" id="msg_active">
<field name="text">Active</field>
</record>
+17
View File
@@ -119,6 +119,8 @@ class ModelStorage(Model):
rec_name = fields.Function(
fields.Char(lazy_gettext('ir.msg_record_name')), 'get_rec_name',
searcher='search_rec_name')
xml_id = fields.Function(
fields.Char(lazy_gettext('ir.msg_xml_id')), 'get_xml_id')
_count_cache = Cache(
'modelstorage.count', duration=_cache_count_timeout, context=False)
_log = None
@@ -685,6 +687,21 @@ class ModelStorage(Model):
return []
return [(rec_name,) + tuple(clause[1:])]
@classmethod
def get_xml_id(cls, records, name):
pool = Pool()
ModelData = pool.get('ir.model.data')
ids = dict.fromkeys(map(int, records))
with without_check_access():
for sub_records in grouped_slice(records):
for record in ModelData.search([
('model', '=', cls.__name__),
('db_id', 'in', [r.id for r in sub_records]),
]):
ids[record.db_id] = f'{record.module}.{record.fs_id}'
return ids
@classmethod
def search_global(cls, text):
'''