Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
4142 Prikazi
I  wanted to show the CreateOrderPopup in Odoo15 BUT it's not showing and there is no error message. I created 2 logs : ffffffff and QQQQQ the fffffffff is shown in the logs but the QQQQQ which is after calling " await this.showPopup('CreateOrderPopup'); " it's not being shown.
I have this in the JS file :
odoo.define("point_of_sale.CreateOrderButton", function (require) {
    "use strict";

    const PosComponent = require("point_of_sale.PosComponent");
    const ProductScreen = require("point_of_sale.ProductScreen");
    const Registries = require("point_of_sale.Registries");
   
    class CreateOrderButton extends PosComponent {
        async onClick() {
            console.log("ffffffffffffffffffff");
           await this.showPopup('CreateOrderPopup');
            console.log('QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ');
        };
        
    }
    CreateOrderButton.template = "CreateOrderButton";
    
    ProductScreen.addControlButton({
        
        component: CreateOrderButton,
        condition: function () {
            return (
                this.env.pos.config.iface_create_sale_order &&
                this.env.pos.get_order().get_client() &&
                this.env.pos.get_order().get_orderlines().length !== 0
                
            );
        },
    });

    Registries.Component.add(CreateOrderButton);
});

But the CreateOrderPopup is not showing when I click on the button. Also the QQQQ logs don't get shown

For the CreateOrderPopUp i have :

odoo.define("point_of_sale.CreateOrderPopup", function (require) { "use strict"; const AbstractAwaitablePopup = require("point_of_sale.AbstractAwaitablePopup"); const Registries = require("point_of_sale.Registries"); const framework = require("web.framework"); class CreateOrderPopup extends AbstractAwaitablePopup { setup() { super.setup(); this.createOrderClicked = false; } async createDraftSaleOrder() { await this._createSaleOrder("draft"); } async createConfirmedSaleOrder() { await this._createSaleOrder("confirmed"); } async createDeliveredSaleOrder() { await this._createSaleOrder("delivered"); } async createInvoicedSaleOrder() { await this._createSaleOrder("invoiced"); } async _createSaleOrder(order_state) { var current_order = this.env.pos.get_order(); framework.blockUI(); await this.rpc({ model: "sale.order", method: "create_order_from_pos", args: [current_order.export_as_JSON(), order_state], }) .catch(function (error) { throw error; }) .finally(function () { framework.unblockUI(); }); // Delete current order this.env.pos.removeOrder(current_order); this.env.pos.add_new_order(); // Close popup return await super.confirm(); } } CreateOrderPopup.template = "CreateOrderPopup"; Registries.Component.add(CreateOrderPopup); return CreateOrderPopup; });

both templates are created and they are all called like this in the manifest file :
"assets": { "point_of_sale.assets": [ "pos_order_to_sale_order/static/src/css/pos.css", "pos_order_to_sale_order/static/src/js/CreateOrderPopup.js", "pos_order_to_sale_order/static/src/js/CreateOrderButton.js", ], 'web.assets_qweb': [ "pos_order_to_sale_order/static/src/xml/CreateOrderPopup.xml", "pos_order_to_sale_order/static/src/xml/CreateOrderButton.xml", ],


Why does the PopUp stops the QQQQ log from showing in the logs and itself in the POS

Avatar
Opusti
Avtor Best Answer

Thank you for your reply. But still nothing is working and No errors!!

Also, 

this.env.pos.config.iface_create_sale_order &&
this.env.pos.get_order().get_client() &&
this.env.pos.get_order().get_orderlines().length !== 0

is not being read correctly, because the button is not being shown correctlyl!!

Avatar
Opusti
Best Answer

Hi,

Try the following code

odoo.define('point_of_sale.CreateOrderPopup', function(require){
'use strict';

const AbstractAwaitablePopup = require('point_of_sale.AbstractAwaitablePopup');
const Registries = require('point_of_sale.Registries');
const { _lt } = require('@web/core/l10n/translation');
const framework = require("web.framework");

class CreateOrderPopup extends AbstractAwaitablePopup {
setup() {
super.setup();
this.createOrderClicked = false;
}

async createDraftSaleOrder() {
await this._createSaleOrder("draft");
}

async createConfirmedSaleOrder() {
await this._createSaleOrder("confirmed");
}

async createDeliveredSaleOrder() {
await this._createSaleOrder("delivered");
}

async createInvoicedSaleOrder() {
await this._createSaleOrder("invoiced");
}

async _createSaleOrder(order_state) {
var current_order = this.env.pos.get_order();

framework.blockUI();

await this.rpc({
model: "sale.order",
method: "create_order_from_pos",
args: [current_order.export_as_JSON(), order_state],
})
.catch(function (error) {
throw error;
})
.finally(function () {
framework.unblockUI();
});

// Delete current order
this.env.pos.removeOrder(current_order);
this.env.pos.add_new_order();
 
// Close popup
return await super.confirm();
}

 
}
//Create Order popup
CreateOrderPopup.template = 'CreateOrderPopup';
CreateOrderPopup.defaultProps = {
confirmText: _lt('Ok'),
title: _lt('Confirm ?'),
body: '',
};

Registries.Component.add(CreateOrderPopup);

return CreateOrderPopup;
});
odoo.define("point_of_sale.CreateOrderButton", function (require) {
"use strict";

const PosComponent = require("point_of_sale.PosComponent");
const ProductScreen = require("point_of_sale.ProductScreen");
const Registries = require("point_of_sale.Registries");
const { useListener } = require('web.custom_hooks');
 
class CreateOrderButton extends PosComponent {
async onClick() {
await this.showPopup('CreateOrderPopup',{
title : this.env._t("enter title"),
body : this.env._t("Enter your body message")
});
};
 
}
CreateOrderButton.template = "CreateOrderButton";
 
ProductScreen.addControlButton({
 
component: CreateOrderButton,
condition: function () {
return (
this.env.pos.config.iface_create_sale_order &&
this.env.pos.get_order().get_client() &&
this.env.pos.get_order().get_orderlines().length !== 0
 
);
},
});

Registries.Component.add(CreateOrderButton);
 
return CreateOrderButton;
});

Regards

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
2
maj 22
14434
2
apr. 22
4551
1
apr. 22
3608
1
jul. 25
3971
10
dec. 24
31894