diff options
| -rw-r--r-- | addons/account/models/account_bank_statement.py | 5 | ||||
| -rw-r--r-- | addons/account/models/account_journal_dashboard.py | 8 | ||||
| -rw-r--r-- | addons/account/models/account_move.py | 2 | ||||
| -rw-r--r-- | addons/account/wizard/wizard_tax_adjustments.py | 3 | ||||
| -rw-r--r-- | addons/account_fleet/models/fleet_vehicle.py | 3 | ||||
| -rw-r--r-- | addons/crm/models/res_partner.py | 2 | ||||
| -rw-r--r-- | addons/crm/models/utm.py | 2 | ||||
| -rw-r--r-- | addons/hr/models/res_users.py | 2 | ||||
| -rw-r--r-- | addons/hr_expense/models/account_journal_dashboard.py | 2 | ||||
| -rw-r--r-- | addons/hr_recruitment/models/hr_recruitment.py | 3 | ||||
| -rw-r--r-- | addons/point_of_sale/models/pos_order.py | 3 | ||||
| -rw-r--r-- | addons/point_of_sale/models/pos_session.py | 3 | ||||
| -rw-r--r-- | addons/project/models/project.py | 3 | ||||
| -rw-r--r-- | addons/purchase/models/purchase.py | 5 | ||||
| -rw-r--r-- | addons/purchase_stock/models/stock.py | 3 | ||||
| -rw-r--r-- | addons/stock_account/models/stock_inventory.py | 5 | ||||
| -rw-r--r-- | addons/stock_account/models/stock_move.py | 5 | ||||
| -rw-r--r-- | addons/survey/models/survey_survey.py | 9 | ||||
| -rw-r--r-- | odoo/tools/test_reports.py | 4 |
19 files changed, 25 insertions, 47 deletions
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index e3726860b71..5f46bf53a37 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -419,10 +419,7 @@ class AccountBankStatement(models.Model): def button_validate_or_action(self): if self.journal_type == 'cash' and not self.currency_id.is_zero(self.difference): - action_rec = self.env['ir.model.data'].xmlid_to_object('account.action_view_account_bnk_stmt_check') - if action_rec: - action = action_rec.read()[0] - return action + return self.env['ir.actions.act_window']._for_xml_id('account.action_view_account_bnk_stmt_check') return self.button_validate() diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index efddf269bdb..53d2140d52c 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -456,7 +456,7 @@ class account_journal(models.Model): action_name = self._select_action_to_open() # Set 'account.' prefix if missing. - if '.' not in action_name: + if not action_name.startswith("account."): action_name = 'account.%s' % action_name action = self.env["ir.actions.act_window"]._for_xml_id(action_name) @@ -500,7 +500,7 @@ class account_journal(models.Model): action_ref = 'account.action_account_payments_transfer' else: action_ref = 'account.action_account_payments' - [action] = self.env.ref(action_ref).read() + action = self.env['ir.actions.act_window']._for_xml_id(action_ref) action['context'] = dict(ast.literal_eval(action.get('context')), default_journal_id=self.id, search_default_journal_id=self.id) if payment_type == 'transfer': action['context'].update({ @@ -520,9 +520,7 @@ class account_journal(models.Model): ctx.update(search_default_journal_id=self.id) del ctx['search_default_journal'] # otherwise it will do a useless groupby in bank statements ctx.pop('group_by', None) - ir_model_obj = self.env['ir.model.data'] - model, action_id = ir_model_obj.get_object_reference('account', action_name) - [action] = self.env[model].browse(action_id).read() + action = self.env['ir.actions.act_window']._for_xml_id(f"account.{action_name}") action['context'] = ctx if ctx.get('use_domain', False): action['domain'] = isinstance(ctx['use_domain'], list) and ctx['use_domain'] or ['|', ('journal_id', '=', self.id), ('journal_id', '=', False)] diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 9decc62a290..6e9e9f0929b 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -4701,7 +4701,7 @@ class AccountMoveLine(models.Model): return action def action_automatic_entry(self): - [action] = self.env.ref('account.account_automatic_entry_wizard_action').read() + action = self.env['ir.actions.act_window']._for_xml_id('account.account_automatic_entry_wizard_action') # Force the values of the move line in the context to avoid issues ctx = dict(self.env.context) ctx.pop('active_id', None) diff --git a/addons/account/wizard/wizard_tax_adjustments.py b/addons/account/wizard/wizard_tax_adjustments.py index 9d011daf837..6214f572042 100644 --- a/addons/account/wizard/wizard_tax_adjustments.py +++ b/addons/account/wizard/wizard_tax_adjustments.py @@ -61,8 +61,7 @@ class TaxAdjustments(models.TransientModel): move._post() # Return an action opening the created move - action = self.env.ref(self.env.context.get('action', 'account.action_move_line_form')) - result = action.read()[0] + result = self.env['ir.actions.act_window']._for_xml_id('account.action_move_line_form') result['views'] = [(False, 'form')] result['res_id'] = move.id return result diff --git a/addons/account_fleet/models/fleet_vehicle.py b/addons/account_fleet/models/fleet_vehicle.py index 1bd640b763c..1d4de3d7278 100644 --- a/addons/account_fleet/models/fleet_vehicle.py +++ b/addons/account_fleet/models/fleet_vehicle.py @@ -26,8 +26,7 @@ class FleetVehicle(models.Model): form_view_ref = self.env.ref('account.view_move_form', False) tree_view_ref = self.env.ref('account.view_move_tree', False) - action = self.env.ref('account.action_move_in_invoice_type') - result = action.read()[0] + result = self.env['ir.actions.act_window']._for_xml_id('account.action_move_in_invoice_type') result.update({ 'domain': [('id', 'in', self.account_move_ids.ids)], 'views': [(tree_view_ref.id, 'tree'), (form_view_ref.id, 'form')], diff --git a/addons/crm/models/res_partner.py b/addons/crm/models/res_partner.py index 742b7b3ed88..03e76b810c7 100644 --- a/addons/crm/models/res_partner.py +++ b/addons/crm/models/res_partner.py @@ -107,7 +107,7 @@ class Partner(models.Model): ''' This function returns an action that displays the opportunities from partner. ''' - action = self.env.ref('crm.crm_lead_opportunities').read()[0] + action = self.env['ir.actions.act_window']._for_xml_id('crm.crm_lead_opportunities') if self.is_company: action['domain'] = [('partner_id.commercial_partner_id.id', '=', self.id)] else: diff --git a/addons/crm/models/utm.py b/addons/crm/models/utm.py index fd093579217..b1dcb5ed7b1 100644 --- a/addons/crm/models/utm.py +++ b/addons/crm/models/utm.py @@ -23,7 +23,7 @@ class UtmCampaign(models.Model): def action_redirect_to_leads_opportunities(self): view = 'crm.crm_lead_all_leads' if self.use_leads else 'crm.crm_lead_opportunities' - action = self.env.ref(view).sudo().read()[0] + action = self.env['ir.actions.act_window']._for_xml_id(view) action['view_mode'] = 'tree,kanban,graph,pivot,form,calendar' action['domain'] = [('campaign_id', 'in', self.ids)] action['context'] = {'active_test': False, 'create': False} diff --git a/addons/hr/models/res_users.py b/addons/hr/models/res_users.py index 2c7a66db97b..cc53e167cb3 100644 --- a/addons/hr/models/res_users.py +++ b/addons/hr/models/res_users.py @@ -188,7 +188,7 @@ class User(models.Model): @api.model def action_get(self): if self.env.user.employee_id: - return self.sudo().env.ref('hr.res_users_action_my').sudo().read()[0] + return self.env['ir.actions.act_window']._for_xml_id('hr.res_users_action_my') return super(User, self).action_get() @api.depends('employee_ids') diff --git a/addons/hr_expense/models/account_journal_dashboard.py b/addons/hr_expense/models/account_journal_dashboard.py index a41198f30f9..23dbb802e42 100644 --- a/addons/hr_expense/models/account_journal_dashboard.py +++ b/addons/hr_expense/models/account_journal_dashboard.py @@ -32,7 +32,7 @@ class AccountJournal(models.Model): return res def open_expenses_action(self): - [action] = self.env.ref('hr_expense.action_hr_expense_sheet_all_all').read() + action = self.env['ir.actions.act_window']._for_xml_id('hr_expense.action_hr_expense_sheet_all_all') action['context'] = { 'search_default_approved': 1, 'search_default_to_post': 1, diff --git a/addons/hr_recruitment/models/hr_recruitment.py b/addons/hr_recruitment/models/hr_recruitment.py index 716cb200b0a..bb7b0dd475c 100644 --- a/addons/hr_recruitment/models/hr_recruitment.py +++ b/addons/hr_recruitment/models/hr_recruitment.py @@ -349,8 +349,7 @@ class Applicant(models.Model): return res def action_get_attachment_tree_view(self): - attachment_action = self.env.ref('base.action_attachment') - action = attachment_action.read()[0] + action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment') action['context'] = {'default_res_model': self._name, 'default_res_id': self.ids[0]} action['domain'] = str(['&', ('res_model', '=', self._name), ('res_id', 'in', self.ids)]) action['search_view_id'] = (self.env.ref('hr_recruitment.ir_attachment_view_search_inherit_hr_recruitment').id, ) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index a169178efb3..32a0d05a2df 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -342,8 +342,7 @@ class PosOrder(models.Model): def action_stock_picking(self): self.ensure_one() - action_picking = self.env.ref('stock.action_picking_tree_ready') - action = action_picking.read()[0] + action = self.env['ir.actions.act_window']._for_xml_id('stock.action_picking_tree_ready') action['context'] = {} action['domain'] = [('id', 'in', self.picking_ids.ids)] return action diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index f4fb15017db..a046c9707f7 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -141,8 +141,7 @@ class PosSession(models.Model): def action_stock_picking(self): self.ensure_one() - action_picking = self.env.ref('stock.action_picking_tree_ready') - action = action_picking.read()[0] + action = self.env['ir.actions.act_window']._for_xml_id('stock.action_picking_tree_ready') action['context'] = {} action['domain'] = [('id', 'in', self.picking_ids.ids)] return action diff --git a/addons/project/models/project.py b/addons/project/models/project.py index da3d30dddb6..252debd704b 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -121,8 +121,7 @@ class Project(models.Model): project.task_count = result.get(project.id, 0) def attachment_tree_view(self): - attachment_action = self.env.ref('base.action_attachment') - action = attachment_action.read()[0] + action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment') action['domain'] = str([ '|', '&', diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 5dbf657cd53..3dab310ea39 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -557,8 +557,7 @@ class PurchaseOrder(models.Model): self.sudo()._read(['invoice_ids']) invoices = self.invoice_ids - action = self.env.ref('account.action_move_in_invoice_type').sudo() - result = action.read()[0] + result = self.env['ir.actions.act_window']._for_xml_id('account.action_move_in_invoice_type') # choose the view_mode accordingly if len(invoices) > 1: result['domain'] = [('id', 'in', invoices.ids)] @@ -566,7 +565,7 @@ class PurchaseOrder(models.Model): res = self.env.ref('account.view_move_form', False) form_view = [(res and res.id or False, 'form')] if 'views' in result: - result['views'] = form_view + [(state, view) for state, view in action['views'] if view != 'form'] + result['views'] = form_view + [(state, view) for state, view in result['views'] if view != 'form'] else: result['views'] = form_view result['res_id'] = invoices.id diff --git a/addons/purchase_stock/models/stock.py b/addons/purchase_stock/models/stock.py index 526c96f124c..2aadedd4638 100644 --- a/addons/purchase_stock/models/stock.py +++ b/addons/purchase_stock/models/stock.py @@ -200,8 +200,7 @@ class Orderpoint(models.Model): """ This function returns an action that display existing purchase orders of given orderpoint. """ - action = self.env.ref('purchase.purchase_rfq') - result = action.read()[0] + result = self.env['ir.actions.act_window']._for_xml_id('purchase.purchase_rfq') # Remvove the context since the action basically display RFQ and not PO. result['context'] = {} diff --git a/addons/stock_account/models/stock_inventory.py b/addons/stock_account/models/stock_inventory.py index 03522076eae..6dafe449db7 100644 --- a/addons/stock_account/models/stock_inventory.py +++ b/addons/stock_account/models/stock_inventory.py @@ -26,10 +26,7 @@ class StockInventory(models.Model): def action_get_account_moves(self): self.ensure_one() - action_ref = self.env.ref('account.action_move_journal_line') - if not action_ref: - return False - action_data = action_ref.read()[0] + action_data = self.env['ir.actions.act_window']._for_xml_id('account.action_move_journal_line') action_data['domain'] = [('stock_move_id.id', 'in', self.move_ids.ids)] action_data['context'] = dict(self._context, create=False) return action_data diff --git a/addons/stock_account/models/stock_move.py b/addons/stock_account/models/stock_move.py index cb11e71fd57..2c90c4af584 100644 --- a/addons/stock_account/models/stock_move.py +++ b/addons/stock_account/models/stock_move.py @@ -21,10 +21,7 @@ class StockMove(models.Model): def action_get_account_moves(self): self.ensure_one() - action_ref = self.env.ref('account.action_move_journal_line') - if not action_ref: - return False - action_data = action_ref.read()[0] + action_data = self.env['ir.actions.act_window']._for_xml_id('account.action_move_journal_line') action_data['domain'] = [('id', 'in', self.account_move_ids.ids)] return action_data diff --git a/addons/survey/models/survey_survey.py b/addons/survey/models/survey_survey.py index 0b846cccad0..12f6d7114e3 100644 --- a/addons/survey/models/survey_survey.py +++ b/addons/survey/models/survey_survey.py @@ -879,8 +879,7 @@ class Survey(models.Model): } def action_survey_user_input_completed(self): - action_rec = self.env.ref('survey.action_survey_user_input') - action = action_rec.read()[0] + action = self.env['ir.actions.act_window']._for_xml_id('survey.action_survey_user_input') ctx = dict(self.env.context) ctx.update({'search_default_survey_id': self.ids[0], 'search_default_completed': 1, @@ -889,8 +888,7 @@ class Survey(models.Model): return action def action_survey_user_input_certified(self): - action_rec = self.env.ref('survey.action_survey_user_input') - action = action_rec.read()[0] + action = self.env['ir.actions.act_window']._for_xml_id('survey.action_survey_user_input') ctx = dict(self.env.context) ctx.update({'search_default_survey_id': self.ids[0], 'search_default_scoring_success': 1, @@ -899,8 +897,7 @@ class Survey(models.Model): return action def action_survey_user_input(self): - action_rec = self.env.ref('survey.action_survey_user_input') - action = action_rec.read()[0] + action = self.env['ir.actions.act_window']._for_xml_id('survey.action_survey_user_input') ctx = dict(self.env.context) ctx.update({'search_default_survey_id': self.ids[0], 'search_default_not_test': 1}) diff --git a/odoo/tools/test_reports.py b/odoo/tools/test_reports.py index 2ee6d16ae95..96d6b6fb89e 100644 --- a/odoo/tools/test_reports.py +++ b/odoo/tools/test_reports.py @@ -74,7 +74,7 @@ def try_report(cr, uid, rname, ids, data=None, context=None, our_module=None, re def try_report_action(cr, uid, action_id, active_model=None, active_ids=None, wiz_data=None, wiz_buttons=None, context=None, our_module=None): - """Take an ir.action.act_window and follow it until a report is produced + """Take an ir.actions.act_window and follow it until a report is produced :param action_id: the integer id of an action, or a reference to xml id of the act_window (can search [our_module.]+xml_id @@ -121,7 +121,7 @@ def try_report_action(cr, uid, action_id, active_model=None, active_ids=None, act_model, act_id = action._name, action.id else: assert isinstance(action_id, int) - act_model = 'ir.action.act_window' # assume that + act_model = 'ir.actions.act_window' # assume that act_id = action_id act_xmlid = '<%s>' % act_id |
