[REF] fix precommit

This commit is contained in:
Robin Keunen
2023-06-21 15:26:14 +02:00
committed by Darío Lodeiros
parent 587aac7f96
commit 66a985eb36
74 changed files with 3677 additions and 1838 deletions

View File

@@ -1,37 +1,44 @@
odoo.define('pos_pms_link.PaymentScreen', function (require) {
'use strict';
odoo.define("pos_pms_link.PaymentScreen", function (require) {
"use strict";
const PaymentScreen = require('point_of_sale.PaymentScreen');
const Registries = require('point_of_sale.Registries');
const session = require('web.session');
const PaymentScreen = require("point_of_sale.PaymentScreen");
const Registries = require("point_of_sale.Registries");
const session = require("web.session");
const PosPMSLinkPaymentScreen = (PaymentScreen) =>
class extends PaymentScreen {
async selectReservation() {
const { confirmed, payload: newReservation } = await this.showTempScreen(
'ReservationListScreen',
{ reservation: null }
const {confirmed, payload: newReservation} = await this.showTempScreen(
"ReservationListScreen",
{
reservation: null,
}
);
if (confirmed) {
var self = this;
const { confirmed } = await this.showPopup('ConfirmPopup', {
title: this.env._t('Pay order with reservation ?'),
const {confirmed} = await this.showPopup("ConfirmPopup", {
title: this.env._t("Pay order with reservation ?"),
body: this.env._t(
'This operation will add all the products in the order to the reservation. RESERVATION: ' + newReservation['name'] + ' PARTNER : ' + newReservation['partner_name'] + ' ROOM: ' + newReservation['rooms']
"This operation will add all the products in the order to the reservation. RESERVATION: " +
newReservation.name +
" PARTNER : " +
newReservation.partner_name +
" ROOM: " +
newReservation.rooms
),
});
if (confirmed) {
var payment_method = {
'id': self.env.pos.config.pay_on_reservation_method_id[0],
'name': self.env.pos.config.pay_on_reservation_method_id[1],
'is_cash_count': false,
'pos_mercury_config_id': false,
'use_payment_terminal': false,
}
self.trigger('new-payment-line', payment_method);
id: self.env.pos.config.pay_on_reservation_method_id[0],
name: self.env.pos.config.pay_on_reservation_method_id[1],
is_cash_count: false,
pos_mercury_config_id: false,
use_payment_terminal: false,
};
self.trigger("new-payment-line", payment_method);
this.currentOrder.set_paid_on_reservation(true);
this.currentOrder.set_pms_reservation_id(newReservation['id']);
this.currentOrder.set_pms_reservation_id(newReservation.id);
self.validateOrder(false);
}
}

View File

@@ -1,9 +1,9 @@
odoo.define('pos_pms_link.OrderReceipt', function (require) {
'use strict';
odoo.define("pos_pms_link.OrderReceipt", function (require) {
"use strict";
const OrderReceipt = require('point_of_sale.OrderReceipt');
const Registries = require('point_of_sale.Registries');
const session = require('web.session');
const OrderReceipt = require("point_of_sale.OrderReceipt");
const Registries = require("point_of_sale.Registries");
const session = require("web.session");
const PosPMSLinkOrderReceipt = (OrderReceipt) =>
class extends OrderReceipt {
@@ -11,7 +11,11 @@ odoo.define('pos_pms_link.OrderReceipt', function (require) {
return this.receiptEnv.receipt.paid_on_reservation;
}
get reservation_name() {
return this.env.pos.db.get_reservation_by_id(this.receiptEnv.receipt.pms_reservation_id).partner_name || "";
return (
this.env.pos.db.get_reservation_by_id(
this.receiptEnv.receipt.pms_reservation_id
).partner_name || ""
);
}
};

View File

@@ -1,10 +1,10 @@
odoo.define('pos_pms_link.ReservationDetailsEdit', function(require) {
'use strict';
odoo.define("pos_pms_link.ReservationDetailsEdit", function (require) {
"use strict";
const { _t } = require('web.core');
const { getDataURLFromFile } = require('web.utils');
const PosComponent = require('point_of_sale.PosComponent');
const Registries = require('point_of_sale.Registries');
const {_t} = require("web.core");
const {getDataURLFromFile} = require("web.utils");
const PosComponent = require("point_of_sale.PosComponent");
const Registries = require("point_of_sale.Registries");
class ReservationDetailsEdit extends PosComponent {
constructor() {
@@ -12,10 +12,10 @@ odoo.define('pos_pms_link.ReservationDetailsEdit', function(require) {
const reservation = this.props.reservation;
}
mounted() {
this.env.bus.on('save-reservation', this, this.saveChanges);
this.env.bus.on("save-reservation", this, this.saveChanges);
}
willUnmount() {
this.env.bus.off('save-reservation', this);
this.env.bus.off("save-reservation", this);
}
/**
* Save to field `changes` all input changes from the form fields.
@@ -24,25 +24,27 @@ odoo.define('pos_pms_link.ReservationDetailsEdit', function(require) {
this.changes[event.target.name] = event.target.value;
}
saveChanges() {
let processedChanges = {};
for (let [key, value] of Object.entries(this.changes)) {
const processedChanges = {};
for (const [key, value] of Object.entries(this.changes)) {
if (this.intFields.includes(key)) {
processedChanges[key] = parseInt(value) || false;
} else {
processedChanges[key] = value;
}
}
if ((!this.props.reservation.name && !processedChanges.name) ||
processedChanges.name === '' ){
return this.showPopup('ErrorPopup', {
title: _t('A Customer Name Is Required'),
if (
(!this.props.reservation.name && !processedChanges.name) ||
processedChanges.name === ""
) {
return this.showPopup("ErrorPopup", {
title: _t("A Customer Name Is Required"),
});
}
processedChanges.id = this.props.reservation.id || false;
this.trigger('save-changes', { processedChanges });
this.trigger("save-changes", {processedChanges});
}
}
ReservationDetailsEdit.template = 'ReservationDetailsEdit';
ReservationDetailsEdit.template = "ReservationDetailsEdit";
Registries.Component.add(ReservationDetailsEdit);

View File

@@ -1,15 +1,17 @@
odoo.define('pos_pms_link.ReservationLine', function(require) {
'use strict';
odoo.define("pos_pms_link.ReservationLine", function (require) {
"use strict";
const PosComponent = require('point_of_sale.PosComponent');
const Registries = require('point_of_sale.Registries');
const PosComponent = require("point_of_sale.PosComponent");
const Registries = require("point_of_sale.Registries");
class ReservationLine extends PosComponent {
get highlight() {
return this.props.reservation !== this.props.selectedReservation ? '' : 'highlight';
return this.props.reservation !== this.props.selectedReservation
? ""
: "highlight";
}
}
ReservationLine.template = 'ReservationLine';
ReservationLine.template = "ReservationLine";
Registries.Component.add(ReservationLine);

View File

@@ -1,12 +1,12 @@
odoo.define('pos_pms_link.ReservationListScreen', function(require) {
'use strict';
odoo.define("pos_pms_link.ReservationListScreen", function (require) {
"use strict";
const { debounce } = owl.utils;
const PosComponent = require('point_of_sale.PosComponent');
const Registries = require('point_of_sale.Registries');
const { useListener } = require('web.custom_hooks');
const { isRpcError } = require('point_of_sale.utils');
const { useAsyncLockedMethod } = require('point_of_sale.custom_hooks');
const {debounce} = owl.utils;
const PosComponent = require("point_of_sale.PosComponent");
const Registries = require("point_of_sale.Registries");
const {useListener} = require("web.custom_hooks");
const {isRpcError} = require("point_of_sale.utils");
const {useAsyncLockedMethod} = require("point_of_sale.custom_hooks");
/**
* Render this screen using `showTempScreen` to select client.
@@ -27,9 +27,9 @@ odoo.define('pos_pms_link.ReservationListScreen', function(require) {
constructor() {
super(...arguments);
this.lockedSaveChanges = useAsyncLockedMethod(this.saveChanges);
useListener('click-save', () => this.env.bus.trigger('save-customer'));
useListener('click-edit', () => this.editReservation());
useListener('save-changes', this.lockedSaveChanges);
useListener("click-save", () => this.env.bus.trigger("save-customer"));
useListener("click-edit", () => this.editReservation());
useListener("save-changes", this.lockedSaveChanges);
// We are not using useState here because the object
// passed to useState converts the object and its contents
@@ -42,7 +42,7 @@ odoo.define('pos_pms_link.ReservationListScreen', function(require) {
detailIsShown: false,
isEditMode: false,
editModeProps: {
reservation: {}
reservation: {},
},
};
this.updateReservationList = debounce(this.updateReservationList, 70);
@@ -50,17 +50,20 @@ odoo.define('pos_pms_link.ReservationListScreen', function(require) {
// Lifecycle hooks
back() {
if(this.state.detailIsShown) {
if (this.state.detailIsShown) {
this.state.detailIsShown = false;
this.render();
} else {
this.props.resolve({ confirmed: false, payload: false });
this.trigger('close-temp-screen');
this.props.resolve({confirmed: false, payload: false});
this.trigger("close-temp-screen");
}
}
confirm() {
this.props.resolve({ confirmed: true, payload: this.state.selectedReservation });
this.trigger('close-temp-screen');
this.props.resolve({
confirmed: true,
payload: this.state.selectedReservation,
});
this.trigger("close-temp-screen");
}
// Getters
@@ -69,14 +72,13 @@ odoo.define('pos_pms_link.ReservationListScreen', function(require) {
}
get reservations() {
if (this.state.query && this.state.query.trim() !== '') {
if (this.state.query && this.state.query.trim() !== "") {
return this.env.pos.db.search_reservation(this.state.query.trim());
} else {
return this.env.pos.db.get_reservations_sorted(1000);
}
return this.env.pos.db.get_reservations_sorted(1000);
}
get isNextButtonVisible() {
return this.state.selectedReservation ? true : false;
return Boolean(this.state.selectedReservation);
}
/**
* Returns the text and command of the next button.
@@ -84,12 +86,14 @@ odoo.define('pos_pms_link.ReservationListScreen', function(require) {
*/
get nextButton() {
if (!this.props.reservation) {
return { command: 'set', text: this.env._t('Set Reservation') };
} else if (this.props.reservation && this.props.reservation === this.state.selectedReservation) {
return { command: 'deselect', text: this.env._t('Deselect Reservation') };
} else {
return { command: 'set', text: this.env._t('Change Reservation') };
return {command: "set", text: this.env._t("Set Reservation")};
} else if (
this.props.reservation &&
this.props.reservation === this.state.selectedReservation
) {
return {command: "deselect", text: this.env._t("Deselect Reservation")};
}
return {command: "set", text: this.env._t("Change Reservation")};
}
// Methods
@@ -99,7 +103,7 @@ odoo.define('pos_pms_link.ReservationListScreen', function(require) {
updateReservationList(event) {
this.state.query = event.target.value;
const reservations = this.reservations;
if (event.code === 'Enter' && reservations.length === 1) {
if (event.code === "Enter" && reservations.length === 1) {
this.state.selectedReservation = reservations[0];
this.clickNext();
} else {
@@ -107,7 +111,7 @@ odoo.define('pos_pms_link.ReservationListScreen', function(require) {
}
}
clickReservation(event) {
let reservation = event.detail.reservation;
const reservation = event.detail.reservation;
if (this.state.selectedReservation === reservation) {
this.state.selectedCReservation = null;
} else {
@@ -123,11 +127,14 @@ odoo.define('pos_pms_link.ReservationListScreen', function(require) {
this.render();
}
clickNext() {
this.state.selectedReservation = this.nextButton.command === 'set' ? this.state.selectedReservation : null;
this.state.selectedReservation =
this.nextButton.command === "set"
? this.state.selectedReservation
: null;
this.confirm();
}
activateEditMode(event) {
const { isNewReservation } = event.detail;
const {isNewReservation} = event.detail;
this.state.isEditMode = true;
this.state.detailIsShown = true;
this.state.isNewReservation = isNewReservation;
@@ -149,7 +156,7 @@ odoo.define('pos_pms_link.ReservationListScreen', function(require) {
this.deactivateEditMode();
}
}
ReservationListScreen.template = 'ReservationListScreen';
ReservationListScreen.template = "ReservationListScreen";
Registries.Component.add(ReservationListScreen);