Odoo11 TypeError: this.pos is undefined with a screen widget triggered by a button action
Clash Royale CLAN TAG#URR8PPP
Odoo11 TypeError: this.pos is undefined with a screen widget triggered by a button action
Create a screen "custom-screen" extended from screen widget with a template show a paragraph of lorem and return object of screen widget so it can be called from other widgets.
This screen I want to trigger this screen widget from a button. The screen showed but I got this error "this.pos is undefined" when the button clicked
TypeError: this.pos is undefined
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
__mainfest__.py
'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',
],
views/templates
<?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
;
);
static/src/xml/custom-screen.xml
<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>
1 Answer
1
Can you provide whole traceback of error stack here. Also this error is raised because you try to access current value of 'pos' object but it is not defined so this error is getting raised.
Try to debug this code via console's inspect element at the time of opening screen.
– Keval Mehta
Aug 14 at 10:35
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I edit the question to include the whole traceback of the error stack
– M. Rizk
Aug 13 at 7:10