diff --git a/pos_event_sale/static/src/js/Popups/EventSelectorPopup/EventItem.js b/pos_event_sale/static/src/js/Popups/EventSelectorPopup/EventItem.js index 52e0cc8971..9e8d5b119c 100644 --- a/pos_event_sale/static/src/js/Popups/EventSelectorPopup/EventItem.js +++ b/pos_event_sale/static/src/js/Popups/EventSelectorPopup/EventItem.js @@ -9,6 +9,7 @@ odoo.define("pos_event_sale.EventItem", function (require) { const {useState} = owl; const PosComponent = require("point_of_sale.PosComponent"); const Registries = require("point_of_sale.Registries"); + const {onWillRender} = owl; class EventItem extends PosComponent { /** @@ -20,6 +21,10 @@ odoo.define("pos_event_sale.EventItem", function (require) { this.state = useState({ seatsAvailable: this.props.event.getSeatsAvailableReal(), }); + onWillRender(this.willRender); + } + willRender() { + this.state.seatsAvailable = this.props.event.getSeatsAvailableReal(); } get disabled() { return this.state.seatsAvailable <= 0; diff --git a/pos_event_sale/static/src/js/Popups/EventTicketsPopup/EventTicketItem.js b/pos_event_sale/static/src/js/Popups/EventTicketsPopup/EventTicketItem.js index 019be1c1f6..24cb8bef36 100644 --- a/pos_event_sale/static/src/js/Popups/EventTicketsPopup/EventTicketItem.js +++ b/pos_event_sale/static/src/js/Popups/EventTicketsPopup/EventTicketItem.js @@ -9,7 +9,7 @@ odoo.define("pos_event_sale.EventTicketItem", function (require) { const {useState} = owl; const PosComponent = require("point_of_sale.PosComponent"); const Registries = require("point_of_sale.Registries"); - const {onMounted, reactive} = owl; + const {onWillRender} = owl; class EventTicketItem extends PosComponent { /** @@ -22,13 +22,10 @@ odoo.define("pos_event_sale.EventTicketItem", function (require) { orderedQty: this.props.eventTicket.getOrderedQuantity(), seatsAvailable: this.props.eventTicket.getSeatsAvailableReal(), }); - onMounted(this.mounted); + onWillRender(this.willRendered); } - mounted() { - const order = this.env.pos.get_order(); - if (order) { - reactive(order.orderlines, this._orderlinesUpdated); - } + willRendered() { + this._updateQuantities(); } get imageUrl() { const product_id = this.props.eventTicket.product_id[0]; @@ -68,12 +65,6 @@ odoo.define("pos_event_sale.EventTicketItem", function (require) { this.state.seatsAvailable = this.props.eventTicket.getSeatsAvailableReal(); this.state.orderedQty = this.props.eventTicket.getOrderedQuantity(); } - _orderlinesUpdated(orderline) { - const event = this.props.eventTicket.getEvent(); - if (event === orderline.getEvent()) { - this._updateQuantities(); - } - } } EventTicketItem.template = "EventTicketItem";