ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

How to Replace Record Name in Specific Action in Odoo

how to replace record name in specific action in odoo?

python

xml

odoo

Автор: vlogize

Загружено: 2025-08-29

Просмотров: 3

Описание: Discover how to customize the `_rec_name` field for specific user groups in Odoo by overriding the `name_get` method.
---
This video is based on the question https://stackoverflow.com/q/64265510/ asked by the user 'Mohamed Fouad' ( https://stackoverflow.com/u/7862342/ ) and on the answer https://stackoverflow.com/a/64351008/ provided by the user 'Mohamed Fouad' ( https://stackoverflow.com/u/7862342/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.

Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: how to replace record name in specific action in odoo?

Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l...
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license.

If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com.
---
Introduction

When working with Odoo, a powerful open-source ERP platform, customization is often required to meet specific business needs. A common challenge developers face is how to replace the default record name displayed in certain menus or actions based on user permissions or roles. This post will guide you through the steps to achieve this by modifying the behavior of a model, specifically for a model called patient, which contains all patient data.

The Problem

In the scenario presented, the user needed to create a menu that would allow a certain group of users to view patient records without revealing sensitive data such as their names. By default, the name that appears in lists and forms is controlled by _rec_name, which often defaults to a field like Name. Instead, the requirement was to replace the name displayed in the specific action with either another field or a static label like “Patient.”

The Solution

To resolve this, we can override the name_get method in the patient model. This method is responsible for fetching the record name as it appears in various views throughout Odoo. By adding conditional logic, we can customize the output based on whether the user belongs to the specified group. Here’s a step-by-step breakdown of how to implement this solution.

Step 1: Navigate to Your Model

First, ensure you have access to the model definition where you want to implement the changes—in this case, the patient model.

Step 2: Override the name_get Method

You will need to create a custom implementation of the name_get method by adding the following code to your model:

[[See Video to Reveal this Text or Code Snippet]]

Explanation of the Code

Condition Check: The method checks if the current user is part of a specific access group using self.env.user.has_group(...). Replace 'pl_analytic.group_pl_analytic' with the correct identifier for your user group.

Record Name Formatting:

For users not in the specified group, the code fetches the full name of the patient using the full_name field.

For users in the specified group, it uses an alternative identifier, identification_code, to display instead.

Result Construction: The method builds a list of tuples, where each tuple contains the patient's ID and the desired display name.

Step 3: Test Your Changes

Once you've added this method to your model, it's essential to test it:

Log in as users from both groups and verify the displayed record names in the patient model.

Ensure that the modifications work seamlessly without affecting other operations within Odoo, maintaining the integrity of the access controls you have set up.

Conclusion

By following these steps, you can easily customize the displayed names of models in Odoo based on user access levels. This method keeps sensitive data hidden while tailoring the user experience to match the needs of different user groups. Remember, customizing Odoo’s functionality can significantly enhance its usability and security for your organization.

If you have any questions or need further assistance with Odoo customizations, feel free to reach out!

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
How to Replace Record Name in Specific Action in Odoo

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Как превратить таблицы Excel в мощные приложения (2025) | Пошаговое руководство для начинающих

Как превратить таблицы Excel в мощные приложения (2025) | Пошаговое руководство для начинающих

Интернет по паспорту и блокировка Телеграм с 1 марта

Интернет по паспорту и блокировка Телеграм с 1 марта

Борцы грабят банк, Борцы играют в

Борцы грабят банк, Борцы играют в "Что? Где? Когда?", Кафе "Северное сияние" - КВН Борцы

Сисадмины больше не нужны? Gemini настраивает Linux сервер и устанавливает cтек N8N. ЭТО ЗАКОННО?

Сисадмины больше не нужны? Gemini настраивает Linux сервер и устанавливает cтек N8N. ЭТО ЗАКОННО?

AI-002 : How to Set Up Python for AI | Install Python, VS Code & Jupyter (AI Engineer Roadmap #002)

AI-002 : How to Set Up Python for AI | Install Python, VS Code & Jupyter (AI Engineer Roadmap #002)

ABAP RESTful Application Programming Model (RAP) Free Learning Videos

ABAP RESTful Application Programming Model (RAP) Free Learning Videos

Beginner PowerShell 7 Tutorials

Beginner PowerShell 7 Tutorials

10 НАУЧНО-ФАНТАСТИЧЕСКИХ ФИЛЬМОВ, КОТОРЫЕ СТОИТ ПОСМОТРЕТЬ ХОТЯ БЫ РАЗ В ЖИЗНИ!

10 НАУЧНО-ФАНТАСТИЧЕСКИХ ФИЛЬМОВ, КОТОРЫЕ СТОИТ ПОСМОТРЕТЬ ХОТЯ БЫ РАЗ В ЖИЗНИ!

Я В ШОКЕ! Обновление Windows убило ноутбук за 5 минут. Вот что случилось...

Я В ШОКЕ! Обновление Windows убило ноутбук за 5 минут. Вот что случилось...

Deep House Mix 2024 | Deep House, Vocal House, Nu Disco, Chillout Mix by Diamond #3

Deep House Mix 2024 | Deep House, Vocal House, Nu Disco, Chillout Mix by Diamond #3

MacOS vs Linux vs Windows: Best OS for programming with AI agents | Peter Steinberger

MacOS vs Linux vs Windows: Best OS for programming with AI agents | Peter Steinberger

TypeScript ФУНДАМЕНТАЛЬНЫЙ КУРС от А до Я. Вся теория + практика

TypeScript ФУНДАМЕНТАЛЬНЫЙ КУРС от А до Я. Вся теория + практика

Если у тебя спросили «Как твои дела?» — НЕ ГОВОРИ! Ты теряешь свою силу | Еврейская мудрость

Если у тебя спросили «Как твои дела?» — НЕ ГОВОРИ! Ты теряешь свою силу | Еврейская мудрость

Abstract Black and White wave pattern| Height Map Footage| 3 hours Topographic 4k  Background

Abstract Black and White wave pattern| Height Map Footage| 3 hours Topographic 4k Background

Учебное пособие по Odoo для начинающих

Учебное пособие по Odoo для начинающих

Понимание Active Directory и групповой политики

Понимание Active Directory и групповой политики

Docker за 20 минут

Docker за 20 минут

Music for Men Who Stay Silent | Gentleman Dark Blues

Music for Men Who Stay Silent | Gentleman Dark Blues

Учебное пособие по DBeaver — как использовать DBeaver (редактор SQL)

Учебное пособие по DBeaver — как использовать DBeaver (редактор SQL)

Circles - Area, Circumference, Radius & Diameter Explained!

Circles - Area, Circumference, Radius & Diameter Explained!

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]