Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3072 มุมมอง

How to use custom js functions in odoo Js.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi, to add a function to a new or existing POS odoo component you can use this code:               odoo.define('module_name.main_component_name', function(require) {
    'use strict';

    const PosComponent = require('point_of_sale.PosComponent');
    const Registries = require('point_of_sale.Registries');

   //for defining a new component

    class ComponentName extends PosComponent {
        function_name() {
            //function definition
        }
    }

    Registries.Component.add(ComponentName);

    return ComponentName;

    // or for existing components

    const ExistingComponent = require('point_of_sale.ExistingComponent');

    const ComponentName = ExistingComponent => class extends ExistingComponent {
        function_name() {
            //function definition
        }
    };

    Registries.Component.extend(ExistingComponent, ComponentName);

    return ExistingComponent;
});

Hope it helps

อวตาร
ละทิ้ง