Rename ir.model 'model' field into 'name'

This commit is contained in:
Cédric Krier
2024-11-16 21:17:55 +01:00
parent a89fc8bf1c
commit 7449eda49c
26 changed files with 120 additions and 115 deletions
+2 -2
View File
@@ -94,7 +94,7 @@ class Email(ModelSQL, ModelView):
triggers = fields.One2Many(
'ir.trigger', 'notification_email', "Triggers",
domain=[('model.model', '=', Eval('model'))],
domain=[('model.name', '=', Eval('model'))],
help="Add a trigger for the notification.")
send_after = fields.TimeDelta(
"Send After",
@@ -122,7 +122,7 @@ class Email(ModelSQL, ModelView):
field.domain.append(['OR',
('relation', 'in', EmailTemplate.email_models()),
[
('model.model', 'in', EmailTemplate.email_models()),
('model.name', 'in', EmailTemplate.email_models()),
('name', '=', 'id'),
],
])
@@ -92,7 +92,7 @@ class NotificationEmailTestCase(CompanyTestMixin, ModuleTestCase):
notification_email, = NotificationEmail.search([])
model, = Model.search([
('model', '=', User.__name__),
('name', '=', User.__name__),
])
trigger, = Trigger.create([{
'name': 'Test creation',
@@ -143,7 +143,7 @@ class NotificationEmailTestCase(CompanyTestMixin, ModuleTestCase):
notification_email, = NotificationEmail.search([])
model, = Model.search([
('model', '=', User.__name__),
('name', '=', User.__name__),
])
trigger, = Trigger.create([{
'name': 'Test creation',
@@ -186,7 +186,7 @@ class NotificationEmailTestCase(CompanyTestMixin, ModuleTestCase):
notification_email.save()
model, = Model.search([
('model', '=', User.__name__),
('name', '=', User.__name__),
])
Trigger.create([{
'name': 'Test creation',
@@ -219,7 +219,7 @@ class NotificationEmailTestCase(CompanyTestMixin, ModuleTestCase):
self._setup_notification()
model, = Model.search([
('model', '=', User.__name__),
('name', '=', User.__name__),
])
en, = Language.search([('code', '=', 'en')])
@@ -228,7 +228,7 @@ class NotificationEmailTestCase(CompanyTestMixin, ModuleTestCase):
attachment.report_name = 'notification_notification.test.report'
attachment.template_extension = 'txt'
attachment.report_content = b'attachment for ${records[0].name}'
attachment.model = model.model
attachment.model = model.name
attachment.save()
notification_email, = NotificationEmail.search([])
@@ -265,7 +265,7 @@ class NotificationEmailTestCase(CompanyTestMixin, ModuleTestCase):
self._setup_notification()
model, = Model.search([
('model', '=', User.__name__),
('name', '=', User.__name__),
])
en, = Language.search([('code', '=', 'en')])
@@ -291,7 +291,7 @@ class NotificationEmailTestCase(CompanyTestMixin, ModuleTestCase):
self._setup_notification()
model, = Model.search([
('model', '=', User.__name__),
('name', '=', User.__name__),
])
es, = Language.search([('code', '=', 'es')])
Language.load_translations([es])
@@ -341,7 +341,7 @@ class NotificationEmailTestCase(CompanyTestMixin, ModuleTestCase):
notification_email.save()
model, = Model.search([
('model', '=', User.__name__),
('name', '=', User.__name__),
])
Trigger.create([{
'name': 'Test creation',
@@ -378,7 +378,7 @@ class NotificationEmailTestCase(CompanyTestMixin, ModuleTestCase):
notification_email.save()
model, = Model.search([
('model', '=', User.__name__),
('name', '=', User.__name__),
])
Trigger.create([{
'name': 'Test creation',
+4 -4
View File
@@ -467,9 +467,9 @@ class Inspection(Workflow, ModelSQL, ModelView):
IrModel = pool.get('ir.model')
models = cls._get_origins()
models = IrModel.search([
('model', 'in', models),
('name', 'in', models),
])
return [(None, '')] + [(m.model, m.string) for m in models]
return [(None, '')] + [(m.name, m.string) for m in models]
@fields.depends('control', 'points')
def on_change_control(self):
@@ -693,9 +693,9 @@ class Alert(Workflow, ModelSQL, ModelView):
IrModel = pool.get('ir.model')
models = cls._get_origins()
models = IrModel.search([
('model', 'in', models),
('name', 'in', models),
])
return [(None, '')] + [(m.model, m.string) for m in models]
return [(None, '')] + [(m.name, m.string) for m in models]
@classmethod
@ModelView.button
+3 -2
View File
@@ -29,7 +29,8 @@ class Type(DeactivableMixin, ModelSQL, ModelView):
name = fields.Char('Name', required=True)
origin = fields.Many2One('ir.model', 'Origin', required=True,
domain=[('model', 'in', ['sale.sale', 'sale.line',
domain=[('name', 'in', [
'sale.sale', 'sale.line',
'account.invoice', 'account.invoice.line'])])
@@ -241,7 +242,7 @@ class Complaint(Workflow, ModelSQL, ModelView):
def get_origin(self):
if self.type:
origin = self.type.origin
return [('', ''), (origin.model, origin.name)]
return [('', ''), (origin.name, origin.name)]
else:
return []
+1 -1
View File
@@ -155,7 +155,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">Complaints</field>
<field name="res_model">sale.complaint</field>
<field name="domain"
eval="[['OR', ('origin.id', 'in', Eval('active_ids'), 'sale.sale'), ('origin.sale', 'in', Eval('active_ids'), 'sale.line')], ('type.origin.model', 'in', ['sale.sale', 'sale.line'])]"
eval="[['OR', ('origin.id', 'in', Eval('active_ids'), 'sale.sale'), ('origin.sale', 'in', Eval('active_ids'), 'sale.line')], ('type.origin.name', 'in', ['sale.sale', 'sale.line'])]"
pyson="1"/>
</record>
<record model="ir.action.act_window.view"
@@ -40,18 +40,18 @@ Create complaint type::
>>> Type = Model.get('sale.complaint.type')
>>> IrModel = Model.get('ir.model')
>>> sale_type = Type(name='Sale')
>>> sale_type.origin, = IrModel.find([('model', '=', 'sale.sale')])
>>> sale_type.origin, = IrModel.find([('name', '=', 'sale.sale')])
>>> sale_type.save()
>>> sale_line_type = Type(name='Sale Line')
>>> sale_line_type.origin, = IrModel.find([('model', '=', 'sale.line')])
>>> sale_line_type.origin, = IrModel.find([('name', '=', 'sale.line')])
>>> sale_line_type.save()
>>> invoice_type = Type(name='Invoice')
>>> invoice_type.origin, = IrModel.find(
... [('model', '=', 'account.invoice')])
... [('name', '=', 'account.invoice')])
>>> invoice_type.save()
>>> invoice_line_type = Type(name='Invoice Line')
>>> invoice_line_type.origin, = IrModel.find(
... [('model', '=', 'account.invoice.line')])
... [('name', '=', 'account.invoice.line')])
>>> invoice_line_type.save()
Create account category::
+1 -1
View File
@@ -1,4 +1,4 @@
* Rename ir.model 'name' field into 'string'
* Rename ir.model 'name' field into 'string' and 'model' into 'name'
Version 7.4.0 - 2024-11-04
--------------------------
+3 -3
View File
@@ -9,14 +9,14 @@ CREATE TABLE ir_configuration (
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 NOT NULL,
string VARCHAR,
info TEXT,
module VARCHAR,
PRIMARY KEY(id)
);
ALTER TABLE ir_model ADD CONSTRAINT ir_model_model_uniq UNIQUE (model);
ALTER TABLE ir_model ADD CONSTRAINT ir_model_name_unique UNIQUE (name);
CREATE TABLE ir_model_field (
id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL
@@ -30,7 +30,7 @@ CREATE TABLE ir_model_field (
module VARCHAR,
"access" BOOL,
PRIMARY KEY(id),
FOREIGN KEY (model) REFERENCES ir_model(model) ON DELETE CASCADE
FOREIGN KEY (model) REFERENCES ir_model(name) ON DELETE CASCADE
);
ALTER TABLE ir_model_field ADD CONSTRAINT ir_model_field_name_model_uniq UNIQUE (name, model);
+1 -1
View File
@@ -10,7 +10,7 @@ CREATE TABLE ir_configuration (
CREATE TABLE ir_model (
id INTEGER PRIMARY KEY AUTOINCREMENT,
model VARCHAR,
name VARCHAR,
string VARCHAR,
info TEXT,
module VARCHAR,
+4 -4
View File
@@ -465,7 +465,7 @@ class ActionMixin(ModelSQL):
class ActionReport(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
ondelete='CASCADE'),
fields.fmany2one(
'module_ref', 'module', 'ir.module,name', "Module",
@@ -729,10 +729,10 @@ class ActionReport(
class ActionActWindow(
fields.fmany2one(
'res_model_ref', 'res_model', 'ir.model,model', "Model",
'res_model_ref', 'res_model', 'ir.model,name', "Model",
ondelete='CASCADE'),
fields.fmany2one(
'context_model_ref', 'context_model', 'ir.model,model',
'context_model_ref', 'context_model', 'ir.model,name',
"Context Model", ondelete='CASCADE'),
ActionMixin, ModelSQL, ModelView):
"Action act window"
@@ -1076,7 +1076,7 @@ class ActionActWindowDomain(
class ActionWizard(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
ondelete='CASCADE'),
ActionMixin, ModelSQL, ModelView):
"Action wizard"
+4 -4
View File
@@ -330,7 +330,7 @@ class EmailTemplate(ModelSQL, ModelView):
@fields.depends('model')
def on_change_with_model_name(self, name=None):
if self.model:
return self.model.model
return self.model.name
@classmethod
def validate_fields(cls, templates, field_names):
@@ -403,7 +403,7 @@ class EmailTemplate(ModelSQL, ModelView):
def get(self, record):
pool = Pool()
Model = pool.get(self.model.model)
Model = pool.get(self.model.name)
record = Model(int(record))
values = {}
@@ -485,12 +485,12 @@ class EmailTemplate(ModelSQL, ModelView):
values = {}
fields = Field.search([
('model.model', '=', model),
('model.name', '=', model),
('name', 'not in', cls._get_default_exclude(record)),
['OR',
('relation', 'in', cls.email_models()),
[
('model.model', 'in', cls.email_models()),
('model.name', 'in', cls.email_models()),
('name', '=', 'id'),
],
],
+51 -47
View File
@@ -53,11 +53,11 @@ class Model(
states={
'readonly': Bool(Eval('module')),
})
model = fields.Char('Model Name', required=True,
name = fields.Char(
"Name", required=True,
states={
'readonly': Bool(Eval('module')),
},
depends=['module'])
})
info = fields.Text('Information',
states={
'readonly': Bool(Eval('module')),
@@ -73,10 +73,10 @@ class Model(
super(Model, cls).__setup__()
table = cls.__table__()
cls._sql_constraints += [
('model_uniq', Unique(table, table.model),
('name_unique', Unique(table, table.name),
'The model must be unique!'),
]
cls._order.insert(0, ('model', 'ASC'))
cls._order.insert(0, ('name', 'ASC'))
cls.__rpc__.update({
'list_models': RPC(),
'list_history': RPC(),
@@ -89,8 +89,12 @@ class Model(
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')
# Migration from 7.4:
# rename column name into string and model into name
if table_h.column_exist('model'):
table_h.column_rename('name', 'string')
table_h.column_rename('model', 'name')
table_h.drop_constraint('model_uniq')
super().__register__(module)
@@ -100,7 +104,7 @@ class Model(
ir_model = cls.__table__()
cursor.execute(*ir_model.select(ir_model.id,
where=ir_model.model == model.__name__))
where=ir_model.name == model.__name__))
model_id = None
if cursor.rowcount == -1 or cursor.rowcount is None:
data = cursor.fetchone()
@@ -110,17 +114,17 @@ class Model(
model_id, = cursor.fetchone()
if not model_id:
cursor.execute(*ir_model.insert(
[ir_model.model, ir_model.string, ir_model.info,
[ir_model.name, ir_model.string, ir_model.info,
ir_model.module],
[[
model.__name__, model._get_name(), model.__doc__,
module_name]]))
cursor.execute(*ir_model.select(ir_model.id,
where=ir_model.model == model.__name__))
where=ir_model.name == model.__name__))
(model_id,) = cursor.fetchone()
elif model.__doc__:
cursor.execute(*ir_model.update(
[ir_model.name, ir_model.info],
[ir_model.string, ir_model.info],
[model._get_name(), model.__doc__],
where=ir_model.id == model_id))
cls._get_names_cache.clear()
@@ -132,29 +136,29 @@ class Model(
transaction = Transaction()
cursor = transaction.connection.cursor()
ir_model = cls.__table__()
cursor.execute(*ir_model.select(ir_model.model, ir_model.id))
for model, id_ in cursor:
cursor.execute(*ir_model.select(ir_model.name, ir_model.id))
for name, id_ in cursor:
try:
pool.get(model)
pool.get(name)
except KeyError:
logger.info("remove model: %s", model)
logger.info("remove model: %s", name)
try:
cls.delete([cls(id_)])
transaction.commit()
except Exception:
transaction.rollback()
logger.error(
"could not delete model: %s", model, exc_info=True)
"could not delete model: %s", name, exc_info=True)
@classmethod
def list_models(cls):
'Return a list of all models names'
models = cls.search([], order=[
('module', 'ASC'), # Optimization assumption
('model', 'ASC'),
('name', 'ASC'),
('id', 'ASC'),
])
return [m.model for m in models]
return [m.name for m in models]
@classmethod
def list_history(cls):
@@ -177,7 +181,7 @@ class Model(
items = cls._get_names_cache.get('items')
if items is None:
models = cls.search([])
items = [(m.model, m.string) for m in models]
items = [(m.name, m.string) for m in models]
cls._get_names_cache.set('items', items)
return items
@@ -205,9 +209,9 @@ class Model(
models = cls.search(['OR',
('global_search_p', '=', True),
('model', '=', menu),
('name', '=', menu),
])
access = ModelAccess.get_access([m.model for m in models])
access = ModelAccess.get_access([m.name for m in models])
s = StringMatcher()
if isinstance(text, bytes):
text = text.decode('utf-8')
@@ -215,16 +219,16 @@ class Model(
def generate():
for model in models:
if not access[model.model]['read']:
if not access[model.name]['read']:
continue
Model = pool.get(model.model)
Model = pool.get(model.name)
if not hasattr(Model, 'search_global'):
continue
for record, name, icon in Model.search_global(text):
if isinstance(name, bytes):
name = name.decode('utf-8')
s.set_seq1(name)
yield (s.ratio(), model.model, model.rec_name,
yield (s.ratio(), model.name, model.rec_name,
record.id, name, icon)
return heapq.nlargest(int(limit), generate())
@@ -235,7 +239,7 @@ class Model(
class ModelField(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
required=True, ondelete='CASCADE'),
fields.fmany2one(
'module_ref', 'module', 'ir.module,name', "Module",
@@ -314,7 +318,7 @@ class ModelField(
table_h.column_rename('model', '_temp_model')
table_h.add_column('model', 'VARCHAR')
cursor.execute(*table.update(
[table.model], [model.model],
[table.model], [model.name],
from_=[model],
where=table._temp_model == model.id))
table_h.drop_column('_temp_model')
@@ -443,7 +447,7 @@ class ModelField(
name = cls._get_name_cache.get((model, field))
if name is None:
fields = cls.search([
('model.model', '=', model),
('model.name', '=', model),
('name', '=', field),
], limit=1)
if fields:
@@ -509,7 +513,7 @@ class ModelField(
class ModelAccess(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
required=True, ondelete='CASCADE'),
DeactivableMixin, ModelSQL, ModelView):
"Model access"
@@ -548,7 +552,7 @@ class ModelAccess(
table_h.column_rename('model', '_temp_model')
table_h.add_column('model', 'VARCHAR')
cursor.execute(*table.update(
[table.model], [model.model],
[table.model], [model.name],
from_=[model],
where=table._temp_model == model.id))
table_h.drop_column('_temp_model')
@@ -761,7 +765,7 @@ class ModelAccess(
class ModelFieldAccess(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
required=True, ondelete='CASCADE'),
fields.fmany2one(
'field_ref', 'field,model', 'ir.model.field,name,model', "Field",
@@ -955,7 +959,7 @@ class ModelFieldAccess(
class ModelButton(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
required=True, readonly=True, ondelete='CASCADE'),
DeactivableMixin, ModelSQL, ModelView):
"Model Button"
@@ -1002,7 +1006,7 @@ class ModelButton(
table_h.column_rename('model', '_temp_model')
table_h.add_column('model', 'VARCHAR')
cursor.execute(*table.update(
[table.model], [model.model],
[table.model], [model.name],
from_=[model],
where=table._temp_model == model.id))
table_h.drop_column('_temp_model')
@@ -1226,7 +1230,7 @@ class ModelButtonClick(DeactivableMixin, ModelSQL, ModelView):
user = Transaction().user
button, = Button.search([
('model.model', '=', model),
('model.name', '=', model),
('name', '=', name),
])
cls.create([{
@@ -1254,7 +1258,7 @@ class ModelButtonClick(DeactivableMixin, ModelSQL, ModelView):
clicks = []
for records in grouped_slice(records):
clicks.extend(cls.search([
('button.model.model', '=', model),
('button.model.name', '=', model),
('button.name', 'in', names),
('record_id', 'in', [r.id for r in records]),
]))
@@ -1265,7 +1269,7 @@ class ModelButtonClick(DeactivableMixin, ModelSQL, ModelView):
@classmethod
def get_click(cls, model, button, record_id):
clicks = cls.search([
('button.model.model', '=', model),
('button.model.name', '=', model),
('button.name', '=', button),
('record_id', '=', record_id),
])
@@ -1285,7 +1289,7 @@ class ModelButtonReset(ModelSQL):
class ModelData(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
required=True, ondelete='CASCADE'),
fields.fmany2one(
'module_ref', 'module', 'ir.module,name', "Module",
@@ -1690,9 +1694,9 @@ class ModelGraph(Report):
filter=filter)
for model in models:
if filter and re.search(filter, model.model):
if filter and re.search(filter, model.name):
continue
label = '"{' + model.model + '\\n'
label = '"{' + model.name + '\\n'
if model.fields:
label += '|'
for field in model.fields:
@@ -1704,7 +1708,7 @@ class ModelGraph(Report):
label += ' ' + field.relation
label += '\\l'
label += '}"'
node_name = '"%s"' % model.model
node_name = '"%s"' % model.name
node = pydot.Node(node_name, shape='record', label=label)
graph.add_node(node)
@@ -1716,9 +1720,9 @@ class ModelGraph(Report):
if not graph.get_node(node_name):
continue
args = {}
tail = model.model
tail = model.name
head = field.relation
edge_model_name = '"%s"' % model.model
edge_model_name = '"%s"' % model.name
edge_relation_name = '"%s"' % field.relation
if field.ttype == 'many2one':
edge = graph.get_edge(edge_model_name,
@@ -1733,7 +1737,7 @@ class ModelGraph(Report):
continue
args['arrowhead'] = "normal"
tail = field.relation
head = model.model
head = model.name
elif field.ttype == 'many2many':
if graph.get_edge(edge_model_name, edge_relation_name):
continue
@@ -1781,23 +1785,23 @@ class ModelWorkflowGraph(Report):
pool = Pool()
for record in models:
Model = pool.get(record.model)
Model = pool.get(record.name)
if not issubclass(Model, Workflow):
continue
subgraph = pydot.Cluster('%s' % record.id, label=record.model)
subgraph = pydot.Cluster('%s' % record.id, label=record.name)
graph.add_subgraph(subgraph)
state_field = getattr(Model, Model._transition_state)
for state, _ in state_field.selection:
node = pydot.Node(
f'"{record.model}--{state}"', shape='octagon', label=state)
f'"{record.name}--{state}"', shape='octagon', label=state)
subgraph.add_node(node)
for from_, to in Model._transitions:
edge = pydot.Edge(
f'"{record.model}--{from_}"',
f'"{record.model}--{to}"',
f'"{record.name}--{from_}"',
f'"{record.name}--{to}"',
arrowhead='normal')
subgraph.add_edge(edge)
+1 -1
View File
@@ -48,7 +48,7 @@ def html_editor(request, pool, model, record, field):
Field = pool.get('ir.model.field')
field, = Field.search([
('name', '=', field),
('model.model', '=', model),
('model.name', '=', model),
])
transaction = Transaction()
+2 -2
View File
@@ -41,7 +41,7 @@ def _get_access_models(Model, names=None, model2field=None, path=None):
class RuleGroup(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
required=True, ondelete='CASCADE'),
ModelSQL, ModelView):
"Rule group"
@@ -96,7 +96,7 @@ class RuleGroup(
table_h.column_rename('model', '_temp_model')
table_h.add_column('model', 'VARCHAR')
cursor.execute(*table.update(
[table.model], [model.model],
[table.model], [model.name],
from_=[model],
where=table._temp_model == model.id))
table_h.drop_column('_temp_model')
+4 -4
View File
@@ -350,7 +350,7 @@ class Translation(
if ttype in ('field', 'help'):
name = record.model + ',' + record.name
else:
name = record.model + ',' + field_name
name = record.name + ',' + field_name
trans_args.append((name, ttype, lang, None))
cls.get_sources(trans_args)
@@ -358,7 +358,7 @@ class Translation(
if ttype in ('field', 'help'):
name = record.model + ',' + record.name
else:
name = record.model + ',' + field_name
name = record.name + ',' + field_name
translations[record.id] = cls.get_source(name, ttype, lang)
if translations[record.id] is None:
with Transaction().set_context(language=lang):
@@ -375,7 +375,7 @@ class Translation(
value = field.help
else:
try:
model = pool.get(record.model)
model = pool.get(record.name)
except KeyError:
continue
if not model.__doc__:
@@ -467,7 +467,7 @@ class Translation(
if ttype in ('field', 'help'):
return record.model + ',' + record.name
else:
return record.model + ',' + field_name
return record.name + ',' + field_name
name2translations = defaultdict(list)
for translation in cls.search([
+4 -4
View File
@@ -90,7 +90,7 @@ class Trigger(DeactivableMixin, ModelSQL, ModelView):
Model = pool.get('ir.model')
model = Model.__table__()
action_model = model.select(
model.model, where=model.id == sql_table.action_model)
model.name, where=model.id == sql_table.action_model)
cursor.execute(*sql_table.update(
[sql_table.action],
[Concat(action_model, Concat(
@@ -162,7 +162,7 @@ class Trigger(DeactivableMixin, ModelSQL, ModelView):
return cls.browse(trigger_ids)
triggers = cls.search([
('model.model', '=', model_name),
('model.name', '=', model_name),
('on_%s' % mode, '=', True),
])
cls._get_triggers_cache.set(key, list(map(int, triggers)))
@@ -192,7 +192,7 @@ class Trigger(DeactivableMixin, ModelSQL, ModelView):
"""
pool = Pool()
TriggerLog = pool.get('ir.trigger.log')
Model = pool.get(self.model.model)
Model = pool.get(self.model.name)
model, method = self.action.split('|')
ActionModel = pool.get(model)
cursor = Transaction().connection.cursor()
@@ -271,7 +271,7 @@ class Trigger(DeactivableMixin, ModelSQL, ModelView):
('on_time', '=', True),
])
for trigger in triggers:
Model = pool.get(trigger.model.model)
Model = pool.get(trigger.model.name)
# TODO add a domain
records = Model.search([])
trigger.trigger_action(records)
+5 -5
View File
@@ -26,7 +26,7 @@ class XMLError(ValidationError):
class View(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
ondelete='CASCADE'),
fields.fmany2one(
'field_children', 'field_childs,model',
@@ -445,7 +445,7 @@ class ShowView(Wizard):
class ViewTreeWidth(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
required=True, ondelete='CASCADE'),
fields.fmany2one(
'field_ref', 'field,model', 'ir.model.field,name,model', "Field",
@@ -534,7 +534,7 @@ class ViewTreeWidth(
class ViewTreeOptional(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
required=True, ondelete='CASCADE'),
fields.fmany2one(
'field_ref', 'field,model', 'ir.model.field,name,model', "Field",
@@ -644,7 +644,7 @@ class ViewTreeOptional(
class ViewTreeState(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
required=True, ondelete='CASCADE'),
fields.fmany2one(
'child_field', 'child_name,model', 'ir.model.field,name,model',
@@ -732,7 +732,7 @@ class ViewTreeState(
class ViewSearch(
fields.fmany2one(
'model_ref', 'model', 'ir.model,model', "Model",
'model_ref', 'model', 'ir.model,name', "Model",
required=True, ondelete='CASCADE'),
ModelSQL, ModelView):
"View Search"
+2 -2
View File
@@ -4,8 +4,8 @@ this repository contains the full copyright notices and license terms. -->
<form col="6">
<label name="string"/>
<field name="string"/>
<label name="model"/>
<field name="model"/>
<label name="name"/>
<field name="name"/>
<label name="module_ref"/>
<field name="module_ref"/>
<label name="global_search_p"/>
+1 -1
View File
@@ -3,7 +3,7 @@
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="string" expand="2"/>
<field name="model" expand="1"/>
<field name="name" expand="1" optional="1"/>
<field name="info" expand="1" optional="1"/>
<field name="global_search_p"/>
<field name="module_ref" optional="1"/>
+1 -1
View File
@@ -628,7 +628,7 @@ class FieldTranslate(Field):
translation.name.as_('name'),
group_by=[translation.res_id, translation.name])
if Model.__name__ == 'ir.model':
name_ = Concat(Concat(table.model, ','), name)
name_ = Concat(Concat(table.name, ','), name)
type_ = 'model'
res_id = -1
elif Model.__name__ == 'ir.model.field':
+1 -1
View File
@@ -356,7 +356,7 @@ class ModelView(Model):
[('resource', '=', cls.__name__)],
fields_names=['name', 'header', 'records', 'export_fields.name'])
emails = Email.search_read(
[('model.model', '=', cls.__name__)],
[('model.name', '=', cls.__name__)],
fields_names=['name'])
result = {
'print': prints,
+1 -1
View File
@@ -160,7 +160,7 @@ class ModelButton(metaclass=PoolMeta):
if groups is not None:
return groups
buttons = cls.search([
('model.model', '=', model),
('model.name', '=', model),
('name', '=', name),
])
if not buttons:
+4 -4
View File
@@ -429,7 +429,7 @@ class IrTestCase(ModuleTestCase):
admin = User(1)
admin.email = 'admin@example.com'
admin.save()
model, = IrModel.search([('model', '=', 'res.user')])
model, = IrModel.search([('name', '=', 'res.user')])
field, = IrModelField.search([
('model', '=', 'res.user'),
('name', '=', 'id'),
@@ -464,7 +464,7 @@ class IrTestCase(ModuleTestCase):
admin = User(1)
admin.email = 'admin@example.com'
admin.save()
model, = IrModel.search([('model', '=', 'res.user')])
model, = IrModel.search([('name', '=', 'res.user')])
field, = IrModelField.search([
('model', '=', 'res.user'),
('name', '=', 'id'),
@@ -490,7 +490,7 @@ class IrTestCase(ModuleTestCase):
admin = User(1)
admin.email = 'admin@example.com'
admin.save()
model, = IrModel.search([('model', '=', 'res.user')])
model, = IrModel.search([('name', '=', 'res.user')])
field, = IrModelField.search([
('model', '=', 'res.user'),
('name', '=', 'id'),
@@ -607,7 +607,7 @@ class IrCronTestCase(TestCase):
Model = pool.get('ir.model')
ModelWorkflowGraph = pool.get('ir.model.workflow_graph', type='report')
model, = Model.search([('model', '=', 'ir.error')])
model, = Model.search([('name', '=', 'ir.error')])
oext, content, print_, filename = (
ModelWorkflowGraph.execute([model.id], {}))
+1 -1
View File
@@ -1530,7 +1530,7 @@ class ModelSQLTranslationTestCase(TranslationTestCase):
self.assertEqual(values[0]['name'], "Foo")
translated_model, = Model.search([
('model', '=', 'test.modelsql.name_translated'),
('name', '=', 'test.modelsql.name_translated'),
])
Model.write([translated_model], {'string': "NameTranslated"})
+5 -5
View File
@@ -41,7 +41,7 @@ class TriggerTestCase(TestCase):
transaction = Transaction()
model, = Model.search([
('model', '=', 'test.triggered'),
('name', '=', 'test.triggered'),
])
values = {
@@ -85,7 +85,7 @@ class TriggerTestCase(TestCase):
Triggered = pool.get('test.triggered')
model, = Model.search([
('model', '=', 'test.triggered'),
('name', '=', 'test.triggered'),
])
trigger, = Trigger.create([{
@@ -163,7 +163,7 @@ class TriggerTestCase(TestCase):
Triggered = pool.get('test.triggered')
model, = Model.search([
('model', '=', 'test.triggered'),
('name', '=', 'test.triggered'),
])
trigger, = Trigger.create([{
@@ -295,7 +295,7 @@ class TriggerTestCase(TestCase):
TriggerLog = pool.get('ir.trigger.log')
model, = Model.search([
('model', '=', 'test.triggered'),
('name', '=', 'test.triggered'),
])
triggered, = Triggered.create([{
@@ -386,7 +386,7 @@ class TriggerTestCase(TestCase):
TriggerLog = pool.get('ir.trigger.log')
model, = Model.search([
('model', '=', 'test.triggered'),
('name', '=', 'test.triggered'),
])
trigger, = Trigger.create([{
+1 -1
View File
@@ -1029,7 +1029,7 @@ class ModuleTestCase(_DBTestCase):
if not issubclass(model, ModelView):
continue
ir_buttons = {b.name for b in Button.search([
('model.model', '=', model.__name__),
('model.name', '=', model.__name__),
])}
buttons = set(model._buttons)
with self.subTest(model=mname):