Skip to content

Commit

Permalink
[MIG] Make availability tags to show correct remaining seats
Browse files Browse the repository at this point in the history
  • Loading branch information
BT-dmoreno committed Jul 5, 2023
1 parent b614c95 commit e799ece
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand All @@ -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];
Expand Down Expand Up @@ -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";

Expand Down

0 comments on commit e799ece

Please sign in to comment.