I want to add new order button in pos product screen with function.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hi,
Try to add the Odoo version along with your question.
Using the below code you can add button in odoo 16.
Added JS files and XML files to the src folder. The manifest.py
'assets': {
'point_of_sale.assets': [
'module_name/static/src/js/filename.js',
'module_name/static/src/xml/filename.xml',
],
},
In .xml
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="CustomDemoButtons" owl="1">
<div class="control-button" style="color:red">
<i class="fa fa-eraser"> </i>
<span> </span>
<span>Click me</span>
</div>
</t>
</templates>
After adding the button, we have to add the JS file. And in the JS file we have to define the module using odoo.define and define the required screens.
odoo.define('pos_button.Custom', function(require) {
'use strict';
const { Gui } = require('point_of_sale.Gui');
const PosComponent = require('point_of_sale.PosComponent');
const { identifyError } = require('point_of_sale.utils');
const ProductScreen = require('point_of_sale.ProductScreen');
const { useListener } = require("@web/core/utils/hooks");
const Registries = require('point_of_sale.Registries');
const PaymentScreen = require('point_of_sale.PaymentScreen');
class CustomDemoButtons extends PosComponent {
setup() {
super.setup();
useListener('click', this.onClick);
}
async onClick() {
const { confirmed} = await
this.showPopup("ConfirmPopup", {
title: this.env._t('Title of the Popup?'),
body: this.env._t('Body of the popup'),
});
}
}
CustomDemoButtons.template = 'CustomDemoButtons';
ProductScreen.addControlButton({
component: CustomDemoButtons,
condition: function() {
return this.env.pos;
},
});
Registries.Component.add(CustomDemoButtons);
return CustomDemoButtons;
});
In this way you can add a button anywhere in the pos screen like systray, payment screen etc
Regards
Thanks For Your Answer. But I want to create one order save to draft to other order continue .How to do it? Plz Help Me.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up