İçereği Atla
Menü
This question has been flagged
1 Cevapla
1570 Görünümler

i did this but doesnt work : 

odoo.define("custom_pos.CustomProductPopup", function (require) {

"use strict";


const PosComponent = require("point_of_sale.PosComponent");

const Registries = require("point_of_sale.Registries");

const { useListener } = require("@web/core/utils/hooks");

const core = require("web.core");

var _t = core._t;


class CustomProductPopup extends PosComponent {

setup() {

super.setup();

useListener("click", this.productClickHandler);

}


async productClickHandler() {

const product = this.props.product;

if (product.prescription_needed) {

this.showPopup("CustomPrescriptionPopup", {

title: _t("Prescription Needed"),

body: _t("This product requires a prescription."),

});

}

}

}


Registries.Component.add(CustomProductPopup);


return CustomProductPopup;

});

Avatar
Vazgeç
Best Answer

Hi,

In the code you provided, noticed that there is a custom popup added If you do not  need to create a new popup, update your code with the ErrorPopup in Odoo

odoo.define("custom_pos.CustomProductPopup", function (require) {
"use strict";

const PosComponent = require("point_of_sale.PosComponent");
const Registries = require("point_of_sale.Registries");
const { useListener } = require("@web/core/utils/hooks");
const core = require("web.core");
const _t = core._t;

class CustomProductPopup extends PosComponent {
setup() {
super.setup();
useListener("click", this.productClickHandler);
}

async productClickHandler() {
const product = this.props.product;
if (product.prescription_needed) {
this.showPopup("ErrorPopup", {
title: _t("Prescription Needed"),
body: _t("This product requires a prescription."),
});
}
}
}

Registries.Component.add(CustomProductPopup);

return CustomProductPopup;
});


Hope it helps

Avatar
Vazgeç
Üretici

i did it but doesnt work still :( at moment to click the product doesnt show up the popup this is my code

should i do something more?

js file:

odoo.define("custom_pos.CustomProductPopup", function (require) {
"use strict";

const PosComponent = require("point_of_sale.PosComponent");
const Registries = require("point_of_sale.Registries");
const { useListener } = require("@web/core/utils/hooks");
const core = require("web.core");
const _t = core._t;

class CustomProductPopup extends PosComponent {
setup() {
super.setup();
useListener("click", this.productClickHandler);
}

async productClickHandler() {
const product = this.props.product;
if (product.prescription_needed) {
this.showPopup("ErrorPopup", {
title: _t("Prescription Needed"),
body: _t("This product requires a prescription."),
});
}
}
}

Registries.Component.add(CustomProductPopup);

return CustomProductPopup;
});

manifest.py

'assets':{
'point_of_sale.assets':[
"wb_pos/static/src/js/wb_sample_button.js",
]
}

Üretici

# -*- coding: utf-8 -*-

from odoo import api, fields, models, _

class ProductTemplate(models.Model):
_inherit = "product.template"

prescription_needed = fields.Boolean(string="Se necesita receta")

Related Posts Cevaplar Görünümler Aktivite
1
Şub 25
1451
1
Mar 24
1470
2
Haz 24
2210
1
Şub 24
1252
1
Şub 24
1555