diff --git a/modules/notification_email/notification.py b/modules/notification_email/notification.py index cdac01632f..a7adc568b0 100644 --- a/modules/notification_email/notification.py +++ b/modules/notification_email/notification.py @@ -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'), ], ]) diff --git a/modules/notification_email/tests/test_module.py b/modules/notification_email/tests/test_module.py index bab5b59224..bf8a7c410c 100644 --- a/modules/notification_email/tests/test_module.py +++ b/modules/notification_email/tests/test_module.py @@ -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', diff --git a/modules/quality/quality.py b/modules/quality/quality.py index 6f82c60542..5a64140d59 100644 --- a/modules/quality/quality.py +++ b/modules/quality/quality.py @@ -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 diff --git a/modules/sale_complaint/complaint.py b/modules/sale_complaint/complaint.py index f0582d2a84..93f28986a3 100644 --- a/modules/sale_complaint/complaint.py +++ b/modules/sale_complaint/complaint.py @@ -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 [] diff --git a/modules/sale_complaint/complaint.xml b/modules/sale_complaint/complaint.xml index ba495b830d..9aae795aa8 100644 --- a/modules/sale_complaint/complaint.xml +++ b/modules/sale_complaint/complaint.xml @@ -155,7 +155,7 @@ this repository contains the full copyright notices and license terms. --> Complaints sale.complaint >> 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:: diff --git a/trytond/CHANGELOG b/trytond/CHANGELOG index b75b2485d8..85e0478e70 100644 --- a/trytond/CHANGELOG +++ b/trytond/CHANGELOG @@ -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 -------------------------- diff --git a/trytond/trytond/backend/postgresql/init.sql b/trytond/trytond/backend/postgresql/init.sql index 09882f4b35..d815fda1a5 100644 --- a/trytond/trytond/backend/postgresql/init.sql +++ b/trytond/trytond/backend/postgresql/init.sql @@ -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); diff --git a/trytond/trytond/backend/sqlite/init.sql b/trytond/trytond/backend/sqlite/init.sql index f36e162402..53ae77d989 100644 --- a/trytond/trytond/backend/sqlite/init.sql +++ b/trytond/trytond/backend/sqlite/init.sql @@ -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, diff --git a/trytond/trytond/ir/action.py b/trytond/trytond/ir/action.py index 333451224a..4a995f1722 100644 --- a/trytond/trytond/ir/action.py +++ b/trytond/trytond/ir/action.py @@ -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" diff --git a/trytond/trytond/ir/email_.py b/trytond/trytond/ir/email_.py index 179b8ba3cc..ca736522e9 100644 --- a/trytond/trytond/ir/email_.py +++ b/trytond/trytond/ir/email_.py @@ -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'), ], ], diff --git a/trytond/trytond/ir/model.py b/trytond/trytond/ir/model.py index e7692e61e9..f5c9f454b7 100644 --- a/trytond/trytond/ir/model.py +++ b/trytond/trytond/ir/model.py @@ -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) diff --git a/trytond/trytond/ir/routes.py b/trytond/trytond/ir/routes.py index d2957e7006..48ef735ea2 100644 --- a/trytond/trytond/ir/routes.py +++ b/trytond/trytond/ir/routes.py @@ -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() diff --git a/trytond/trytond/ir/rule.py b/trytond/trytond/ir/rule.py index e8e05205d2..9ee552bbf0 100644 --- a/trytond/trytond/ir/rule.py +++ b/trytond/trytond/ir/rule.py @@ -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') diff --git a/trytond/trytond/ir/translation.py b/trytond/trytond/ir/translation.py index 7d604573ae..f273330b4a 100644 --- a/trytond/trytond/ir/translation.py +++ b/trytond/trytond/ir/translation.py @@ -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([ diff --git a/trytond/trytond/ir/trigger.py b/trytond/trytond/ir/trigger.py index 74427eee8a..57e28ce177 100644 --- a/trytond/trytond/ir/trigger.py +++ b/trytond/trytond/ir/trigger.py @@ -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) diff --git a/trytond/trytond/ir/ui/view.py b/trytond/trytond/ir/ui/view.py index 4c09d5fe3a..1b8c3c770d 100644 --- a/trytond/trytond/ir/ui/view.py +++ b/trytond/trytond/ir/ui/view.py @@ -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" diff --git a/trytond/trytond/ir/view/model_form.xml b/trytond/trytond/ir/view/model_form.xml index dfe1ae0269..abcb0e7e6b 100644 --- a/trytond/trytond/ir/view/model_form.xml +++ b/trytond/trytond/ir/view/model_form.xml @@ -4,8 +4,8 @@ this repository contains the full copyright notices and license terms. -->