Skip to content

Instantly share code, notes, and snippets.

@ofelix03
Last active November 5, 2022 20:20
Show Gist options
  • Save ofelix03/9b371f94a3c9eff042a2fbd03a1ea215 to your computer and use it in GitHub Desktop.
Save ofelix03/9b371f94a3c9eff042a2fbd03a1ea215 to your computer and use it in GitHub Desktop.
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