Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
serveractionTechnicalStudioArchiveSF-Experts
1 Odpoveď
12624 Zobrazenia
Avatar
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
Avatar
Zrušiť
Niyas Raphy (Walnut Software Solutions)

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

Avatar
Harishankar Unnikrishnan (hun)
Autor Best Answer

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
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
How to override access rights and record rules in a server action? Solved
serveraction Studio SF-Experts
Avatar
1
dec 23
3057
How can I create a customer invoice from a task and link it to the task? Solved
Studio SF-Experts
Avatar
1
okt 25
2531
How can I create a vendor refund from a task and link it to the task? Solved
Studio SF-Experts
Avatar
1
aug 24
1771
How can I create a vendor bill from a task and link it to the task? Solved
Studio SF-Experts
Avatar
1
aug 24
2523
How can I create a customer credit note from a task and link it to the task? Solved
Studio SF-Experts
Avatar
1
aug 24
1982
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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