跳至内容
菜单
此问题已终结
1 回复
1601 查看

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;

});

形象
丢弃
最佳答案

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

形象
丢弃
编写者

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",
]
}

编写者

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

from odoo import api, fields, models, _

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

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

相关帖文 回复 查看 活动
1
2月 25
1506
1
3月 24
1522
2
6月 24
2303
1
2月 24
1286
1
2月 24
1625