Last active
November 5, 2022 20:20
-
-
Save ofelix03/9b371f94a3c9eff042a2fbd03a1ea215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from odoo import models | |
class SomeModel(models.Model): | |
_name = 'some.model' | |
# Defines the field used to to store records archive state | |
# Odoo supports only two fields for archiving and unarchiving records, active and x_active field | |
_active_name = 'x_active' | |
def action_archive_method(self): | |
# Archives a record by setting x_active field to True | |
self.action_archive() | |
def action_unarchive_method(self): | |
# Unarchives a record by setting x_active field to False | |
self.action_unarchive() | |
def action_toggle_active_method(self): | |
# Toggles the archive state to True/False based on the current state | |
self.toggle_active() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment