콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3062 화면

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

아바타
취소