Edi Santoso
Odoo and Python Developer
drink a tea to enjoying the life

Odoo check if current form is new record or not

 How to check if current form is creating new record or edit record


odoo.define('my_custom_app.CustomFormController', function (require) {

    'use strict';

    const FormController = require('web.FormController');

      FormController.include({

        saveRecord: function () {

            // Access the record

            var record = this.model.get(this.handle);

            // Check if it's a new record

            if (!record.data.id) {

                console.log('This is a new record.');

            } else {

                console.log('This is an existing record with ID:', record.data.id);

            }

  });

  });