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);
}
});
});
Tambahkan Komentar