Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2232 Представления
odoo.define( 'odoo_pos_hide_button.ProductScreenn' , function (require) { 
'use strict' ;

const PosComponent = require( 'point_of_sale.PosComponent' );
const ProductScreen = require( 'point_of_sale.ProductScreen' );
const ProductInfoButton = require( ' point_of_sale.ProductInfoButton' );
const { useListener } = require( "@web/core/utils/hooks" );
const Registries = require( 'point_of_sale.Registries' );
const { ConnectionLostError,ConnectionAbortedError } = require( '@web/core/network/rpc_service' )
const { identifyError } = require( 'point_of_sale.utils' );

class HiddenProductInfoButton extends ProductInfoButton {
constructor() {
super(...arguments);
useListener( 'click' , this.onClick );
}

async onClick() {
const orderline = this .env.pos.get_order().get_selected_orderline();
if (orderline) {
const product = orderline. get_product();
const quantity = orderline. get_quantity();
try {
const info = await this.env.pos.getProductInfo(product, quantity);
this.showPopup ( 'ProductInfoPopup' , { info: info, product: product });
} catch (e) {
if (identifyError(e) instanceof ConnectionLostError || ConnectionAbortedError) {
this .showPopup( 'OfflineErrorPopup' , {
title: this .env._t( 'Network Error' ),
body: this .env._t( 'Cannot access product information screen if offline.' ),
});
} else{
this .showPopup( 'ErrorPopup' , {
title: this .env._t( 'Unknown error' ),
body: this .env._t( 'An unknown error prevents us from loading product information.' ),
});
}
}
}
}
}

HiddenProductInfoButton.template = 'ProductInfoButton' ;

ProductScreen. addControlButton({
component: HiddenProductInfoButton,
condition: function () {
return false ; // Add your desired condition here
},
position: [ 'before' , 'SetFiscalPositionButton' ],
});

return ProductScreen;
});

Ive tried to hide the info button from pos this way but still not working.
This is the second way and this still not working but for others buttons it works just fine only for Info button doesnt work.
Anyone who faced this can help me tho ?

ProductScreen.addControlButton({ 
component: ProductInfoButton,
condition: function () {
return this .env.pos.config.pos_button_info;
console.log( this .env.pos.config.pos_button_info);
},
position: [ 'before' , 'SetFiscalPositionButton' ],
});



Аватар
Отменить
Лучший ответ

Hi,


You can Try this Code










<templates id="template" xml:space="preserve">
<t t-name="ProductInfoButton2" t-inherit="point_of_sale.ProductInfoButton" t-inherit-mode="extension" owl="1">
<div class="control-button" position="replace">
<diV/>
</div>
</t>
</templates>


<templates id="template" xml:space="preserve">
<t t-name="ProductItem1" t-inherit="point_of_sale.ProductItem" t-inherit-mode="extension" owl="1">
<i role="img" aria-label="Info" title="Info" class="product-info-button fa fa-info-circle" t-on-click.stop="onProductInfoClick()" position="replace"> </i>
</t>
</templates>




Hope it helps




Аватар
Отменить
Автор

Hello brother i forgot to specify that i need it in odoo 16 , this part remove the info button but the pos isnt working the same after i remove this.

Related Posts Ответы Просмотры Активность
1
февр. 25
2410
1
мар. 24
2447
2
июн. 24
3503
1
февр. 24
2061
1
февр. 24
2563