Enable Dark Mode!
how-to-automate-journal-entry-reversals-in-odoo-19.jpg
By: Safa KB

How to Automate Journal Entry Reversals in Odoo 19

Technical Odoo 19 Odoo Enterprises Odoo Community

End-of-month accounting frequently involves posting accrual journal entries, which need to be reversed at a later date. Although making such entries is not difficult, reversing them in due time might be troublesome for the finance team.

This module, called Journal Entry Auto Reversal for Odoo 19 customization, solves this problem through the scheduling of journal entry reversals on a particular future date. It can automatically send a notification to the original entry creator via email.

Reversal Challenges Using Manually Driven Process

There exist various expenses, revenues, and intercompany transactions that are recorded through accrual entries and must be reversed in due time. While there is an option in the Odoo standard version to define the reversal date, the reversal must be done manually nonetheless.

As a result, there will be a problem of not being able to complete the reversal process in time, and other problems, such as double-counting, may occur.

The Solution

To solve these problems, the customization provides an automatic reversal capability of Odoo's journal entry creation process.

During the process of journal entry creation, the user just has to click on the Auto Reverse checkbox and choose the Reverse Date. As soon as the journal entry is posted, everything else is done by the system itself.

No need to make reminders or use spreadsheets anymore.

Additional Fields

Three additional fields are introduced on the journal entry form.

class InheritAccountMove(models.Model):
   _inherit = "account.move"
   auto_reverse = fields.Boolean(copy=False)
   reverse_date = fields.Date(copy=False)
   already_reversed = fields.Boolean(copy=False)
  1. The Auto Reverse checkbox allows users to indicate fields. The journal entry should be automatically reversed in the future.
  2. The Reverse Date field specifies exactly when the reversal should occur.
  3. The Already Reversed field is maintained by the system and helps prevent duplicate reversals.
  <odoo>
 <record id="account_move_form_inherit" model="ir.ui.view">
       <field name="name">account_move_form_inherit</field>
       <field name="model">account.move</field>
       <field name="inherit_id" ref="account.view_move_form"/>
       <field name="arch" type="xml">
           <xpath expr="//page[@id='other_tab_entry']//field[@name='auto_post']" position="after">
               <field name="already_reversed" invisible="1"/>
               <field name="auto_reverse"/>
               <field name="reverse_date"
                       required="auto_reverse != False"/>
           </xpath>
       </field>
   </record>
</odoo>

From the user’s point of view, everything is still very straightforward. They make their entries, turn on Auto Reverse, set the date of the reversal, and then post the entry. That’s all there is to it.

How does the Automation Works?

This process will involve running an automated Odoo cron job that will execute daily, searching for journal entries that need reversing.

These journal entries are those that:

  • Have Automatic Reversal ticked.
  • Have not been reversed yet.
  • Are posted journal entries.
  • Match today’s reversafields.

Upon finding a match, Odoo automatically reverses this journal entry through its native reversal process. The journal entry is labeled as already reversed to avoid any duplication.

Here is the method used in automating the reversal process:

def _run_reversal_entries(self):
   je_to_reverse = (
       self.env["account.move"]
       .sudo()
       .search(
           [
               ("auto_reverse", "=", True),
               ("already_reversed", "=", False),
               ("move_type", "=", "entry"),
               ("state", "=", "posted"),
               ("reverse_date", "=", fields.Date.today()),
           ]
       )
   )
   for je in je_to_reverse:
       # default values for creating entry
       default_vals_list = [
           {
               "auto_post": "no",
               "date": fields.Date.today(),
               "invoice_date": je.invoice_date,
               "invoice_date_due": je.invoice_date_due,
               "invoice_payment_term_id": je.invoice_payment_term_id.id,
               "ref": _("Reversal of: %s", je.name),
               "invoice_user_id": je.invoice_user_id.id,
               "journal_id": je.journal_id.id,
           }
       ]
       reversed_entry = je._reverse_moves(
           default_values_list=default_vals_list, cancel=True
       )
       je.already_reversed = True
       self.send_journal_entry_reverse_email(je, reversed_entry)

Automatic Email Notification for Reversal Entry

The process of automation becomes more helpful if users know exactly what has happened.

After the creation of a reversal entry, the system automatically triggers an email notification to the user who initially made the journal entry. This email will include the reference to both the original journal entry and the reversed journal entry.

It ensures that the process of reversal is done successfully without any manual verification by the user in Odoo.

The email notification process is handled by:

def send_journal_entry_reverse_email(self, journal_entry=None, reversed_entry=None):
   je_reverse_template = self.env.ref(
       "je_auto_reversal.auto_reversal_je_email_template"
   )
   if je_reverse_template:
       creator_user = journal_entry.create_uid
       if creator_user and creator_user.email:
           je_reverse_template.with_context(
               **{
                   "journal_entry": journal_entry.name,
                   "reversed_entry": reversed_entry.name,
               }
           ).send_mail(creator_user.id, force_send=True)

Email template:

<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="0">
       <record id="auto_reversal_je_email_template" model="mail.template">
           <field name="name">Journal Entry Reversed Template</field>
           <field name="email_from">{{(user.email and '%s &lt;%s&gt;' % (user.name, user.email) or '')}}</field>
           <field name="email_to">{{object.email}}</field>
           <field name="subject">Journal Entry Reversed</field>
           <field name="model_id" ref="base.model_res_users"/>
           <field name="auto_delete" eval="False"/>
           <field name="body_html" type="html">
               <div>
                   <p>Dear
                       <t t-out="object.name"/>,
                   </p>
                   <p>
                       The Journal Entry
                       <t t-out="ctx.get('journal_entry')"/>
                       has been reversed. Reversed Entry Reference is
                       <t t-out="ctx.get('reversed_entry')"/>.
                   </p>
                   <br/>
                   <p>
                       Thanks and Regards
                   </p>
               </div>
           </field>
       </record>
</odoo>

Business advantages

It offers some significant business advantages to the accounting team.

Manually monitoring the process of reversals is no longer required. The chances of forgetting to reverse something become smaller. Duplicates are avoided due to the inherent mechanisms of the system. Accountants get an automatic notification when a reversal takes place, and auditors get a better auditing trail.

Most importantly, the user interface stays very simple. Accountants have to check one box and set the date while entering a journal entry.

The Journal Entry Auto Reversal feature makes accrual management much easier by auto-reversing the journal entries on the scheduled date. It has built-in features for notifications and ensures that there are no duplicates in the process to improve efficiency.

To read more about The Ultimate Guide to Journal Items and Entries in Odoo 19 Accounting, refer to our blog The Ultimate Guide to Journal Items and Entries in Odoo 19 Accounting.


Frequently Asked Questions

What is Journal Entry Auto Reversal in Odoo 19?

It is an auto-reversing journal entry feature on a predetermined date in the future.

How can automatic reversal be achieved?

This can be done by enabling the Auto Reverse checkbox and specifying the Reverse Date.

Will users get notified of the reversal of the journal entry?

Yes. An automatic email will be sent to the user who made the journal entry.

If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

Send Us A Message