Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
174 Переглядів

Hello, I have been trying to resolve this issue, but I have no idea what's wrong.

I have this template:

<?xml version="1.0" encoding="UTF-8"?>

<templates id="template" xml:space="preserve">

    <t t-name="devtest_owl.SetFiscalType">

        <button class="button btn btn-light btn-lg w-100 w-md-50 lh-lg text-truncate" t-on-click="onClick">

            <i class="fa fa-user-check me-2"/>

            <span>Set fiscal Type</span>

        </button>

    </t>

</templates>

And this JS:

import { Component } from "@odoo/owl";


export class SetFiscalType extends Component {

    static template = "devtest_owl.SetFiscalType";

    setup() {

        super.setup(...arguments);

    }


    async onClick() {

        console.log("Hello");

    }

}

And I want to include in this template:

<?xml version="1.0" encoding="UTF-8"?>

<templates id="template" xml:space="preserve">

    <t t-name="devtest_owl.PaymentScreenButtons" t-inherit="point_of_sale.PaymentScreenButtons" t-inherit-mode="extension">

        <xpath expr="//button[hasclass('partner-button')]" position="after">

<!-- Here -->

            <SetFiscalType order="currentOrder"/>

        </xpath>

    </t>

</templates>

Using this JS:

import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen";

import { patch } from "@web/core/utils/patch";

import { SetFiscalType } from "./set_fiscal_type";


patch(PaymentScreen.prototype, {

    components: {

        ...PaymentScreen.prototype.components,

        SetFiscalType,

    },

});

This is my manifest:

    "assets": {

        "point_of_sale._assets_pos": [

            "devtest_owl/static/src/js/set_fiscal_type.js",

            "devtest_owl/static/src/js/register_components.js",

            "devtest_owl/static/src/js/payment_screen_patch.js",

            "devtest_owl/static/src/xml/set_fiscal_type.xml",

            "devtest_owl/static/src/xml/pos_payment_screen.xml",

        ],

    },





Аватар
Відмінити
Найкраща відповідь

Hi,

OWL needs the template to already be registered before the component is instantiated. So update your manifest like this


    "point_of_sale._assets_pos": [

        "devtest_owl/static/src/xml/set_fiscal_type.xml",

        "devtest_owl/static/src/xml/pos_payment_screen.xml",

        "devtest_owl/static/src/js/set_fiscal_type.js",

        "devtest_owl/static/src/js/register_components.js",

        "devtest_owl/static/src/js/payment_screen_patch.js"

    ]


For additional information you


    OWL components don’t normally need to super the  setup unless you’re extending another component. You can remove it:

    setup() {

        // your state, hooks, etc.

    }


Hope it helps.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
груд. 24
2159
2
лист. 24
912
1
серп. 23
4982
1
серп. 23
3673
0
черв. 25
536