Перейти к содержимому
Odoo Меню
  • Войти
  • Попробовать бесплатно
  • Модули
    Финансы
    • Бухгалтерия
    • Выставление счетов
    • Расходы
    • Таблицы
    • Документооборот
    • Подпись
    Продажи
    • CRM
    • Продажи
    • POS Магазин
    • POS Ресторан
    • Подписки
    • Аренда
    Вебсайты
    • Конструктор вебсайтов
    • eCommerce
    • Блог
    • Форум
    • Онлайн-чат
    • Электронное обучение
    Логистика
    • Склад
    • Производство
    • PLM
    • Закупки
    • Обслуживание
    • Качество
    Отдел кадров
    • Сотрудники
    • Подбор персонала
    • Отпуска
    • Оценка персонала
    • Реферальная программа
    • Автопарк
    Маркетинг
    • SMM
    • E-mail рассылки
    • СМС рассылки
    • Мероприятия
    • Автоматизация маркетинга
    • Опросы
    Услуги
    • Проекты
    • Табели
    • Выездной сервис
    • Поддержка
    • Планирование
    • Встречи
    Продуктивность
    • Обсуждения
    • Согласование
    • IoT
    • VoIP-телефония
    • Knowledge
    • WhatsApp
    Сторонние приложения Модуль Студия Odoo Платформа Odoo Cloud
  • Индустрии
    Розничная торговля
    • Книжный магазин
    • Магазин одежды
    • Мебельный магазин
    • Продуктовый магазин
    • Строительный магазин
    • Магазин игрушек
    Гостинично-ресторанный бизнес
    • Бар и паб
    • Ресторан
    • Фастфуд
    • Гостевой дом
    • Дистрибьютор напитков
    • Отель
    Недвижимость
    • Агентство недвижимости
    • Архитектурное бюро
    • Строительство
    • Управление недвижимостью
    • Ландшафтный дизайн
    • Товарищество собственников жилья
    Консалтинг
    • Бухгалтерская фирма
    • Партнер Odoo
    • Маркетинговое агентство
    • Юридическая фирма
    • Подбор персонала
    • Аудиторское бюро
    Производство
    • Текстиль
    • Металл
    • Мебель
    • Продукты питания
    • Пивоварня
    • Корпоративные сувениры
    Здоровье и фитнес
    • Спортивный комплекс
    • Магазин оптики
    • Фитнес-клуб
    • Велнес-центр
    • Аптека
    • Салон красоты
    Услуги
    • Специалист по бытовым услугам
    • Продажа и обслуживание IT-оборудования
    • Солнечные энергосистемы
    • Производство обуви
    • Клининг
    • Системы ОВКВ
    Прочее
    • Некоммерческая организация
    • Консалтинг в сфере устойчивого развития
    • Аренда рекламных щитов
    • Бизнес по фотосъемке
    • Прокат велосипедов
    • Реселлер программного обеспечения
    Все индустрии
  • Community
    Обучение
    • Видео уроки
    • Документация
    • Сертификация
    • Тренинг
    • Блог
    • Подкаст
    Образование и развитие
    • Образовательная программа
    • Деловая игра Scale Up!
    • Экскурсия в офис Odoo
    ПО
    • Скачать
    • Сравнить версии
    • Релизы
    Сотрудничество
    • Github
    • Форум
    • Мероприятия
    • Перевод
    • Стать партнером
    • Услуги для партнеров
    • Зарегистрировать бухгалтерскую фирму
    Услуги
    • Найти партнера
    • Найти бухгалтера
    • Встреча с экспертом
    • Услуги по внедрению
    • Отзывы клиентов
    • Поддержка
    • Обновления
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Заказать демонстрацию
  • Цены
  • Поддержка

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Бухгалтерия
  • Склад
  • PoS
  • Проекты
  • MRP
All apps
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Все посты Люди Значки
Теги (Смотреть все)
odoo accounting v14 pos v15
Об этом форуме
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Все посты Люди Значки
Теги (Смотреть все)
odoo accounting v14 pos v15
Об этом форуме
Помощь

Is there a way to add "Archive" action to an existing model?

Подписаться

Получайте уведомления о появлении активности в этом посте

Этот вопрос был отмечен
serveractionTechnicalStudioArchiveSF-Experts
1 Ответить
12660 Представления
Аватар
Harishankar Unnikrishnan (hun)

There are models in Odoo that do not have the "Archive" action under the 'Action' button. Additionally, if we create a new model and do not check the option to allow records to be Archived, can we add it in later? 

0
Аватар
Отменить
Niyas Raphy (Walnut Software Solutions)

From code side: https://www.youtube.com/watch?v=aSs0aKsbUqo

Аватар
Harishankar Unnikrishnan (hun)
Автор Лучший ответ

What does “Archive” Action do?

Before we jump into the steps for achieving this, let’s explore what the “Archive” button does. In Odoo, ‘Archive’ is nothing, but a filter based on a Boolean field. Odoo models that have archiving capabilities usually have a field called “Active”, which is a simple Boolean checkbox. Basically, if it is checked, it means that the record is active and if it is unchecked it means the record is not active i.e., archived. When you select a record and archive it, Odoo is unchecking the box for you and then filtering it out. By default, in a model view, you have displayed only the active records, and the archived ones are filtered. When you click on “Filters” and then select the Archived records it basically just shows you all the records that have the checkbox set to FALSE. For models that do not have the archiving function, we are missing this checkbox and some defaults which we can create later. The only step in this that may require direct XML coding will be adding the ribbon that says “Archived” on all the archived records.

Creating the Boolean field

The first step of the process is to create this checkbox that will help us differentiate archived from active records. Do not create this checkbox using studio because the field will be called x_studio_active and that won’t do. We will need to create the field directly on the model itself. 

Go into Settings > Technical > Models, find your model, and add a boolean field named "x_active" (label "Active")

Once you create the field on the model, you must add the field on the form and list views so that we can use it to create the filters.  You can add the field using Studio by simply finding it under “Existing Fields”. You don’t necessarily have to make it visible, as long as it is present in both views. In other models, this field is usually invisible so you can make it invisible after adding it.

Existing Records

If the model you are doing this has existing records, we need to make them active. When we add a new checkbox, Odoo defaults it to be unchecked for all records. This means that all the existing records will have the checkbox set to FALSE (meaning archived). This can be fixed by simply exporting all the existing records with external ID’s and the Active field, setting the Active field to be TRUE, and importing it back in so that all the records now have the Active field checked (hence meaning unarchived). 

Setting User-defined Defaults

For new records that will be created in the model, we need Odoo to automatically check the box. This means that the default for the Active field should be TRUE (checked). We can do this using User-defined Defaults.

Go into Settings > Technical > User-defined default and add a default set to true for the field.

Creating custom Filters for Archived records

We need a preset Filter for displaying all the Archived records. We can do this using Studio.

Open the model – Open Studio – Click on Views and select Search View. Drag a Filter and drop it under ‘Filters’. Label it “Archived” and set a domain on it – Active is not set (false) [["x_active","=",False]]

[OPTIONAL] Adding the Ribbon to Archived Records

We can also add the ribbon widget in the form view, but this can be done only through XML. Open the form view of the model, open studio, click on “View” on the left bar, click on the XML button to open the code and add the following lines of code as the first child of the sheet element in the form view.

Save the XML and exit Studio. You’re all set! 

2
Аватар
Отменить
Не оставайтесь в стороне – присоединяйтесь к обсуждению!

Создайте аккаунт сегодня, чтобы получить доступ к эксклюзивным функциям и стать частью нашего замечательного сообщества!

Регистрация
Похожие посты Ответы Просмотры Активность
How to override access rights and record rules in a server action? Решено
serveraction Studio SF-Experts
Аватар
1
дек. 23
3076
How can I create a customer invoice from a task and link it to the task? Решено
Studio SF-Experts
Аватар
1
окт. 25
2544
How can I create a vendor refund from a task and link it to the task? Решено
Studio SF-Experts
Аватар
1
авг. 24
1782
How can I create a vendor bill from a task and link it to the task? Решено
Studio SF-Experts
Аватар
1
авг. 24
2532
How can I create a customer credit note from a task and link it to the task? Решено
Studio SF-Experts
Аватар
1
авг. 24
1993
Сообщество
  • Видео уроки
  • Документация
  • Форум
Открытый исходный код
  • Скачать
  • Github
  • Runbot
  • Перевод
Услуги
  • Хостинг Odoo.sh
  • Поддержка
  • Обновление
  • Индивидуальные решения по доработке
  • Образование
  • Найти бухгалтера
  • Найти партнера
  • Стать партнером
О нас
  • Наша компания
  • Активы бренда
  • Cвяжитесь с нами
  • Вакансии
  • Мероприятия
  • Подкаст
  • Блог
  • Клиенты
  • Правовые документы • Конфиденциальность
  • Безопасность
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo – это набор бизнес-модулей с открытым исходным кодом, который закроет все потребности вашей компании: CRM, E-commerce, Бухгалтерия, Склад, POS, управление проектами и др.

Odoo сочетает в себе простоту использования и полную интеграцию всех бизнес-процессов в одной системе.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now