Data Recycle - Odoo 20 Community Book

Making a Rule

The List of Rules

Configuration > Rules > Recycle Records lists the rules, with the columns Name, Model and Active. The columns Recycle Mode and Recycle Action are added in developer mode. It is empty at the start.

odoo Development

The Form of a Rule

Click New. The form has the name of the rule in big letters at the top, the button Run Now, and a smart button Records with the number of suggestions of the rule.

odoo Development

Model. The kind of record to clean. Type a name and Odoo lists the models. We typed Calendar Event. The list also offers two technical models of the calendar (the wizards), which are not what you want here.

odoo Development

When you choose the model, the name of the rule is filled with the name of the model. We wrote our own, Old meetings.

Active. The switch that turns the rule on or off. A rule that is switched off makes no suggestion, and its old suggestions are removed.

Recycle Mode. Manual (the first choice) or Automatic. When you click Automatic, a window called Automatic Mode warns you: when you enable the automatic mode, your rules run periodically without manual validation, and the changes are permanent and cannot be reversed. Click Close to go back to Manual.

odoo Development

Recycle Action. Delete (the choice that Odoo gives first) or Archive. We chose Archive. A model can be archived only if its records have the field Active. For the others Odoo says that the model does not manage archived records and only deletion is possible.

Include archived. A switch that shows only when the Recycle Action is Delete. When it is on, the records that are already archived are looked at too.

Notify Users and Every. The people who get a message in Discuss when new suggestions are waiting, and how often: a number and Days, Weeks or Months. Odoo puts you in the list, once a week. The help of the field says that it is a list of users to notify when there are new records to recycle. Only users of the administrator group can be chosen. The message is for the manual mode only.

odoo Development

Which Records: Filter and Age

Two parts decide which records match.

Filter. At first it says Match all records, with a link New Rule and a link that shows how many records of the model there are (17 for us). Click New Rule and Odoo adds a line: a field, a test (is equal to, and others) and a value. You can add many lines, and choose if all of them or any of them must match.

odoo Development

Time Field, Delta and Delta Unit. The age. The Time Field is a date field of the model (we chose Start of the meeting, in the list that also had Start Date). Delta is a number, and Delta Unit is Days, Weeks, Months (the default) or Years. A record matches when its date is older than the number of units before now. We chose 3 months.

odoo Development

Click the cloud icon to save. This is our rule: calendar events, manual mode, archive, started more than 3 months ago.

odoo Development odoo Development

The list of the rules now has one line.

odoo Development
WhatsApp