Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4323 Lượt xem

Hello, I am getting the above error when I click on IsCustomButton button in POS Payment screen. 


Here is the full list of the error:
TypeError: utils.getComponent(...).IsCustomButton is not a function
at extra.handlers.click__1043__ (eval at _compile (http://localhost:8011/web/assets/1158- 26a83f0/ web.assets_common.min.js:1014:178), :350:174)
at invokeHandler (http://localhost:8011/web/assets/1158-26a83f0/ web.assets_common.min.js:838:144 )
at handleEvent (http://localhost:8011/web/assets/1158-26a83f0/ web.assets_common.min.js:842:92)
at HTMLDivElement.handler (http://localhost:8011/web/assets/1158 -26a83f0/ web.assets_common.min.js:844:58)

Here is the JS code:

odoo.define( 'pos_custom_buttons.PaymentScreenButton' , function (require) {
'use strict' ;
const { Gui } = require( 'point_of_sale.Gui' );
const PosComponent = require( 'point_of_sale.PosComponent' );
const { posbus } = require( 'point_of_sale.utils' );
const ProductScreen = require( 'point_of_sale.ProductScreen' );
const { useListener } = require( 'web.custom_hooks' );
const Registries = require( 'point_of_sale.Registries' );
const PaymentScreen = require( 'point_of_sale.PaymentScreen');
const CustomButtonPaymentScreen = (PaymentScreen) =>
class extends PaymentScreen {
constructor() {
super(...arguments);
}
IsCustomButton() {
let partnerId = this .rpc({
model: 'model.model' ,
method: 'do_payment' ,
args: [event.detail.processedChanges],
});

var phone = prompt( "Enter the Customer phone number" );
var send_phone = "1" + String(parseInt(phone))
alert( "Request sent to: " + send_phone)

console.log(phone)
// Gui.showPopup("ErrorPopup", {
// title: this.env._t('Send request'),
// body: this. env._t('Send request'),
// });
}
};
Registries.Component.extend(PaymentScreen, CustomButtonPaymentScreen);
return CustomButtonPaymentScreen;
});

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

Hi Cybrosys Techno Solutions Pvt.Ltd.

Thanks a lot for replying however, after updating my code with the code you provided above, I am getting this error now.
Kindly, what could be the issue?

Error:
OwlError: Invalid handler (expected a function, received: 'undefined')

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

Hi, 

The issue is that the IsCustomButton() function is not being added to the PaymentScreen component properly. Instead of extending the PaymentScreen class with the CustomButtonPaymentScreen class, you need to create a new component that inherits from the PaymentScreen component and add the IsCustomButton() function to it.

odoo.define('pos_custom_buttons.PaymentScreenButton', function(require) {'use strict';
const {Gui} = require('point_of_sale.Gui');
const {posbus} = require('point_of_sale.utils');
const {useListener} = require('web.custom_hooks');
const Registries = require('point_of_sale.Registries');
const PaymentScreen = require('point_of_sale.PaymentScreen');
const CustomButtonPaymentScreen = PaymentScreen => class extends PaymentScreen {
constructor() {
super(...arguments);
}
IsCustomButton() {

let partnerId = this.rpc({
model: 'model.model',
method: 'do_payment',
args: [event.detail.processedChanges],
});

var phone = prompt("Enter the Customer phone number");
var send_phone = "1" + String(parseInt(phone))
alert("Request sent to: " + send_phone)
console.log(phone)
}
}
Registries.Component.add(CustomButtonPaymentScreen);
return CustomButtonPaymentScreen;
});

Regards

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi Cybrosys Techno Solutions Pvt.Ltd.

Thanks a lot for replying however, after updating my code with the code you provided above, I am getting this error now.
Kindly, what could be the issue?

Error:
OwlError: Invalid handler (expected a function, received: 'undefined')at Object.mainEventHandler (http://localhost:8011/web/assets/debug/web.assets_common.js:21602:23) (/web/static/lib/owl/owl.js:5432)
at HTMLDivElement.listener (http://localhost:8011/web/assets/debug/web.assets_common.js:16501:20) (/web/static/lib/owl/owl.js:331)

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 24
1319
0
thg 1 24
1053
1
thg 9 23
2299
2
thg 1 23
6837
get the model in js Đã xử lý
3
thg 3 25
2818