How to trigger my odoo model function when I click on specific notebook tab in form view in odoo16

  Kiến thức lập trình

I want to trigger the function when user clicks the my custom notebook tab. I tried to use FormRedner but seem not working and I can’t see any log is displayed in the browser console. This is how I tried.

My JS file.

odoo.define('project_task_feasibility_check.feasibilitychecktab', function(require) {
    "use strict";

    var FormRenderer = require('web.FormRenderer');

    var CustomFormRenderer = FormRenderer.extend({
        events: _.extend({}, FormRenderer.prototype.events, {
            'click .feasibility_check': '_onfeasibilityTabClick',
        }),
        _onfeasibilityTabClick: function(ev) {
            console.log("Tab clicked!");
            this._rpc({
                model: 'project.task',
                method: 'action_get_feasibility_result',
                args: [/* args */],
            }).then(function(result) {
                console.log('RPC Call Result:', result);
            });
        },
    });

    return CustomFormRenderer;
});

My view.xml

<xpath expr="//page[@name='description_page']" position="after">
    <page
        name="feasibility_check"
        string="Feasibility Check"
        js_class="feasibility_check"
    >
        <field name="feasibility_check" />
    </page>
</xpath>

My function is not trigged at all. How can I achieve my requirement?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT