Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Odoo11 TypeError:this.pos未定义由按钮操作触发的屏幕小部件_Odoo_Point Of Sale_Qweb - Fatal编程技术网

Odoo11 TypeError:this.pos未定义由按钮操作触发的屏幕小部件

Odoo11 TypeError:this.pos未定义由按钮操作触发的屏幕小部件,odoo,point-of-sale,qweb,Odoo,Point Of Sale,Qweb,创建一个从screen小部件扩展而来的screen“custom screen”,并使用一个模板显示一段lorem和screen小部件的返回对象,以便可以从其他小部件调用它 这个屏幕我想从一个按钮触发这个屏幕小部件。屏幕显示了,但我在点击按钮时出现了错误“this.pos未定义” TypeError:this.pos未定义 TypeError: this.pos is undefined http://localhost:8069/web/content/1394-95d31f5/point_o

创建一个从screen小部件扩展而来的screen“custom screen”,并使用一个模板显示一段lorem和screen小部件的返回对象,以便可以从其他小部件调用它

这个屏幕我想从一个按钮触发这个屏幕小部件。屏幕显示了,但我在点击按钮时出现了错误“this.pos未定义”

TypeError:this.pos未定义

TypeError: this.pos is undefined
http://localhost:8069/web/content/1394-95d31f5/point_of_sale.assets.js:337
Traceback:
show@http://localhost:8069/web/content/1394-95d31f5/point_of_sale.assets.js:337:1
show_screen@http://localhost:8069/web/content/1394-95d31f5/point_of_sale.assets.js:316:28
button_click@http://localhost:8069/web/content/1394-95d31f5/point_of_sale.assets.js:572:385
renderElement/<@http://localhost:8069/web/content/1394-95d31f5/point_of_sale.assets.js:362:203
dispatch@http://localhost:8069/web/content/941-9a091d9/web.assets_common.js:892:378
$event.dispatch@http://localhost:8069/web/content/1394-95d31f5/point_of_sale.assets.js:480:8
add/elemData.handle@http://localhost:8069/web/content/941-9a091d9/web.assets_common.js:865:151
视图/模板


>custom.js
odoo.define('custom-screen.custom screen')函数(需要){
“严格使用”;
var屏幕=要求(“销售点屏幕”);
var gui=require('point_of_sale.gui');
var Button=screens.ActionButtonWidget.extend({
模板:“按钮”,
按钮单击:函数(){
var self=这个;
log(“单击按钮”);
self.gui.show_screen('custom-screen');
},
});
screens.define_action_按钮({
“名称”:“按钮”,
“小部件”:按钮,
});
var CustomScreenWidget=screens.ScreenWidget.extend({
模板:“CustomScreenWidget”,
init:函数(){
log(“初始化自定义屏幕”);
}
});
gui.define_屏幕({
“名称”:“自定义屏幕”,
“小部件”:自定义屏幕小部件,
});
返回{
按钮:按钮,
CustomScreenWidget:CustomScreenWidget
};
});
static/src/xml/custom-screen.xml


打开自定义屏幕
Lorem ipsum dolor sit amet,奉献精英。Accusamus别名、液态铜、多洛里布、埃尼姆错误、福吉亚-尼西-奥迪特-奎布斯达姆(odit-quibusdam-quo-repellat)驱虫剂和生命体。尼莫,尼莫


您能在这里提供错误堆栈的完整回溯吗。此外,出现此错误的原因是您试图访问“pos”对象的当前值,但该值未定义,因此出现此错误。

我编辑此问题,以包括错误堆栈的整个回溯。请尝试在打开屏幕时通过控制台的inspect元素调试此代码。
{
    'name': "custom-screen",

    'summary': """
        Short (1 phrase/line) summary of the module's purpose, used as
        subtitle on modules listing or apps.openerp.com""",

    'description': """
        Long description of module's purpose
    """,

    'author': "My Company",
    'website': "http://www.yourcompany.com",


    'category': 'Uncategorized',
    'version': '0.1',

    # any module necessary for this one to work correctly
    'depends': ['base'],

    # always loaded
    'data': [
        'views/templates.xml',
    ],

    'demo': [
        'demo/demo.xml',
    ],
    'qweb': [
        'static/src/xml/custom-screen.xml',

    ],
}
<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <template id="assets" inherit_id="point_of_sale.assets">
        <xpath expr="." position="inside">
            <script type="text/javascript" src="/custom-screen/static/src/js/custom.js"></script>

        </xpath>
    </template>

</odoo>

> custom.js

    odoo.define('custom-screen.custom-screen', function (require) {
        "use strict";


        var screens = require('point_of_sale.screens');
        var gui = require('point_of_sale.gui');

        var Button = screens.ActionButtonWidget.extend({
            template: 'Button',

            button_click: function () {
                var self = this;
                console.log('Button Clicked');
                self.gui.show_screen('custom-screen');

            },

        });

        screens.define_action_button({
            'name': 'button',
            'widget': Button,
        });

        var CustomScreenWidget = screens.ScreenWidget.extend({
            template: 'CustomScreenWidget',

            init: function () {
                console.log("Initialize the custom screen");
            }
        });

        gui.define_screen({
            'name': 'custom-screen',
            'widget': CustomScreenWidget,
        });

        return {
            Button: Button,
            CustomScreenWidget: CustomScreenWidget
        };

    });
<t t-name="Button">
    <span class="control-button">
        <!--<i class="fa fa-print"></i>-->
        Open Custom Screen
    </span>
</t>

<t t-name="CustomScreenWidget">
    <div>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus alias, aliquid cupiditate dignissimos, doloribus, enim error eum fugiat id nisi odit quibusdam quo repellat repellendus sed vitae voluptatem. Distinctio, nemo.</p>
    </div>
</t>