From c7bac3dee0bbc8b9e3d0e2dda419f3875916d96e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 6 Jul 2021 12:26:00 +0200 Subject: [PATCH] [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 @@