From 5dc4cff60a557e14b08440c227423291c407899b Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 12 Apr 2021 08:40:44 +0200 Subject: [PATCH 01/13] [IMP] base: remove read access to ir.model* Model, fields and selections are no longer readable Removes metadata access --- addons/calendar/tests/test_calendar.py | 4 ++-- odoo/addons/base/security/ir.model.access.csv | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/calendar/tests/test_calendar.py b/addons/calendar/tests/test_calendar.py index 4083877516c..57e8bde171f 100644 --- a/addons/calendar/tests/test_calendar.py +++ b/addons/calendar/tests/test_calendar.py @@ -195,7 +195,7 @@ class TestCalendar(SavepointCaseWithUserDemo): activity_id = self.env['mail.activity'].create({ 'summary': 'Meeting with partner', 'activity_type_id': activty_type.id, - 'res_model_id': self.env['ir.model'].search([('model', '=', 'res.partner')], limit=1).id, + 'res_model_id': self.env['ir.model']._get_id('res.partner'), 'res_id': self.env['res.partner'].create({'name': 'A Partner'}).id, }) @@ -228,7 +228,7 @@ class TestCalendar(SavepointCaseWithUserDemo): activity_id = self.env['mail.activity'].create({ 'summary': 'Meeting with partner', 'activity_type_id': activty_type.id, - 'res_model_id': self.env['ir.model'].search([('model', '=', 'res.partner')], limit=1).id, + 'res_model_id': self.env['ir.model']._get_id('res.partner'), 'res_id': self.env['res.partner'].create({'name': 'A Partner'}).id, }) diff --git a/odoo/addons/base/security/ir.model.access.csv b/odoo/addons/base/security/ir.model.access.csv index 581755cea21..9b649170f85 100644 --- a/odoo/addons/base/security/ir.model.access.csv +++ b/odoo/addons/base/security/ir.model.access.csv @@ -13,10 +13,10 @@ "access_ir_model_data_group_erp_manager","ir_model_data group_erp_manager","model_ir_model_data","group_erp_manager",1,1,1,1 "access_ir_model_fields_group_erp_manager","ir_model_fields group_erp_manager","model_ir_model_fields","group_erp_manager",1,1,1,1 "access_ir_model_fields_selection_group_erp_manager","ir_model_fields_selection group_erp_manager","model_ir_model_fields_selection","group_erp_manager",1,1,1,1 -"access_ir_model_user","ir_model_all","model_ir_model",base.group_user,1,0,0,0 -"access_ir_model_data_user","ir_model_data user","model_ir_model_data",base.group_user,1,0,1,0 -"access_ir_model_fields_user","ir_model_fields all","model_ir_model_fields",base.group_user,1,0,0,0 -"access_ir_model_fields_selection_user","ir_model_fields_selection all","model_ir_model_fields_selection",base.group_user,1,0,0,0 +"access_ir_model_user","ir_model_all","model_ir_model",base.group_user,0,0,0,0 +"access_ir_model_data_user","ir_model_data user","model_ir_model_data",base.group_user,0,0,0,0 +"access_ir_model_fields_user","ir_model_fields all","model_ir_model_fields",base.group_user,0,0,0,0 +"access_ir_model_fields_selection_user","ir_model_fields_selection all","model_ir_model_fields_selection",base.group_user,0,0,0,0 "access_ir_module_category_group_user","ir_module_category group_user","model_ir_module_category","group_erp_manager",1,0,0,0 "access_ir_module_module_group_user","ir_module_module group_user","model_ir_module_module","group_system",1,1,1,1 "access_ir_module_module_dependency_group_system","ir_module_module_dependency group_system","model_ir_module_module_dependency","group_system",1,1,1,1 From 03ff8d4d5824c07b8d811caf6a3a0bc679c41c8e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 12 Apr 2021 09:24:16 +0200 Subject: [PATCH 02/13] [FIX] *: retrieve model with sudo in selection fields --- addons/mail/wizard/mail_template_preview.py | 2 +- addons/rating/models/rating.py | 2 +- addons/sms/wizard/sms_template_preview.py | 3 +-- odoo/addons/base/models/ir_actions.py | 8 +------- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/addons/mail/wizard/mail_template_preview.py b/addons/mail/wizard/mail_template_preview.py index 03062beee74..80506c2a2bd 100644 --- a/addons/mail/wizard/mail_template_preview.py +++ b/addons/mail/wizard/mail_template_preview.py @@ -13,7 +13,7 @@ class MailTemplatePreview(models.TransientModel): @api.model def _selection_target_model(self): - return [(model.model, model.name) for model in self.env['ir.model'].search([])] + return [(model.model, model.name) for model in self.env['ir.model'].sudo().search([])] @api.model def _selection_languages(self): diff --git a/addons/rating/models/rating.py b/addons/rating/models/rating.py index eabb1adbb4d..5f2f5a66d8e 100644 --- a/addons/rating/models/rating.py +++ b/addons/rating/models/rating.py @@ -33,7 +33,7 @@ class Rating(models.Model): @api.model def _selection_target_model(self): - return [(model.model, model.name) for model in self.env['ir.model'].search([])] + return [(model.model, model.name) for model in self.env['ir.model'].sudo().search([])] create_date = fields.Datetime(string="Submitted on") res_name = fields.Char(string='Resource name', compute='_compute_res_name', store=True, help="The name of the rated resource.") diff --git a/addons/sms/wizard/sms_template_preview.py b/addons/sms/wizard/sms_template_preview.py index ffe22a4238a..f981f6857dc 100644 --- a/addons/sms/wizard/sms_template_preview.py +++ b/addons/sms/wizard/sms_template_preview.py @@ -10,8 +10,7 @@ class SMSTemplatePreview(models.TransientModel): @api.model def _selection_target_model(self): - models = self.env['ir.model'].search([]) - return [(model.model, model.name) for model in models] + return [(model.model, model.name) for model in self.env['ir.model'].sudo().search([])] @api.model def _selection_languages(self): diff --git a/odoo/addons/base/models/ir_actions.py b/odoo/addons/base/models/ir_actions.py index c73116d6513..e1f4909b2dd 100644 --- a/odoo/addons/base/models/ir_actions.py +++ b/odoo/addons/base/models/ir_actions.py @@ -393,11 +393,6 @@ class IrActionsServer(models.Model): # - Command: x2Many commands namespace # To return an action, assign: action = {...}\n\n\n\n""" - @api.model - def _select_objects(self): - records = self.env['ir.model'].search([]) - return [(record.model, record.name) for record in records] + [('', '')] - name = fields.Char(string='Action Name', translate=True) type = fields.Char(default='ir.actions.server') usage = fields.Selection([ @@ -679,8 +674,7 @@ class IrServerObjectLines(models.Model): @api.model def _selection_target_model(self): - models = self.env['ir.model'].search([]) - return [(model.model, model.name) for model in models] + return [(model.model, model.name) for model in self.env['ir.model'].sudo().search([])] @api.depends('col1.relation', 'value', 'evaluation_type') def _compute_resource_ref(self): From aa8eba2fb95e5539deea776e850a46da6e2c52c7 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 12 Apr 2021 09:48:01 +0200 Subject: [PATCH 03/13] [FIX] *: add sudo when accessing models --- addons/google_drive/models/google_drive.py | 2 +- addons/mail/models/mail_activity.py | 3 ++- addons/mail/models/mail_thread.py | 10 ++++++---- addons/mail/models/res_users.py | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/addons/google_drive/models/google_drive.py b/addons/google_drive/models/google_drive.py index b8b8aff5bea..162986d6fe7 100644 --- a/addons/google_drive/models/google_drive.py +++ b/addons/google_drive/models/google_drive.py @@ -154,7 +154,7 @@ class GoogleDrive(models.Model): ''' # TO DO in master: fix my signature and my model if isinstance(res_model, str): - res_model = self.env['ir.model'].search([('model', '=', res_model)]).id + res_model = self.env['ir.model'].sudo().search([('model', '=', res_model)]).id if not res_id: raise UserError(_("Creating google drive may only be done by one at a time.")) # check if a model is configured with a template diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index c7d510ecd5e..82f786f3133 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -740,7 +740,8 @@ class MailActivity(models.Model): 'o_closest_deadline': group['date_deadline'], } activity_type_infos = [] - activity_type_ids = self.env['mail.activity.type'].search(['|', ('res_model_id.model', '=', res_model), ('res_model_id', '=', False)]) + activity_type_ids = self.env['mail.activity.type'].sudo().search( + ['|', ('res_model_id.model', '=', res_model), ('res_model_id', '=', False)]) for elem in sorted(activity_type_ids, key=lambda item: item.sequence): mail_template_info = [] for mail_template_id in elem.mail_template_ids: diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 2e79408ce85..da8e1ca81b1 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -924,20 +924,22 @@ class MailThread(models.AbstractModel): # if destination = alias with different model -> consider it is a forward and not a reply # if destination = alias with same model -> check contact settings as they still apply if reply_model and reply_thread_id: + reply_model_id = self.env['ir.model']._get_id(reply_model) other_model_aliases = self.env['mail.alias'].search([ '&', '&', ('alias_name', '!=', False), ('alias_name', 'in', email_to_localparts), - ('alias_model_id.model', '!=', reply_model), + ('alias_model_id', '!=', reply_model_id), ]) if other_model_aliases: is_a_reply = False rcpt_tos_valid_localparts = [to for to in rcpt_tos_valid_localparts if to in other_model_aliases.mapped('alias_name')] if is_a_reply: + reply_model_id = self.env['ir.model']._get_id(reply_model) dest_aliases = self.env['mail.alias'].search([ ('alias_name', 'in', rcpt_tos_localparts), - ('alias_model_id.model', '=', reply_model) + ('alias_model_id', '=', reply_model_id) ], limit=1) user_id = self._mail_find_user_for_gateway(email_from, alias=dest_aliases).id or self._uid @@ -972,7 +974,7 @@ class MailThread(models.AbstractModel): routes = [] for alias in dest_aliases: user_id = self._mail_find_user_for_gateway(email_from, alias=alias).id or self._uid - route = (alias.alias_model_id.model, alias.alias_force_thread_id, ast.literal_eval(alias.alias_defaults), user_id, alias) + route = (alias.sudo().alias_model_id.model, alias.alias_force_thread_id, ast.literal_eval(alias.alias_defaults), user_id, alias) route = self._routing_check_route(message, message_dict, route, raise_exception=True) if route: _logger.info( @@ -1536,7 +1538,7 @@ class MailThread(models.AbstractModel): if alias and alias.alias_parent_model_id and alias.alias_parent_thread_id: followers = self.env['mail.followers'].search([ - ('res_model', '=', alias.alias_parent_model_id.model), + ('res_model', '=', alias.alias_parent_model_id.sudo().model), ('res_id', '=', alias.alias_parent_thread_id)] ).mapped('partner_id') else: diff --git a/addons/mail/models/res_users.py b/addons/mail/models/res_users.py index 4c62a77f55d..7146c6ddc44 100644 --- a/addons/mail/models/res_users.py +++ b/addons/mail/models/res_users.py @@ -99,7 +99,7 @@ class Users(models.Model): }) activity_data = self.env.cr.dictfetchall() model_ids = [a['id'] for a in activity_data] - model_names = {n[0]: n[1] for n in self.env['ir.model'].browse(model_ids).name_get()} + model_names = {n[0]: n[1] for n in self.env['ir.model'].sudo().browse(model_ids).name_get()} user_activities = {} for activity in activity_data: From e8b533088b47e445d2e84c1da0c8126e59d3301e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 12 Apr 2021 09:46:00 +0200 Subject: [PATCH 04/13] [FIX] *: add sudo when retriving fields --- addons/crm/models/crm_lead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index 65993b87fc9..71108500028 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -1244,7 +1244,7 @@ class Lead(models.Model): for lead in self: title = "%s : %s\n" % (_('Merged opportunity') if lead.type == 'opportunity' else _('Merged lead'), lead.name) body = [title] - _fields = self.env['ir.model.fields'].search([ + _fields = self.env['ir.model.fields'].sudo().search([ ('name', 'in', self._merge_get_fields()), ('model_id.model', '=', lead._name), ]) From 39da150ac2b3f4598affbaf09f222ff4795bd627 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 12 Apr 2021 11:11:43 +0200 Subject: [PATCH 05/13] [FIX] *: add sudo when accessing ir.model.data --- addons/account/demo/account_demo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/demo/account_demo.py b/addons/account/demo/account_demo.py index 11c5d116d3d..88b5d626b9f 100644 --- a/addons/account/demo/account_demo.py +++ b/addons/account/demo/account_demo.py @@ -344,7 +344,7 @@ class AccountChartTemplate(models.Model): :return (Model): the most appropriate record found """ return ( - self.env['account.account'].browse(self.env['ir.model.data'].search([ + self.env['account.account'].browse(self.env['ir.model.data'].sudo().search([ ('name', '=', '%d_%s' % (company.id, xml_id)), ('model', '=', 'account.account'), ('module', '=like', 'l10n%') From 8e4cec6b07c5bdc93b4d46884069017957ae3323 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 12 Apr 2021 11:15:23 +0200 Subject: [PATCH 06/13] [IMP] account: remove deprecated method Never called, action no longer exists --- addons/account/models/chart_template.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 03737089a55..b50d8f116b4 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -426,15 +426,6 @@ class AccountChartTemplate(models.Model): """ return [{'acc_name': _('Cash'), 'account_type': 'cash'}, {'acc_name': _('Bank'), 'account_type': 'bank'}] - def open_select_template_wizard(self): - # Add action to open wizard to select between several templates - if not self.company_id.chart_template_id: - todo = self.env['ir.actions.todo'] - action_rec = self.env['ir.model.data'].xmlid_to_object('account.action_wizard_multi_chart') - if action_rec: - todo.create({'action_id': action_rec.id, 'name': _('Choose Accounting Template')}) - return True - @api.model def _prepare_transfer_account_for_direct_creation(self, name, company): """ Prepare values to create a transfer account directly, based on the From 293d3765fa9f66ab40ec18eb0d8f3b1f5b3ccd72 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 6 Jul 2021 15:46:23 +0200 Subject: [PATCH 07/13] [IMP] lunch: avoid a call to ir.model.data Not needed to do it via a specific call, can be included in the controller data --- addons/lunch/controllers/main.py | 1 + addons/lunch/static/src/js/lunch_widget.js | 24 ++++++------------- .../static/tests/lunch_kanban_mobile_tests.js | 6 ----- .../lunch/static/tests/lunch_kanban_tests.js | 15 ++++-------- addons/lunch/static/tests/lunch_list_tests.js | 14 +++-------- 5 files changed, 15 insertions(+), 45 deletions(-) diff --git a/addons/lunch/controllers/main.py b/addons/lunch/controllers/main.py index 006fec4a5eb..8f6f4ba419e 100644 --- a/addons/lunch/controllers/main.py +++ b/addons/lunch/controllers/main.py @@ -94,6 +94,7 @@ class LunchController(http.Controller): 'userimage': '/web/image?model=res.users&id=%s&field=avatar_128' % user.id, 'wallet': request.env['lunch.cashmove'].get_wallet_balance(user, False), 'is_manager': is_manager, + 'group_portal_id': request.env.ref('base.group_portal').id, 'locations': request.env['lunch.location'].search_read([], ['name']), 'currency': {'symbol': currency.symbol, 'position': currency.position}, }) diff --git a/addons/lunch/static/src/js/lunch_widget.js b/addons/lunch/static/src/js/lunch_widget.js index ca0c497ceff..aa5d19d8d03 100644 --- a/addons/lunch/static/src/js/lunch_widget.js +++ b/addons/lunch/static/src/js/lunch_widget.js @@ -34,13 +34,12 @@ var LunchWidget = Widget.extend({ this._super.apply(this, arguments); this.is_manager = params.is_manager || false; + this.group_portal_id = params.group_portal_id || false; this.userimage = params.userimage || ''; this.username = params.username || ''; this.lunchUserField = null; - this.group_portal_id = undefined; - this.locations = params.locations || []; this.userLocation = params.user_location[1] || ''; @@ -57,23 +56,14 @@ var LunchWidget = Widget.extend({ this.currency = params.currency || session.get_currency(session.company_currency_id); }, willStart: function () { - var self = this; var superDef = this._super.apply(this, arguments); - var def = this._rpc({ - model: 'ir.model.data', - method: 'xmlid_to_res_id', - kwargs: {xmlid: 'base.group_portal'}, - }).then(function (id) { - self.group_portal_id = id; - - if (self.is_manager) { - self.lunchUserField = self._createMany2One('users', 'res.users', self.username, function () { - return [['groups_id', 'not in', [self.group_portal_id]]]; - }); - } - }); - return Promise.all([superDef, def]); + if (this.is_manager) { + this.lunchUserField = this._createMany2One('users', 'res.users', this.username, + () => [['groups_id', 'not in', [this.group_portal_id]]] + ); + } + return superDef; }, renderElement: function () { this._super.apply(this, arguments); diff --git a/addons/lunch/static/tests/lunch_kanban_mobile_tests.js b/addons/lunch/static/tests/lunch_kanban_mobile_tests.js index 1f2e61ff423..30b0ec7b469 100644 --- a/addons/lunch/static/tests/lunch_kanban_mobile_tests.js +++ b/addons/lunch/static/tests/lunch_kanban_mobile_tests.js @@ -37,12 +37,6 @@ QUnit.module('LunchKanbanView Mobile', { fields: {}, records: [], }, - 'ir.model.data': { - fields: {}, - xmlid_to_res_id() { - return Promise.resolve(PORTAL_GROUP_ID); - }, - }, 'lunch.location': { fields: { name: {string: 'Name', type: 'char'}, diff --git a/addons/lunch/static/tests/lunch_kanban_tests.js b/addons/lunch/static/tests/lunch_kanban_tests.js index d4deade79bb..093748921e0 100644 --- a/addons/lunch/static/tests/lunch_kanban_tests.js +++ b/addons/lunch/static/tests/lunch_kanban_tests.js @@ -37,12 +37,6 @@ QUnit.module('LunchKanbanView', { fields: {}, records: [], }, - 'ir.model.data': { - fields: {}, - xmlid_to_res_id() { - return Promise.resolve(PORTAL_GROUP_ID); - }, - }, 'lunch.location': { fields: { name: {string: 'Name', type: 'char'}, @@ -68,6 +62,7 @@ QUnit.module('LunchKanbanView', { username: "Marc Demo", wallet: 36.5, is_manager: false, + group_portal_id: PORTAL_GROUP_ID, currency: { symbol: "\u20ac", position: "after" @@ -78,6 +73,7 @@ QUnit.module('LunchKanbanView', { username: "Mitchell Admin", wallet: 47.6, is_manager: true, + group_portal_id: PORTAL_GROUP_ID, currency: { symbol: "\u20ac", position: "after" @@ -212,7 +208,7 @@ QUnit.module('LunchKanbanView', { }); QUnit.test('search panel domain location', async function (assert) { - assert.expect(20); + assert.expect(18); let expectedLocation = 1; let locationId = this.data['lunch.location'].records[0].id; const regularInfos = _.extend({}, this.regularInfos); @@ -266,7 +262,6 @@ QUnit.module('LunchKanbanView', { '/web/dataset/call_kw/product/search_panel_select_multi_range', '/web/dataset/search_read', '/lunch/infos', - '/web/dataset/call_kw/ir.model.data/xmlid_to_res_id', // Click m2o '/web/dataset/call_kw/lunch.location/name_search', // Click new location @@ -275,14 +270,13 @@ QUnit.module('LunchKanbanView', { '/web/dataset/call_kw/product/search_panel_select_multi_range', '/web/dataset/search_read', '/lunch/infos', - '/web/dataset/call_kw/ir.model.data/xmlid_to_res_id', ]); kanban.destroy(); }); QUnit.test('search panel domain location false: fetch products in all locations', async function (assert) { - assert.expect(10); + assert.expect(9); const regularInfos = _.extend({}, this.regularInfos); const kanban = await createLunchView({ @@ -324,7 +318,6 @@ QUnit.module('LunchKanbanView', { '/web/dataset/call_kw/product/search_panel_select_multi_range', '/web/dataset/search_read', '/lunch/infos', - '/web/dataset/call_kw/ir.model.data/xmlid_to_res_id', ]) kanban.destroy(); diff --git a/addons/lunch/static/tests/lunch_list_tests.js b/addons/lunch/static/tests/lunch_list_tests.js index 3dbcfabea8f..ebff6ffbddb 100644 --- a/addons/lunch/static/tests/lunch_list_tests.js +++ b/addons/lunch/static/tests/lunch_list_tests.js @@ -37,12 +37,6 @@ QUnit.module('LunchListView', { fields: {}, records: [], }, - 'ir.model.data': { - fields: {}, - xmlid_to_res_id() { - return Promise.resolve(PORTAL_GROUP_ID); - }, - }, 'lunch.location': { fields: { name: {string: 'Name', type: 'char'}, @@ -68,6 +62,7 @@ QUnit.module('LunchListView', { username: "Marc Demo", wallet: 36.5, is_manager: false, + group_portal_id: PORTAL_GROUP_ID, currency: { symbol: "\u20ac", position: "after" @@ -120,7 +115,7 @@ QUnit.module('LunchListView', { QUnit.module('LunchWidget', function () { QUnit.test('search panel domain location', async function (assert) { - assert.expect(20); + assert.expect(18); let expectedLocation = 1; let locationId = this.data['lunch.location'].records[0].id; const regularInfos = _.extend({}, this.regularInfos); @@ -170,7 +165,6 @@ QUnit.module('LunchListView', { '/web/dataset/call_kw/product/search_panel_select_multi_range', '/web/dataset/search_read', '/lunch/infos', - '/web/dataset/call_kw/ir.model.data/xmlid_to_res_id', // Click m2o '/web/dataset/call_kw/lunch.location/name_search', // Click new location @@ -179,14 +173,13 @@ QUnit.module('LunchListView', { '/web/dataset/call_kw/product/search_panel_select_multi_range', '/web/dataset/search_read', '/lunch/infos', - '/web/dataset/call_kw/ir.model.data/xmlid_to_res_id', ]); list.destroy(); }); QUnit.test('search panel domain location false: fetch products in all locations', async function (assert) { - assert.expect(10); + assert.expect(9); const regularInfos = _.extend({}, this.regularInfos); const list = await createLunchView({ @@ -224,7 +217,6 @@ QUnit.module('LunchListView', { '/web/dataset/call_kw/product/search_panel_select_multi_range', '/web/dataset/search_read', '/lunch/infos', - '/web/dataset/call_kw/ir.model.data/xmlid_to_res_id', ]) list.destroy(); From abc04a9f18b661d4f30de3593899f50a38b56847 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 6 Jul 2021 16:43:10 +0200 Subject: [PATCH 08/13] [IMP] base_setup: avoid call to ir.model.data Can retrieve the action from _action_show --- addons/base_setup/controllers/main.py | 3 ++ .../static/src/js/res_config_invite_users.js | 39 +++---------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/addons/base_setup/controllers/main.py b/addons/base_setup/controllers/main.py index 317cb6bd754..a19796d672d 100644 --- a/addons/base_setup/controllers/main.py +++ b/addons/base_setup/controllers/main.py @@ -40,11 +40,14 @@ class BaseSetup(http.Controller): LIMIT 10 """) pending_users = cr.fetchall() + action_pending_users = request.env['res.users'].browse( + [uid for (uid, login) in pending_users])._action_show() return { 'active_users': active_count, 'pending_count': pending_count, 'pending_users': pending_users, + 'action_pending_users': action_pending_users, } @http.route('/base_setup/demo_active', type='json', auth='user') diff --git a/addons/base_setup/static/src/js/res_config_invite_users.js b/addons/base_setup/static/src/js/res_config_invite_users.js index c7f36049164..9e75eff0fd7 100644 --- a/addons/base_setup/static/src/js/res_config_invite_users.js +++ b/addons/base_setup/static/src/js/res_config_invite_users.js @@ -41,6 +41,7 @@ odoo.define('base_setup.ResConfigInviteUsers', function (require) { }).then(function (data) { self.active_users = data.active_users; self.pending_users = data.pending_users; + self.action_pending_users = data.action_pending_users; self.pending_count = data.pending_count; self.resend_invitation = data.resend_invitation || false; }); @@ -141,49 +142,19 @@ odoo.define('base_setup.ResConfigInviteUsers', function (require) { * @param {MouseEvent} ev */ _onClickMore: function (ev) { - var self = this; ev.preventDefault(); - this._rpc({ - model: 'ir.model.data', - method: 'xmlid_to_res_model_res_id', - args: ["base.view_users_form"], - }) - .then(function (data) { - self.do_action({ - name: _t('Users'), - type: 'ir.actions.act_window', - view_mode: 'tree,form', - res_model: 'res.users', - domain: [['log_ids', '=', false]], - context: { - search_default_no_share: true, - }, - views: [[false, 'list'], [data[1], 'form']], - }); - }); + this.do_action(this.action_pending_users); }, /** * @private * @param {MouseEvent} ev */ _onClickUser: function (ev) { - var self = this; ev.preventDefault(); var user_id = $(ev.currentTarget).data('user-id'); - this._rpc({ - model: 'ir.model.data', - method: 'xmlid_to_res_model_res_id', - args: ["base.view_users_form"], - }) - .then(function (data) { - self.do_action({ - type: 'ir.actions.act_window', - res_model: 'res.users', - view_mode: 'form', - res_id: user_id, - views: [[data[1], 'form']], - }); - }); + + var action = Object.assign({}, this.action_pending_users, {res_id: user_id}); + this.do_action(action); }, /** * @private From c7bac3dee0bbc8b9e3d0e2dda419f3875916d96e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 6 Jul 2021 12:26:00 +0200 Subject: [PATCH 09/13] [IMP] *: make ir.model.data helper private No reason to interfact with them directly in RPC --- addons/account/tests/test_transfer_wizard.py | 2 +- addons/calendar/models/calendar_alarm.py | 2 +- .../tests/test_mail_activity_mixin.py | 2 +- addons/calendar_sms/models/calendar_alarm.py | 2 +- addons/event/tests/common.py | 4 +-- addons/event/tests/test_event_internals.py | 6 ++--- .../event/tests/test_event_mail_schedule.py | 8 +++--- addons/google_drive/models/google_drive.py | 4 +-- .../google_spreadsheet/models/google_drive.py | 2 +- addons/hr_expense/models/hr_expense.py | 2 +- .../hr_recruitment/models/hr_recruitment.py | 2 +- .../wizard/applicant_refuse_reason.py | 2 +- addons/l10n_eu_service/models/res_company.py | 4 +-- addons/mail/controllers/main.py | 2 +- addons/mail/models/mail_activity.py | 10 +++---- addons/mail/models/mail_message.py | 4 +-- addons/mail/models/mail_thread.py | 22 ++++++++-------- addons/mail/models/res_partner.py | 2 +- addons/mail/wizard/mail_compose_message.py | 4 +-- addons/mail_bot/models/mail_bot.py | 8 +++--- addons/mail_bot/models/mail_channel.py | 2 +- addons/mrp/tests/test_order.py | 4 +-- .../test_warehouse_multistep_manufacturing.py | 6 ++--- addons/note/models/res_users.py | 2 +- .../product_margin/wizard/product_margin.py | 2 +- addons/project/models/project.py | 2 +- addons/purchase/models/purchase.py | 8 +++--- addons/purchase/tests/test_purchase.py | 4 +-- .../purchase_requisition/models/purchase.py | 4 +-- .../tests/test_create_picking.py | 18 ++++++------- .../purchase_stock/tests/test_fifo_price.py | 2 +- .../tests/test_move_cancel_propagation.py | 6 ++--- addons/rating/models/rating_mixin.py | 2 +- addons/sale/models/sale_order.py | 4 +-- .../tests/test_sale_mrp_procurement.py | 2 +- addons/sale_stock/tests/test_sale_stock.py | 2 +- addons/sms/models/mail_thread.py | 2 +- addons/sms/wizard/sms_composer.py | 2 +- addons/stock/models/stock_move.py | 2 +- addons/stock/tests/common.py | 14 +++++----- addons/stock/tests/test_report.py | 8 +++--- .../tests/test_batch_picking.py | 2 +- .../tests/test_event_security.py | 4 +-- addons/test_mail/tests/test_performance.py | 4 +-- addons/test_mail_full/tests/test_odoobot.py | 2 +- addons/website/controllers/form.py | 2 +- addons/website/models/ir_module_module.py | 2 +- addons/website/models/ir_ui_view.py | 2 +- addons/website/views/website_templates.xml | 2 +- addons/website_blog/models/website_blog.py | 2 +- .../website_event_track/models/event_track.py | 2 +- addons/website_forum/controllers/main.py | 2 +- addons/website_forum/models/forum.py | 6 ++--- .../models/hr_recruitment.py | 2 +- addons/website_slides/models/slide_channel.py | 6 ++--- odoo/addons/base/models/ir_model.py | 26 +++++++++---------- odoo/addons/base/models/ir_ui_view.py | 10 +++---- odoo/addons/base/models/res_users.py | 6 ++--- odoo/addons/base/tests/test_ormcache.py | 6 ++--- odoo/api.py | 2 +- odoo/tests/common.py | 2 +- odoo/tools/convert.py | 2 +- 62 files changed, 143 insertions(+), 143 deletions(-) diff --git a/addons/account/tests/test_transfer_wizard.py b/addons/account/tests/test_transfer_wizard.py index eb78a3dae80..da0bfc6e8aa 100644 --- a/addons/account/tests/test_transfer_wizard.py +++ b/addons/account/tests/test_transfer_wizard.py @@ -61,7 +61,7 @@ class TestTransferWizard(AccountTestInvoicingCommon): cls.test_currency_account = cls.env['account.account'].create({ 'name': 'test destination account', 'code': 'test_dest_acc', - 'user_type_id': cls.env['ir.model.data'].xmlid_to_res_id('account.data_account_type_current_assets'), + 'user_type_id': cls.env['ir.model.data']._xmlid_to_res_id('account.data_account_type_current_assets'), 'currency_id': cls.test_currency_3.id, }) diff --git a/addons/calendar/models/calendar_alarm.py b/addons/calendar/models/calendar_alarm.py index 2ea15fd017b..8ed585160cb 100644 --- a/addons/calendar/models/calendar_alarm.py +++ b/addons/calendar/models/calendar_alarm.py @@ -44,7 +44,7 @@ class Alarm(models.Model): def _compute_mail_template_id(self): for alarm in self: if alarm.alarm_type == 'email' and not alarm.mail_template_id: - alarm.mail_template_id = self.env['ir.model.data'].xmlid_to_res_id('calendar.calendar_template_meeting_reminder') + alarm.mail_template_id = self.env['ir.model.data']._xmlid_to_res_id('calendar.calendar_template_meeting_reminder') elif alarm.alarm_type != 'email' or not alarm.mail_template_id: alarm.mail_template_id = False diff --git a/addons/calendar/tests/test_mail_activity_mixin.py b/addons/calendar/tests/test_mail_activity_mixin.py index 826db01eb51..c34688bec96 100644 --- a/addons/calendar/tests/test_mail_activity_mixin.py +++ b/addons/calendar/tests/test_mail_activity_mixin.py @@ -48,7 +48,7 @@ class TestMailActivityMixin(MailCommon): meeting.calendar_event_id = calendar_event return meeting - group_partner_manager = self.env['ir.model.data'].xmlid_to_res_id('base.group_partner_manager') + group_partner_manager = self.env['ir.model.data']._xmlid_to_res_id('base.group_partner_manager') self.user_employee.write({ 'tz': self.user_admin.tz, 'groups_id': [Command.link(group_partner_manager)] diff --git a/addons/calendar_sms/models/calendar_alarm.py b/addons/calendar_sms/models/calendar_alarm.py index d69c1b17406..77a7da77f5e 100644 --- a/addons/calendar_sms/models/calendar_alarm.py +++ b/addons/calendar_sms/models/calendar_alarm.py @@ -20,6 +20,6 @@ class CalendarAlarm(models.Model): def _compute_sms_template_id(self): for alarm in self: if alarm.alarm_type == 'sms' and not alarm.sms_template_id: - alarm.sms_template_id = self.env['ir.model.data'].xmlid_to_res_id('calendar_sms.sms_template_data_calendar_reminder') + alarm.sms_template_id = self.env['ir.model.data']._xmlid_to_res_id('calendar_sms.sms_template_data_calendar_reminder') elif alarm.alarm_type != 'sms' or not alarm.sms_template_id: alarm.sms_template_id = False diff --git a/addons/event/tests/common.py b/addons/event/tests/common.py index 0a2855d8ba7..47bd7584096 100644 --- a/addons/event/tests/common.py +++ b/addons/event/tests/common.py @@ -80,12 +80,12 @@ class TestEventCommon(common.TransactionCase): (0, 0, { # right at subscription 'interval_unit': 'now', 'interval_type': 'after_sub', - 'template_ref': 'mail.template,%i' % cls.env['ir.model.data'].xmlid_to_res_id('event.event_subscription')}), + 'template_ref': 'mail.template,%i' % cls.env['ir.model.data']._xmlid_to_res_id('event.event_subscription')}), (0, 0, { # 1 days before event 'interval_nbr': 1, 'interval_unit': 'days', 'interval_type': 'before_event', - 'template_ref': 'mail.template,%i' % cls.env['ir.model.data'].xmlid_to_res_id('event.event_reminder')}), + 'template_ref': 'mail.template,%i' % cls.env['ir.model.data']._xmlid_to_res_id('event.event_reminder')}), ], }) cls.event_0 = cls.env['event.event'].create({ diff --git a/addons/event/tests/test_event_internals.py b/addons/event/tests/test_event_internals.py index 9ea121503f1..17dd347a97b 100644 --- a/addons/event/tests/test_event_internals.py +++ b/addons/event/tests/test_event_internals.py @@ -104,7 +104,7 @@ class TestEventData(TestEventCommon): event_type.write({ 'event_type_mail_ids': [(5, 0), (0, 0, { 'interval_nbr': 1, 'interval_unit': 'days', 'interval_type': 'before_event', - 'template_ref': 'mail.template,%i' % self.env['ir.model.data'].xmlid_to_res_id('event.event_reminder')}) + 'template_ref': 'mail.template,%i' % self.env['ir.model.data']._xmlid_to_res_id('event.event_reminder')}) ], 'event_type_ticket_ids': [(5, 0), (0, 0, {'name': 'TestRegistration'})], }) @@ -162,7 +162,7 @@ class TestEventData(TestEventCommon): 'interval_nbr': 77, 'interval_unit': 'days', 'interval_type': 'after_event', - 'template_ref': 'mail.template,%i' % self.env['ir.model.data'].xmlid_to_res_id('event.event_reminder'), + 'template_ref': 'mail.template,%i' % self.env['ir.model.data']._xmlid_to_res_id('event.event_reminder'), }) ] }) @@ -179,7 +179,7 @@ class TestEventData(TestEventCommon): 'notification_type': 'mail', 'interval_unit': 'now', 'interval_type': 'after_sub', - 'template_ref': 'mail.template,%i' % self.env['ir.model.data'].xmlid_to_res_id('event.event_subscription'), + 'template_ref': 'mail.template,%i' % self.env['ir.model.data']._xmlid_to_res_id('event.event_subscription'), }) ] }) diff --git a/addons/event/tests/test_event_mail_schedule.py b/addons/event/tests/test_event_mail_schedule.py index 1889e167010..87ce2b33afd 100644 --- a/addons/event/tests/test_event_mail_schedule.py +++ b/addons/event/tests/test_event_mail_schedule.py @@ -39,22 +39,22 @@ class TestMailSchedule(TestEventCommon, MockEmail): (0, 0, { # right at subscription 'interval_unit': 'now', 'interval_type': 'after_sub', - 'template_ref': 'mail.template,%i' % self.env['ir.model.data'].xmlid_to_res_id('event.event_subscription')}), + 'template_ref': 'mail.template,%i' % self.env['ir.model.data']._xmlid_to_res_id('event.event_subscription')}), (0, 0, { # one day after subscription 'interval_nbr': 1, 'interval_unit': 'hours', 'interval_type': 'after_sub', - 'template_ref': 'mail.template,%i' % self.env['ir.model.data'].xmlid_to_res_id('event.event_subscription')}), + 'template_ref': 'mail.template,%i' % self.env['ir.model.data']._xmlid_to_res_id('event.event_subscription')}), (0, 0, { # 1 days before event 'interval_nbr': 1, 'interval_unit': 'days', 'interval_type': 'before_event', - 'template_ref': 'mail.template,%i' % self.env['ir.model.data'].xmlid_to_res_id('event.event_reminder')}), + 'template_ref': 'mail.template,%i' % self.env['ir.model.data']._xmlid_to_res_id('event.event_reminder')}), (0, 0, { # immediately after event 'interval_nbr': 1, 'interval_unit': 'hours', 'interval_type': 'after_event', - 'template_ref': 'mail.template,%i' % self.env['ir.model.data'].xmlid_to_res_id('event.event_reminder')}), + 'template_ref': 'mail.template,%i' % self.env['ir.model.data']._xmlid_to_res_id('event.event_reminder')}), ] }) self.assertEqual(test_event.create_date, now) diff --git a/addons/google_drive/models/google_drive.py b/addons/google_drive/models/google_drive.py index 162986d6fe7..4c49e398d54 100644 --- a/addons/google_drive/models/google_drive.py +++ b/addons/google_drive/models/google_drive.py @@ -54,7 +54,7 @@ class GoogleDrive(models.Model): user_is_admin = self.env.is_admin() if not google_drive_refresh_token: if user_is_admin: - dummy, action_id = self.env['ir.model.data'].get_object_reference('base_setup', 'action_general_configuration') + dummy, action_id = self.env['ir.model.data']._get_object_reference('base_setup', 'action_general_configuration') msg = _("There is no refresh code set for Google Drive. You can set it up from the configuration panel.") raise RedirectWarning(msg, action_id, _('Go to the configuration panel')) else: @@ -75,7 +75,7 @@ class GoogleDrive(models.Model): req.raise_for_status() except requests.HTTPError: if user_is_admin: - dummy, action_id = self.env['ir.model.data'].get_object_reference('base_setup', 'action_general_configuration') + dummy, action_id = self.env['ir.model.data']._get_object_reference('base_setup', 'action_general_configuration') msg = _("Something went wrong during the token generation. Please request again an authorization code .") raise RedirectWarning(msg, action_id, _('Go to the configuration panel')) else: diff --git a/addons/google_spreadsheet/models/google_drive.py b/addons/google_spreadsheet/models/google_drive.py index 0f4f830b673..53bf7affcab 100644 --- a/addons/google_spreadsheet/models/google_drive.py +++ b/addons/google_spreadsheet/models/google_drive.py @@ -92,7 +92,7 @@ class GoogleDrive(models.Model): @api.model def set_spreadsheet(self, model, domain, groupbys, view_id): try: - config_id = self.env['ir.model.data'].get_object_reference('google_spreadsheet', 'google_spreadsheet_template')[1] + config_id = self.env['ir.model.data']._get_object_reference('google_spreadsheet', 'google_spreadsheet_template')[1] except ValueError: raise config = self.browse(config_id) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index fab5a572ab8..6d66f88f839 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -432,7 +432,7 @@ Or send your receipts at Odoo's chat helps employees collaborate efficiently. I'm here to help you discover its features.
Try to send me an emoji :)") diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py index 71cdde8f468..b7464ec04bf 100644 --- a/addons/mrp/tests/test_order.py +++ b/addons/mrp/tests/test_order.py @@ -1526,8 +1526,8 @@ class TestMrpOrder(TestMrpCommon): def test_immediate_validate_uom_2(self): """The rounding precision of a component should be based on the UoM used in the MO for this component, not on the produced product's UoM nor the default UoM of the component""" - uom_units = self.env['ir.model.data'].xmlid_to_object('uom.product_uom_unit') - uom_L = self.env['ir.model.data'].xmlid_to_object('uom.product_uom_litre') + uom_units = self.env['ir.model.data']._xmlid_to_object('uom.product_uom_unit') + uom_L = self.env['ir.model.data']._xmlid_to_object('uom.product_uom_litre') uom_cL = self.env['uom.uom'].create({ 'name': 'cL', 'category_id': uom_L.category_id.id, diff --git a/addons/mrp/tests/test_warehouse_multistep_manufacturing.py b/addons/mrp/tests/test_warehouse_multistep_manufacturing.py index 6f3397a987a..843dbd9a05b 100644 --- a/addons/mrp/tests/test_warehouse_multistep_manufacturing.py +++ b/addons/mrp/tests/test_warehouse_multistep_manufacturing.py @@ -10,7 +10,7 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon): def setUp(self): super(TestMultistepManufacturingWarehouse, self).setUp() # Create warehouse - self.customer_location = self.env['ir.model.data'].xmlid_to_res_id('stock.stock_location_customers') + self.customer_location = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers') warehouse_form = Form(self.env['stock.warehouse']) warehouse_form.name = 'Test Warehouse' warehouse_form.code = 'TWH' @@ -138,7 +138,7 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon): picking_customer = self.env['stock.picking'].create({ 'location_id': self.warehouse.wh_output_stock_loc_id.id, 'location_dest_id': self.customer_location, - 'partner_id': self.env['ir.model.data'].xmlid_to_res_id('base.res_partner_4'), + 'partner_id': self.env['ir.model.data']._xmlid_to_res_id('base.res_partner_4'), 'picking_type_id': self.warehouse.out_type_id.id, }) self.env['stock.move'].create({ @@ -218,7 +218,7 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon): picking_customer = self.env['stock.picking'].create({ 'location_id': self.warehouse.lot_stock_id.id, 'location_dest_id': self.customer_location, - 'partner_id': self.env['ir.model.data'].xmlid_to_res_id('base.res_partner_4'), + 'partner_id': self.env['ir.model.data']._xmlid_to_res_id('base.res_partner_4'), 'picking_type_id': self.warehouse.out_type_id.id, }) self.env['stock.move'].create({ diff --git a/addons/note/models/res_users.py b/addons/note/models/res_users.py index a2780f865f9..0a56ba84005 100644 --- a/addons/note/models/res_users.py +++ b/addons/note/models/res_users.py @@ -15,7 +15,7 @@ class Users(models.Model): @api.model_create_multi def create(self, vals_list): users = super().create(vals_list) - user_group_id = self.env['ir.model.data'].xmlid_to_res_id('base.group_user') + user_group_id = self.env['ir.model.data']._xmlid_to_res_id('base.group_user') # for new employee, create his own 5 base note stages users.filtered_domain([('groups_id', 'in', [user_group_id])])._create_note_stages() return users diff --git a/addons/product_margin/wizard/product_margin.py b/addons/product_margin/wizard/product_margin.py index f58e31f26fa..29e8d9be1b1 100644 --- a/addons/product_margin/wizard/product_margin.py +++ b/addons/product_margin/wizard/product_margin.py @@ -24,7 +24,7 @@ class ProductMargin(models.TransientModel): def ref(module, xml_id): proxy = self.env['ir.model.data'] - return proxy.get_object_reference(module, xml_id) + return proxy._get_object_reference(module, xml_id) model, search_view_id = ref('product', 'product_search_form_view') model, graph_view_id = ref('product_margin', 'view_product_margin_graph') diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 6b5b8e1654c..c7902132f9e 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -1311,7 +1311,7 @@ class Task(models.Model): if 'stage_id' in changes and test_task.stage_id.mail_template_id: res['stage_id'] = (test_task.stage_id.mail_template_id, { 'auto_delete_message': True, - 'subtype_id': self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note'), + 'subtype_id': self.env['ir.model.data']._xmlid_to_res_id('mail.mt_note'), 'email_layout_xmlid': 'mail.mail_notification_light' }) return res diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 03d4368559b..c29c0030a91 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -354,13 +354,13 @@ class PurchaseOrder(models.Model): ir_model_data = self.env['ir.model.data'] try: if self.env.context.get('send_rfq', False): - template_id = ir_model_data.get_object_reference('purchase', 'email_template_edi_purchase')[1] + template_id = ir_model_data._get_object_reference('purchase', 'email_template_edi_purchase')[1] else: - template_id = ir_model_data.get_object_reference('purchase', 'email_template_edi_purchase_done')[1] + template_id = ir_model_data._get_object_reference('purchase', 'email_template_edi_purchase_done')[1] except ValueError: template_id = False try: - compose_form_id = ir_model_data.get_object_reference('mail', 'email_compose_message_wizard_form')[1] + compose_form_id = ir_model_data._get_object_reference('mail', 'email_compose_message_wizard_form')[1] except ValueError: compose_form_id = False ctx = dict(self.env.context or {}) @@ -723,7 +723,7 @@ class PurchaseOrder(models.Model): def _send_reminder_open_composer(self,template_id): self.ensure_one() try: - compose_form_id = self.env['ir.model.data'].get_object_reference('mail', 'email_compose_message_wizard_form')[1] + compose_form_id = self.env['ir.model.data']._get_object_reference('mail', 'email_compose_message_wizard_form')[1] except ValueError: compose_form_id = False ctx = dict(self.env.context or {}) diff --git a/addons/purchase/tests/test_purchase.py b/addons/purchase/tests/test_purchase.py index d27429abbd3..849fb1e58dc 100644 --- a/addons/purchase/tests/test_purchase.py +++ b/addons/purchase/tests/test_purchase.py @@ -218,8 +218,8 @@ class TestPurchase(AccountTestInvoicingCommon): def test_with_different_uom(self): """ This test ensures that the unit price is correctly computed""" - uom_units = self.env['ir.model.data'].xmlid_to_object('uom.product_uom_unit') - uom_dozens = self.env['ir.model.data'].xmlid_to_object('uom.product_uom_dozen') + uom_units = self.env['ir.model.data']._xmlid_to_object('uom.product_uom_unit') + uom_dozens = self.env['ir.model.data']._xmlid_to_object('uom.product_uom_dozen') uom_pairs = self.env['uom.uom'].create({ 'name': 'Pairs', 'category_id': uom_units.category_id.id, diff --git a/addons/purchase_requisition/models/purchase.py b/addons/purchase_requisition/models/purchase.py index a3665665fd5..1e4e595db01 100644 --- a/addons/purchase_requisition/models/purchase.py +++ b/addons/purchase_requisition/models/purchase.py @@ -94,7 +94,7 @@ class PurchaseOrder(models.Model): if purchase.requisition_id: purchase.message_post_with_view('mail.message_origin_link', values={'self': purchase, 'origin': purchase.requisition_id}, - subtype_id=self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note')) + subtype_id=self.env['ir.model.data']._xmlid_to_res_id('mail.mt_note')) return purchase def write(self, vals): @@ -102,7 +102,7 @@ class PurchaseOrder(models.Model): if vals.get('requisition_id'): self.message_post_with_view('mail.message_origin_link', values={'self': self, 'origin': self.requisition_id, 'edit': True}, - subtype_id=self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note')) + subtype_id=self.env['ir.model.data']._xmlid_to_res_id('mail.mt_note')) return result diff --git a/addons/purchase_stock/tests/test_create_picking.py b/addons/purchase_stock/tests/test_create_picking.py index 418b0e6dcba..531aab656aa 100644 --- a/addons/purchase_stock/tests/test_create_picking.py +++ b/addons/purchase_stock/tests/test_create_picking.py @@ -100,9 +100,9 @@ class TestCreatePicking(common.TestProductCommon): following move to MTS in order to be able to link it to a manually created purchase order. """ - stock_location = self.env['ir.model.data'].xmlid_to_object('stock.stock_location_stock') - customer_location = self.env['ir.model.data'].xmlid_to_object('stock.stock_location_customers') - picking_type_out = self.env['ir.model.data'].xmlid_to_object('stock.picking_type_out') + stock_location = self.env['ir.model.data']._xmlid_to_object('stock.stock_location_stock') + customer_location = self.env['ir.model.data']._xmlid_to_object('stock.stock_location_customers') + picking_type_out = self.env['ir.model.data']._xmlid_to_object('stock.picking_type_out') # route buy should be there by default partner = self.env['res.partner'].create({ 'name': 'Jhon' @@ -238,9 +238,9 @@ class TestCreatePicking(common.TestProductCommon): and receipt the picking then try to reserve the delivery picking. """ - stock_location = self.env['ir.model.data'].xmlid_to_object('stock.stock_location_stock') - customer_location = self.env['ir.model.data'].xmlid_to_object('stock.stock_location_customers') - picking_type_out = self.env['ir.model.data'].xmlid_to_object('stock.picking_type_out') + stock_location = self.env['ir.model.data']._xmlid_to_object('stock.stock_location_stock') + customer_location = self.env['ir.model.data']._xmlid_to_object('stock.stock_location_customers') + picking_type_out = self.env['ir.model.data']._xmlid_to_object('stock.picking_type_out') # route buy should be there by default partner = self.env['res.partner'].create({ 'name': 'Jhon' @@ -383,10 +383,10 @@ class TestCreatePicking(common.TestProductCommon): self.assertEqual(move2.product_qty, 24) def create_delivery_order(self): - stock_location = self.env['ir.model.data'].xmlid_to_object('stock.stock_location_stock') - customer_location = self.env['ir.model.data'].xmlid_to_object('stock.stock_location_customers') + stock_location = self.env['ir.model.data']._xmlid_to_object('stock.stock_location_stock') + customer_location = self.env['ir.model.data']._xmlid_to_object('stock.stock_location_customers') unit = self.ref("uom.product_uom_unit") - picking_type_out = self.env['ir.model.data'].xmlid_to_object('stock.picking_type_out') + picking_type_out = self.env['ir.model.data']._xmlid_to_object('stock.picking_type_out') partner = self.env['res.partner'].create({'name': 'AAA', 'email': 'from.test@example.com'}) supplier_info1 = self.env['product.supplierinfo'].create({ 'name': partner.id, diff --git a/addons/purchase_stock/tests/test_fifo_price.py b/addons/purchase_stock/tests/test_fifo_price.py index 848d967c7bf..14378b03bcc 100644 --- a/addons/purchase_stock/tests/test_fifo_price.py +++ b/addons/purchase_stock/tests/test_fifo_price.py @@ -323,7 +323,7 @@ class TestFifoPrice(ValuationReconciliationTestCommon): def test_01_test_fifo(self): """" This test ensures that unit price keeps its decimal precision """ - unit_price_precision = self.env['ir.model.data'].xmlid_to_object('product.decimal_price') + unit_price_precision = self.env['ir.model.data']._xmlid_to_object('product.decimal_price') unit_price_precision.digits = 3 tax = self.env["account.tax"].create({ diff --git a/addons/purchase_stock/tests/test_move_cancel_propagation.py b/addons/purchase_stock/tests/test_move_cancel_propagation.py index 111ba1e08cd..2c9ce915940 100644 --- a/addons/purchase_stock/tests/test_move_cancel_propagation.py +++ b/addons/purchase_stock/tests/test_move_cancel_propagation.py @@ -251,9 +251,9 @@ class TestMoveCancelPropagation(PurchaseTestCommon): """Check for done and cancelled moves. Ensure that the RFQ cancellation will not impact the delivery state if it's already cancelled. """ - stock_location = self.env['ir.model.data'].xmlid_to_object('stock.stock_location_stock') - customer_location = self.env['ir.model.data'].xmlid_to_object('stock.stock_location_customers') - picking_type_out = self.env['ir.model.data'].xmlid_to_object('stock.picking_type_out') + stock_location = self.env['ir.model.data']._xmlid_to_object('stock.stock_location_stock') + customer_location = self.env['ir.model.data']._xmlid_to_object('stock.stock_location_customers') + picking_type_out = self.env['ir.model.data']._xmlid_to_object('stock.picking_type_out') partner = self.env['res.partner'].create({ 'name': 'Steve' diff --git a/addons/rating/models/rating_mixin.py b/addons/rating/models/rating_mixin.py index ed3fd534242..55c8e35f566 100644 --- a/addons/rating/models/rating_mixin.py +++ b/addons/rating/models/rating_mixin.py @@ -160,7 +160,7 @@ class RatingMixin(models.AbstractModel): if lang: template = template.with_context(lang=lang) if subtype_id is False: - subtype_id = self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note') + subtype_id = self.env['ir.model.data']._xmlid_to_res_id('mail.mt_note') if force_send: self = self.with_context(mail_notify_force_send=True) # default value is True, should be set to false if not? for record in self: diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index 6f4ea321af1..dcb8a75a840 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -855,9 +855,9 @@ class SaleOrder(models.Model): template_id = int(self.env['ir.config_parameter'].sudo().get_param('sale.default_confirmation_template')) template_id = self.env['mail.template'].search([('id', '=', template_id)]).id if not template_id: - template_id = self.env['ir.model.data'].xmlid_to_res_id('sale.mail_template_sale_confirmation', raise_if_not_found=False) + template_id = self.env['ir.model.data']._xmlid_to_res_id('sale.mail_template_sale_confirmation', raise_if_not_found=False) if not template_id: - template_id = self.env['ir.model.data'].xmlid_to_res_id('sale.email_template_edi_sale', raise_if_not_found=False) + template_id = self.env['ir.model.data']._xmlid_to_res_id('sale.email_template_edi_sale', raise_if_not_found=False) return template_id diff --git a/addons/sale_mrp/tests/test_sale_mrp_procurement.py b/addons/sale_mrp/tests/test_sale_mrp_procurement.py index 4de6c6d0a4c..df60a07b707 100644 --- a/addons/sale_mrp/tests/test_sale_mrp_procurement.py +++ b/addons/sale_mrp/tests/test_sale_mrp_procurement.py @@ -76,7 +76,7 @@ class TestSaleMrpProcurement(TransactionCase): """ self.env.ref('stock.route_warehouse0_mto').active = True # Create warehouse - self.customer_location = self.env['ir.model.data'].xmlid_to_res_id('stock.stock_location_customers') + self.customer_location = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers') self.warehouse = self.env['stock.warehouse'].create({ 'name': 'Test Warehouse', 'code': 'TWH' diff --git a/addons/sale_stock/tests/test_sale_stock.py b/addons/sale_stock/tests/test_sale_stock.py index 81154db90ec..0c95a9937ea 100644 --- a/addons/sale_stock/tests/test_sale_stock.py +++ b/addons/sale_stock/tests/test_sale_stock.py @@ -1066,7 +1066,7 @@ class TestSaleStock(TestSaleCommon, ValuationReconciliationTestCommon): policy set to "Delivered quantities". When cancelling the delivery of such a product, the invoice status of the associated SO should be 'Nothing to Invoice' """ - group_auto_done = self.env['ir.model.data'].xmlid_to_object('sale.group_auto_done_setting') + group_auto_done = self.env['ir.model.data']._xmlid_to_object('sale.group_auto_done_setting') self.env.user.groups_id = [(4, group_auto_done.id)] product = self.product_a diff --git a/addons/sms/models/mail_thread.py b/addons/sms/models/mail_thread.py index ca5048e3ba1..2598da33ccd 100644 --- a/addons/sms/models/mail_thread.py +++ b/addons/sms/models/mail_thread.py @@ -225,7 +225,7 @@ class MailThread(models.AbstractModel): sms_numbers = [False] if subtype_id is False: - subtype_id = self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note') + subtype_id = self.env['ir.model.data']._xmlid_to_res_id('mail.mt_note') return self.message_post( body=plaintext2html(html2plaintext(body)), partner_ids=partner_ids or [], # TDE FIXME: temp fix otherwise crash mail_thread.py diff --git a/addons/sms/wizard/sms_composer.py b/addons/sms/wizard/sms_composer.py index 57b6d27ecf4..8fd47779e44 100644 --- a/addons/sms/wizard/sms_composer.py +++ b/addons/sms/wizard/sms_composer.py @@ -236,7 +236,7 @@ class SendSMS(models.TransientModel): def _action_send_sms_comment(self, records=None): records = records if records is not None else self._get_records() - subtype_id = self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note') + subtype_id = self.env['ir.model.data']._xmlid_to_res_id('mail.mt_note') messages = self.env['mail.message'] for record in records: diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 60e4dfbe4e7..762bbd1406e 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -610,7 +610,7 @@ class StockMove(models.Model): # Avoids to write the exact same message multiple times. if last_message and last_message.subject == msg_subject: continue - odoobot_id = self.env['ir.model.data'].xmlid_to_res_id("base.partner_root") + odoobot_id = self.env['ir.model.data']._xmlid_to_res_id("base.partner_root") doc.message_post(body=msg, author_id=odoobot_id, subject=msg_subject) def action_show_details(self): diff --git a/addons/stock/tests/common.py b/addons/stock/tests/common.py index e853f6c3104..cdbd6c499f8 100644 --- a/addons/stock/tests/common.py +++ b/addons/stock/tests/common.py @@ -19,20 +19,20 @@ class TestStockCommon(common.TransactionCase): cls.LotObj = cls.env['stock.production.lot'] # Model Data - cls.picking_type_in = cls.ModelDataObj.xmlid_to_res_id('stock.picking_type_in') - cls.picking_type_out = cls.ModelDataObj.xmlid_to_res_id('stock.picking_type_out') + cls.picking_type_in = cls.ModelDataObj._xmlid_to_res_id('stock.picking_type_in') + cls.picking_type_out = cls.ModelDataObj._xmlid_to_res_id('stock.picking_type_out') cls.env['stock.picking.type'].browse(cls.picking_type_out).reservation_method = 'manual' - cls.supplier_location = cls.ModelDataObj.xmlid_to_res_id('stock.stock_location_suppliers') - cls.stock_location = cls.ModelDataObj.xmlid_to_res_id('stock.stock_location_stock') + cls.supplier_location = cls.ModelDataObj._xmlid_to_res_id('stock.stock_location_suppliers') + cls.stock_location = cls.ModelDataObj._xmlid_to_res_id('stock.stock_location_stock') pack_location = cls.env.ref('stock.location_pack_zone') pack_location.active = True cls.pack_location = pack_location.id output_location = cls.env.ref('stock.stock_location_output') output_location.active = True cls.output_location = output_location.id - cls.customer_location = cls.ModelDataObj.xmlid_to_res_id('stock.stock_location_customers') - cls.categ_unit = cls.ModelDataObj.xmlid_to_res_id('uom.product_uom_categ_unit') - cls.categ_kgm = cls.ModelDataObj.xmlid_to_res_id('uom.product_uom_categ_kgm') + cls.customer_location = cls.ModelDataObj._xmlid_to_res_id('stock.stock_location_customers') + cls.categ_unit = cls.ModelDataObj._xmlid_to_res_id('uom.product_uom_categ_unit') + cls.categ_kgm = cls.ModelDataObj._xmlid_to_res_id('uom.product_uom_categ_kgm') # Product Created A, B, C, D cls.productA = cls.ProductObj.create({'name': 'Product A', 'type': 'product'}) diff --git a/addons/stock/tests/test_report.py b/addons/stock/tests/test_report.py index 0f423f285bc..693fa874bdb 100644 --- a/addons/stock/tests/test_report.py +++ b/addons/stock/tests/test_report.py @@ -12,10 +12,10 @@ class TestReportsCommon(TransactionCase): super().setUpClass() cls.partner = cls.env['res.partner'].create({'name': 'Partner'}) cls.ModelDataObj = cls.env['ir.model.data'] - cls.picking_type_in = cls.env['stock.picking.type'].browse(cls.ModelDataObj.xmlid_to_res_id('stock.picking_type_in')) - cls.picking_type_out = cls.env['stock.picking.type'].browse(cls.ModelDataObj.xmlid_to_res_id('stock.picking_type_out')) - cls.supplier_location = cls.env['stock.location'].browse(cls.ModelDataObj.xmlid_to_res_id('stock.stock_location_suppliers')) - cls.stock_location = cls.env['stock.location'].browse(cls.ModelDataObj.xmlid_to_res_id('stock.stock_location_stock')) + cls.picking_type_in = cls.env['stock.picking.type'].browse(cls.ModelDataObj._xmlid_to_res_id('stock.picking_type_in')) + cls.picking_type_out = cls.env['stock.picking.type'].browse(cls.ModelDataObj._xmlid_to_res_id('stock.picking_type_out')) + cls.supplier_location = cls.env['stock.location'].browse(cls.ModelDataObj._xmlid_to_res_id('stock.stock_location_suppliers')) + cls.stock_location = cls.env['stock.location'].browse(cls.ModelDataObj._xmlid_to_res_id('stock.stock_location_stock')) product_form = Form(cls.env['product.product']) product_form.type = 'product' diff --git a/addons/stock_picking_batch/tests/test_batch_picking.py b/addons/stock_picking_batch/tests/test_batch_picking.py index 8efeb199511..bf66f3cb16e 100644 --- a/addons/stock_picking_batch/tests/test_batch_picking.py +++ b/addons/stock_picking_batch/tests/test_batch_picking.py @@ -15,7 +15,7 @@ class TestBatchPicking(TransactionCase): super(TestBatchPicking, self).setUp() self.stock_location = self.env.ref('stock.stock_location_stock') self.customer_location = self.env.ref('stock.stock_location_customers') - self.picking_type_out = self.env['ir.model.data'].xmlid_to_res_id('stock.picking_type_out') + self.picking_type_out = self.env['ir.model.data']._xmlid_to_res_id('stock.picking_type_out') self.env['stock.picking.type'].browse(self.picking_type_out).reservation_method = 'manual' self.productA = self.env['product.product'].create({ 'name': 'Product A', diff --git a/addons/test_event_full/tests/test_event_security.py b/addons/test_event_full/tests/test_event_security.py index 0dfe2a7a0db..a5ba250691d 100644 --- a/addons/test_event_full/tests/test_event_security.py +++ b/addons/test_event_full/tests/test_event_security.py @@ -94,7 +94,7 @@ class TestEventSecurity(TestEventCommon): 'name': 'ManagerEventType', 'event_type_mail_ids': [(5, 0), (0, 0, { 'interval_nbr': 1, 'interval_unit': 'days', 'interval_type': 'before_event', - 'template_ref': 'mail.template,%i' % self.env['ir.model.data'].xmlid_to_res_id('event.event_reminder')})] + 'template_ref': 'mail.template,%i' % self.env['ir.model.data']._xmlid_to_res_id('event.event_reminder')})] }) @users('user_eventmanager') @@ -105,7 +105,7 @@ class TestEventSecurity(TestEventCommon): 'name': 'ManagerEventType', 'event_type_mail_ids': [(5, 0), (0, 0, { 'interval_nbr': 1, 'interval_unit': 'days', 'interval_type': 'before_event', - 'template_ref': 'mail.template,%i' % self.env['ir.model.data'].xmlid_to_res_id('event.event_reminder')})] + 'template_ref': 'mail.template,%i' % self.env['ir.model.data']._xmlid_to_res_id('event.event_reminder')})] }) event_type.write({'name': 'New Name'}) diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py index 706b6aa7332..c525a6e12e0 100644 --- a/addons/test_mail/tests/test_performance.py +++ b/addons/test_mail/tests/test_performance.py @@ -748,7 +748,7 @@ class TestMailComplexPerformance(BaseMailPerformance): 'email_from': self.partners[0].email, 'model': 'mail.test.container', 'res_id': self.container.id, - 'subtype_id': self.env['ir.model.data'].xmlid_to_res_id('mail.mt_comment'), + 'subtype_id': self.env['ir.model.data']._xmlid_to_res_id('mail.mt_comment'), 'attachment_ids': [ (0, 0, { 'name': 'test file 0 - %d' % j, @@ -792,7 +792,7 @@ class TestMailComplexPerformance(BaseMailPerformance): 'email_from': self.partners[1].email, 'model': 'mail.test.container', 'res_id': self.container.id, - 'subtype_id': self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note'), + 'subtype_id': self.env['ir.model.data']._xmlid_to_res_id('mail.mt_note'), 'attachment_ids': [ (0, 0, { 'name': 'test file 1 - %d' % j, diff --git a/addons/test_mail_full/tests/test_odoobot.py b/addons/test_mail_full/tests/test_odoobot.py index ddd6015b7e1..62de2685c2a 100644 --- a/addons/test_mail_full/tests/test_odoobot.py +++ b/addons/test_mail_full/tests/test_odoobot.py @@ -70,7 +70,7 @@ class TestOdoobot(TestMailCommon, TestRecipients): answer=("@OdooBot",) ) kwargs['body'] = '' - kwargs['partner_ids'] = [self.env['ir.model.data'].xmlid_to_res_id("base.partner_root")] + kwargs['partner_ids'] = [self.env['ir.model.data']._xmlid_to_res_id("base.partner_root")] self.assertNextMessage( channel.message_post(**kwargs), sender=self.odoobot, diff --git a/addons/website/controllers/form.py b/addons/website/controllers/form.py index 3491966e363..5e162512c75 100644 --- a/addons/website/controllers/form.py +++ b/addons/website/controllers/form.py @@ -264,7 +264,7 @@ class WebsiteForm(http.Controller): 'message_type': 'comment', 'res_id': id_record, 'attachment_ids': [(6, 0, orphan_attachment_ids)], - 'subtype_id': request.env['ir.model.data'].xmlid_to_res_id('mail.mt_comment'), + 'subtype_id': request.env['ir.model.data']._xmlid_to_res_id('mail.mt_comment'), } mail_id = request.env['mail.message'].with_user(SUPERUSER_ID).create(values) else: diff --git a/addons/website/models/ir_module_module.py b/addons/website/models/ir_module_module.py index 09e5d4b8c2d..6d1e15a59b6 100644 --- a/addons/website/models/ir_module_module.py +++ b/addons/website/models/ir_module_module.py @@ -420,7 +420,7 @@ class IrModuleModule(models.Model): def get_themes_domain(self): """Returns the 'ir.module.module' search domain matching all available themes.""" def get_id(model_id): - return self.env['ir.model.data'].xmlid_to_res_id(model_id) + return self.env['ir.model.data']._xmlid_to_res_id(model_id) return [ ('category_id', 'not in', [ get_id('base.module_category_hidden'), diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 845a8871083..9b4e2142635 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -417,7 +417,7 @@ class View(models.Model): if values and 'main_object' in values: if request.env.user.has_group('website.group_website_publisher'): func = getattr(values['main_object'], 'get_backend_menu_id', False) - values['backend_menu_id'] = func and func() or self.env['ir.model.data'].xmlid_to_res_id('website.menu_website_configuration') + values['backend_menu_id'] = func and func() or self.env['ir.model.data']._xmlid_to_res_id('website.menu_website_configuration') if self._context != new_context: self = self.with_context(new_context) diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index 0699d456b63..ff49e3de336 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -1977,7 +1977,7 @@