Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ

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",

        ],

    },





Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 12 24
2283
2
thg 11 24
979
1
thg 8 23
5069
1
thg 8 23
3741
0
thg 6 25
601