1

enter image description here

when i create a new meeting in calendar module, it shows like "New" i want rename that label, for example, to "New meeting" is it possible? and where can i find this place in code?

Wald Sin
  • 158
  • 11

2 Answers2

2

The New value is defined in the basic model of the form view. To change it you can override the getName function like the following:

import BasicModel from 'web.BasicModel';
import core from 'web.core';

var _t = core._t;

BasicModel.include({
    getName: function (id) {
        var record = this.localData[id];
        var returnValue = this._super(id);
        if ( returnValue === _t("New") && record.model == 'calendar.event') {
            return _t('New meeting');
        } else {
            return returnValue;
        }
    }
});

You need to add the file under the assets entry in the __manifest__.py file.

'assets': {
    'web.assets_backend': [
        '{module_name}/static/src/js/basic_model.js',
    ],
}

Edit:

For more details on how to add the js file to the manifest, check the assets documentation.

Kenly
  • 24,317
  • 7
  • 44
  • 60
  • i try to add a new .js file in module, register it in manifest and do actions in your guide, but odoo crashes. I find way maybe not right but working. I go in base file in odoo\addons\web\static\src\legacy\js\views\basic\basic_model.js, and change some code: `/** return returnValue || _t("New"); */ if (returnValue == '' && record.model == 'calendar.event') { return 'New meeting'; } else { return returnValue || _t("New"); }` and it works. Thanks. – Wald Sin Jul 17 '22 at 14:32
  • Set the file path relative to the module name. Use the above path if you created the js (`basic_model.js`) file inside the `static/src/js folder` – Kenly Jul 18 '22 at 08:33
0

Hi wald i found some solution:

Inside addons/web/static/src/webclient/actions/action_service.js in you need see this code "New" this is target attribute but i think you do not override and change it like "New Meeting"

enter image description here