Home > Net >  Template MyTemplate does not exist Odoo 15
Template MyTemplate does not exist Odoo 15

Time:03-21

Can someone help? I wan to add a custom button in POS Odoo 15 CE. I followed this article: https://www.cybrosys.com/blog/how-to-add-buttons-in-pos-using-owl, but It's seem that something has changed from verssion 14 to 15.

This is my js file in my_project/static/src/js directory:

odoo.define('numenapp_buyer_name.alias_button', function(require) {
    'use strict';

    const PosComponent = require('point_of_sale.PosComponent');
    const ProductScreen = require('point_of_sale.ProductScreen');
    const { useListener } = require('web.custom_hooks');
    const Registries = require('point_of_sale.Registries');

    class AliasButton extends PosComponent {
        constructor() {
            super(...arguments);
            useListener('click', this.onClick);
        }
        is_available() {
            const order = this.env.pos.get_order();
            return order;
        }
        onClick() {
            const cli = this.get_client();
            alert(cli.name);
        }
    }
    AliasButton.template = 'AliasButton';

    ProductScreen.addControlButton({
        component: AliasButton,
        condition: function() {
            return this.env.pos;
        },
        position: ['before', 'OrderlineCustomerNoteButton'],
    });

    Registries.Component.add(AliasButton);

    return AliasButton;
});

This is my xml file in my_project/static/src/xml directory:

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-name="AliasButton" owl="1">
        <div class='control-button'>
            Alias
        </div>
    </t>
</templates>

And this is my manifest.py file (a piece):

'data': [
     # 'security/ir.model.access.csv',
    'views/views.xml',
    'views/templates.xml',
],

'demo': [
     'demo/demo.xml',
],

'qweb': [
    'static/src/xml/AliasButton.xml',
],

'assets': {
    'point_of_sale.assets': [
        'numenapp_buyer_name/static/src/js/**/*',
    ],
},

CodePudding user response:

The is no qweb entry anymore.

From bundles documentation:

The bundles are defined in each module’s __manifest__.py, with a dedicated assets key that contains a dictionary

web.assets_qweb: all static XML templates used in the backend environment and in the point of sale.

Link all qweb .xml in web.assets_qweb bundle like flowing:

'assets': {

    'web.assets_qweb': [
        'my_project/static/src/xml/AliasButton.xml',
    ],

},
  • Related