base_usability: add name_get() on ir.model.fields
Add patch to add technical field name in export dialog box
This commit is contained in:
@@ -4,3 +4,4 @@ from . import res_partner_bank
|
|||||||
from . import res_company
|
from . import res_company
|
||||||
from . import ir_mail_server
|
from . import ir_mail_server
|
||||||
from . import ir_model
|
from . import ir_model
|
||||||
|
from . import ir_model_fields
|
||||||
|
|||||||
16
base_usability/models/ir_model_fields.py
Normal file
16
base_usability/models/ir_model_fields.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Copyright 2024 Akretion France (http://www.akretion.com/)
|
||||||
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import api, models
|
||||||
|
|
||||||
|
|
||||||
|
class IrModelFields(models.Model):
|
||||||
|
_inherit = 'ir.model.fields'
|
||||||
|
|
||||||
|
@api.depends('name', 'field_description')
|
||||||
|
def name_get(self):
|
||||||
|
res = []
|
||||||
|
for rec in self:
|
||||||
|
res.append((rec.id, '%s (%s)' % (rec.field_description, rec.name)))
|
||||||
|
return res
|
||||||
21
base_usability/web-export-add_technical_field_name.diff
Normal file
21
base_usability/web-export-add_technical_field_name.diff
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
diff --git a/addons/web/controllers/export.py b/addons/web/controllers/export.py
|
||||||
|
index 5a1bbcb6b02..04c70131660 100644
|
||||||
|
--- a/addons/web/controllers/export.py
|
||||||
|
+++ b/addons/web/controllers/export.py
|
||||||
|
@@ -308,7 +308,6 @@ class Export(http.Controller):
|
||||||
|
def get_fields(self, model, prefix='', parent_name='',
|
||||||
|
import_compat=True, parent_field_type=None,
|
||||||
|
parent_field=None, exclude=None):
|
||||||
|
-
|
||||||
|
fields = self.fields_get(model)
|
||||||
|
if import_compat:
|
||||||
|
if parent_field_type in ['many2one', 'many2many']:
|
||||||
|
@@ -347,7 +346,7 @@ class Export(http.Controller):
|
||||||
|
# Add name field when expand m2o and m2m fields in import-compatible mode
|
||||||
|
val = prefix
|
||||||
|
name = parent_name + (parent_name and '/' or '') + field['string']
|
||||||
|
- record = {'id': ident, 'string': name,
|
||||||
|
+ record = {'id': ident, 'string': name + f' ({field_name})',
|
||||||
|
'value': val, 'children': False,
|
||||||
|
'field_type': field.get('type'),
|
||||||
|
'required': field.get('required'),
|
||||||
Reference in New Issue
Block a user