Rename ir.model 'name' field into 'string'
This commit is contained in:
1 parent
a44d43f09b
commit
a89fc8bf1c
9 files changed
+29
-19
No files matched your search
@@ -469,7 +469,7 @@ class Inspection(Workflow, ModelSQL, ModelView):
|
||||
models = IrModel.search([
|
||||
('model', 'in', models),
|
||||
])
|
||||
return [(None, '')] + [(m.model, m.name) for m in models]
|
||||
return [(None, '')] + [(m.model, m.string) for m in models]
|
||||
|
||||
@fields.depends('control', 'points')
|
||||
def on_change_control(self):
|
||||
@@ -695,7 +695,7 @@ class Alert(Workflow, ModelSQL, ModelView):
|
||||
models = IrModel.search([
|
||||
('model', 'in', models),
|
||||
])
|
||||
return [(None, '')] + [(m.model, m.name) for m in models]
|
||||
return [(None, '')] + [(m.model, m.string) for m in models]
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
* Rename ir.model 'name' field into 'string'
|
||||
|
||||
Version 7.4.0 - 2024-11-04
|
||||
--------------------------
|
||||
|
||||
@@ -10,7 +10,7 @@ CREATE TABLE ir_model (
|
||||
id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL
|
||||
CONSTRAINT ir_model_id_positive CHECK(id >= 0),
|
||||
model VARCHAR NOT NULL,
|
||||
name VARCHAR,
|
||||
string VARCHAR,
|
||||
info TEXT,
|
||||
module VARCHAR,
|
||||
PRIMARY KEY(id)
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE TABLE ir_configuration (
|
||||
CREATE TABLE ir_model (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
model VARCHAR,
|
||||
name VARCHAR,
|
||||
string VARCHAR,
|
||||
info TEXT,
|
||||
module VARCHAR,
|
||||
create_date TIMESTAMP,
|
||||
|
||||
@@ -47,12 +47,12 @@ class Model(
|
||||
ModelSQL, ModelView):
|
||||
"Model"
|
||||
__name__ = 'ir.model'
|
||||
_order_name = 'model'
|
||||
name = fields.Char('Model Description', translate=True, loading='lazy',
|
||||
_rec_name = 'string'
|
||||
string = fields.Char(
|
||||
"String", translate=True,
|
||||
states={
|
||||
'readonly': Bool(Eval('module')),
|
||||
},
|
||||
depends=['module'])
|
||||
})
|
||||
model = fields.Char('Model Name', required=True,
|
||||
states={
|
||||
'readonly': Bool(Eval('module')),
|
||||
@@ -85,6 +85,15 @@ class Model(
|
||||
'global_search': RPC(timeout=_request_timeout),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module):
|
||||
table_h = cls.__table_handler__(module)
|
||||
|
||||
# Migration from 7.4: rename column name into string
|
||||
table_h.column_rename('name', 'string')
|
||||
|
||||
super().__register__(module)
|
||||
|
||||
@classmethod
|
||||
def register(cls, model, module_name):
|
||||
cursor = Transaction().connection.cursor()
|
||||
@@ -101,7 +110,7 @@ class Model(
|
||||
model_id, = cursor.fetchone()
|
||||
if not model_id:
|
||||
cursor.execute(*ir_model.insert(
|
||||
[ir_model.model, ir_model.name, ir_model.info,
|
||||
[ir_model.model, ir_model.string, ir_model.info,
|
||||
ir_model.module],
|
||||
[[
|
||||
model.__name__, model._get_name(), model.__doc__,
|
||||
@@ -168,7 +177,7 @@ class Model(
|
||||
items = cls._get_names_cache.get('items')
|
||||
if items is None:
|
||||
models = cls.search([])
|
||||
items = [(m.model, m.name) for m in models]
|
||||
items = [(m.model, m.string) for m in models]
|
||||
cls._get_names_cache.set('items', items)
|
||||
return items
|
||||
|
||||
|
||||
@@ -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 col="6">
|
||||
<label name="name"/>
|
||||
<field name="name"/>
|
||||
<label name="string"/>
|
||||
<field name="string"/>
|
||||
<label name="model"/>
|
||||
<field name="model"/>
|
||||
<label name="module_ref"/>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="name" expand="2"/>
|
||||
<field name="string" expand="2"/>
|
||||
<field name="model" expand="1"/>
|
||||
<field name="info" expand="1" optional="1"/>
|
||||
<field name="global_search_p"/>
|
||||
|
||||
@@ -39,10 +39,10 @@ class IrTestCase(ModuleTestCase):
|
||||
Model = pool.get('ir.model')
|
||||
|
||||
record, = Model.search([
|
||||
('name', '=', "Language"),
|
||||
('string', '=', "Language"),
|
||||
('module', '=', 'ir'),
|
||||
])
|
||||
self.assertEqual(record.name, "Language")
|
||||
self.assertEqual(record.string, "Language")
|
||||
|
||||
@with_transaction()
|
||||
def test_model_search_order(self):
|
||||
@@ -51,11 +51,11 @@ class IrTestCase(ModuleTestCase):
|
||||
Model = pool.get('ir.model')
|
||||
|
||||
records = Model.search([
|
||||
('name', 'in', ["Language", "Module"]),
|
||||
('string', 'in', ["Language", "Module"]),
|
||||
('module', '=', 'ir'),
|
||||
],
|
||||
order=[('name', 'ASC')])
|
||||
self.assertEqual([r.name for r in records], ["Language", "Module"])
|
||||
order=[('string', 'ASC')])
|
||||
self.assertEqual([r.string for r in records], ["Language", "Module"])
|
||||
|
||||
@with_transaction()
|
||||
def test_model_field_search_description(self):
|
||||
|
||||
@@ -1532,7 +1532,7 @@ class ModelSQLTranslationTestCase(TranslationTestCase):
|
||||
translated_model, = Model.search([
|
||||
('model', '=', 'test.modelsql.name_translated'),
|
||||
])
|
||||
Model.write([translated_model], {'name': "NameTranslated"})
|
||||
Model.write([translated_model], {'string': "NameTranslated"})
|
||||
|
||||
values = NameTranslated.read([record.id], ['name'])
|
||||
self.assertEqual(values[0]['name'], "Foo")
|
||||
|
||||
Reference in new issue
Block a user