I want to trigger a JS event from another JS function from a different file. I want to apply a discount from customer card when user will set a customer in POS. I already made a JS function which is working perfectly but its need to set customer first then needs to click another button but I want to apply this when customer will set. Is there any way to trigger event from another class function?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
1
ตอบกลับ
3938
มุมมอง
Hi,
Try like following.
// Import this in both files
const { posbus } = require("point_of_sale.utils");
// use this inside the function where you need to trigger the action
posbus.trigger('a-unique-custom-name');
// Import this in the file where you want to receive the action
const { useBus } = require("@web/core/utils/hooks");
// Add this to the setup function of your component
useBus(posbus, 'a-unique-custom-name', this.functionName);
// define your function
Regards
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
2
ก.ย. 23
|
8777 | ||
|
1
ธ.ค. 22
|
3452 | ||
|
3
มี.ค. 25
|
7149 | ||
|
0
ม.ค. 24
|
1317 | ||
|
1
ต.ค. 23
|
3636 |