If you wish, you can share with the rest of the guests the access to their check-in so that they can fill it out.
diff --git a/pms/wizards/pms_booking_engine.py b/pms/wizards/pms_booking_engine.py
index b8998376b..bb7a26e9f 100644
--- a/pms/wizards/pms_booking_engine.py
+++ b/pms/wizards/pms_booking_engine.py
@@ -278,7 +278,9 @@ class BookingEngine(models.TransientModel):
record.discount * 100
)
action = self.sudo().env.ref("pms.open_pms_folio1_form_tree_all").read()[0]
- action["views"] = [(self.sudo().env.ref("pms.pms_folio_view_form").id, "form")]
+ action["views"] = [
+ (self.sudo().env.ref("pms.pms_folio_view_form").id, "form")
+ ]
action["res_id"] = folio.id
return action
diff --git a/pos_pms_link/models/__init__.py b/pos_pms_link/models/__init__.py
index 1146e6879..f2cc697db 100755
--- a/pos_pms_link/models/__init__.py
+++ b/pos_pms_link/models/__init__.py
@@ -25,4 +25,4 @@ from . import pos_payment
from . import pms_reservation
from . import pms_service
from . import product_pricelist
-from . import pos_session
\ No newline at end of file
+from . import pos_session
diff --git a/pos_pms_link/models/pms_reservation.py b/pos_pms_link/models/pms_reservation.py
index e801456e6..ac55d0bf6 100644
--- a/pos_pms_link/models/pms_reservation.py
+++ b/pos_pms_link/models/pms_reservation.py
@@ -17,15 +17,22 @@
# along with this program. If not, see
.
#
##############################################################################
-from odoo import models, api
+from odoo import api, models
class PMSReservation(models.Model):
- _inherit = 'pms.reservation'
+ _inherit = "pms.reservation"
@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
if self.env.context.get("pos_user_force", False):
- return super().sudo().with_context(pos_user_force=False).search_read(domain, fields, offset, limit, order)
+ return (
+ super()
+ .sudo()
+ .with_context(pos_user_force=False)
+ .search_read(domain, fields, offset, limit, order)
+ )
else:
- return super(PMSReservation, self).search_read(domain, fields, offset, limit, order)
+ return super(PMSReservation, self).search_read(
+ domain, fields, offset, limit, order
+ )
diff --git a/pos_pms_link/models/pms_service.py b/pos_pms_link/models/pms_service.py
index 395240e24..1b31b3e07 100644
--- a/pos_pms_link/models/pms_service.py
+++ b/pos_pms_link/models/pms_service.py
@@ -17,14 +17,22 @@
# along with this program. If not, see
.
#
##############################################################################
-from odoo import models, api
+from odoo import api, models
+
class PMSService(models.Model):
- _inherit = 'pms.service'
+ _inherit = "pms.service"
@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
if self.env.context.get("pos_user_force", False):
- return super().sudo().with_context(pos_user_force=False).search_read(domain, fields, offset, limit, order)
+ return (
+ super()
+ .sudo()
+ .with_context(pos_user_force=False)
+ .search_read(domain, fields, offset, limit, order)
+ )
else:
- return super(PMSService, self).search_read(domain, fields, offset, limit, order)
+ return super(PMSService, self).search_read(
+ domain, fields, offset, limit, order
+ )
diff --git a/pos_pms_link/models/pms_service_line.py b/pos_pms_link/models/pms_service_line.py
index b520d32c6..a686f3e90 100644
--- a/pos_pms_link/models/pms_service_line.py
+++ b/pos_pms_link/models/pms_service_line.py
@@ -17,14 +17,11 @@
# along with this program. If not, see
.
#
##############################################################################
-from odoo import fields, models, api, _
-from odoo.osv.expression import AND
-import pytz
-from datetime import timedelta
-from odoo.addons.point_of_sale.wizard.pos_box import PosBox
+from odoo import api, fields, models
+
class PMSServiceLine(models.Model):
- _inherit = 'pms.service.line'
+ _inherit = "pms.service.line"
pos_order_line_ids = fields.One2many(
string="POS lines",
@@ -35,6 +32,13 @@ class PMSServiceLine(models.Model):
@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
if self.env.context.get("pos_user_force", False):
- return super().sudo().with_context(pos_user_force=False).search_read(domain, fields, offset, limit, order)
+ return (
+ super()
+ .sudo()
+ .with_context(pos_user_force=False)
+ .search_read(domain, fields, offset, limit, order)
+ )
else:
- return super(PMSServiceLine, self).search_read(domain, fields, offset, limit, order)
+ return super(PMSServiceLine, self).search_read(
+ domain, fields, offset, limit, order
+ )
diff --git a/pos_pms_link/models/pos_config.py b/pos_pms_link/models/pos_config.py
index 91eb62832..c6188244e 100644
--- a/pos_pms_link/models/pos_config.py
+++ b/pos_pms_link/models/pos_config.py
@@ -18,24 +18,34 @@
#
##############################################################################
-import json
-from odoo import api, fields, models, _
-from odoo.exceptions import Warning, UserError
-
import logging
+
+from odoo import api, fields, models
+
_logger = logging.getLogger(__name__)
class PosConfig(models.Model):
- _inherit = 'pos.config'
+ _inherit = "pos.config"
- pay_on_reservation = fields.Boolean('Pay on reservation', default=False)
- pay_on_reservation_method_id = fields.Many2one('pos.payment.method', string='Pay on reservation method')
- reservation_allowed_propertie_ids = fields.Many2many('pms.property', string='Reservation allowed properties')
+ pay_on_reservation = fields.Boolean("Pay on reservation", default=False)
+ pay_on_reservation_method_id = fields.Many2one(
+ "pos.payment.method", string="Pay on reservation method"
+ )
+ reservation_allowed_propertie_ids = fields.Many2many(
+ "pms.property", string="Reservation allowed properties"
+ )
@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
if self.env.context.get("pos_user_force", False):
- return super().sudo().with_context(pos_user_force=False).search_read(domain, fields, offset, limit, order)
+ return (
+ super()
+ .sudo()
+ .with_context(pos_user_force=False)
+ .search_read(domain, fields, offset, limit, order)
+ )
else:
- return super(PosConfig, self).search_read(domain, fields, offset, limit, order)
+ return super(PosConfig, self).search_read(
+ domain, fields, offset, limit, order
+ )
diff --git a/pos_pms_link/models/pos_order.py b/pos_pms_link/models/pos_order.py
index 67df4da38..541c9024e 100644
--- a/pos_pms_link/models/pos_order.py
+++ b/pos_pms_link/models/pos_order.py
@@ -17,52 +17,61 @@
# along with this program. If not, see
.
#
##############################################################################
-from odoo import fields, models, api, _
-from odoo.osv.expression import AND
-import pytz
-from datetime import datetime, timedelta
-from odoo.addons.point_of_sale.wizard.pos_box import PosBox
+from datetime import datetime
+
+from odoo import _, api, fields, models
from odoo.exceptions import UserError
-class PosOrder(models.Model):
- _inherit = 'pos.order'
- paid_on_reservation = fields.Boolean('Paid on reservation', default=False)
- pms_reservation_id = fields.Many2one('pms.reservation', string='PMS reservation')
+class PosOrder(models.Model):
+ _inherit = "pos.order"
+
+ paid_on_reservation = fields.Boolean("Paid on reservation", default=False)
+ pms_reservation_id = fields.Many2one("pms.reservation", string="PMS reservation")
def _get_fields_for_draft_order(self):
res = super(PosOrder, self)._get_fields_for_draft_order()
- res.append('paid_on_reservation')
- res.append('pms_reservation_id')
+ res.append("paid_on_reservation")
+ res.append("pms_reservation_id")
return res
@api.model
def _order_fields(self, ui_order):
order_fields = super(PosOrder, self)._order_fields(ui_order)
- order_fields['paid_on_reservation'] = ui_order.get('paid_on_reservation', False)
- order_fields['pms_reservation_id'] = ui_order.get('pms_reservation_id', False)
+ order_fields["paid_on_reservation"] = ui_order.get("paid_on_reservation", False)
+ order_fields["pms_reservation_id"] = ui_order.get("pms_reservation_id", False)
return order_fields
def _get_fields_for_order_line(self):
res = super(PosOrder, self)._get_fields_for_order_line()
- res.append('pms_service_line_id')
+ res.append("pms_service_line_id")
return res
-
+
def _get_order_lines(self, orders):
super(PosOrder, self)._get_order_lines(orders)
for order in orders:
- if 'lines' in order:
- for line in order['lines']:
- line[2]['pms_service_line_id'] = line[2]['pms_service_line_id'][0] if line[2]['pms_service_line_id'] else False
-
+ if "lines" in order:
+ for line in order["lines"]:
+ line[2]["pms_service_line_id"] = (
+ line[2]["pms_service_line_id"][0]
+ if line[2]["pms_service_line_id"]
+ else False
+ )
+
@api.model
def _process_order(self, pos_order, draft, existing_order):
- data = pos_order.get('data', False)
- if data and data.get("paid_on_reservation", False) and data.get("pms_reservation_id", False):
- pms_reservation_id = data.pop('pms_reservation_id')
+ data = pos_order.get("data", False)
+ if (
+ data
+ and data.get("paid_on_reservation", False)
+ and data.get("pms_reservation_id", False)
+ ):
+ pms_reservation_id = data.pop("pms_reservation_id")
res = super(PosOrder, self)._process_order(pos_order, draft, existing_order)
- order_id = self.env['pos.order'].browse(res)
- pms_reservation_id = self.sudo().env['pms.reservation'].browse(pms_reservation_id)
+ order_id = self.env["pos.order"].browse(res)
+ pms_reservation_id = (
+ self.sudo().env["pms.reservation"].browse(pms_reservation_id)
+ )
if not pms_reservation_id:
raise UserError(_("Reservation does not exists."))
order_id.pms_reservation_id = pms_reservation_id.id
@@ -72,12 +81,15 @@ class PosOrder(models.Model):
return super()._process_order(pos_order, draft, existing_order)
def add_order_lines_to_reservation(self, pms_reservation_id):
- self.lines.filtered(lambda x: not x.pms_service_line_id)._generate_pms_service(pms_reservation_id)
+ self.lines.filtered(lambda x: not x.pms_service_line_id)._generate_pms_service(
+ pms_reservation_id
+ )
+
class PosOrderLine(models.Model):
- _inherit = 'pos.order.line'
+ _inherit = "pos.order.line"
- pms_service_line_id = fields.Many2one('pms.service.line', string='PMS Service line')
+ pms_service_line_id = fields.Many2one("pms.service.line", string="PMS Service line")
def _generate_pms_service(self, pms_reservation_id):
for line in self:
@@ -100,6 +112,4 @@ class PosOrderLine(models.Model):
}
service = self.sudo().env["pms.service"].create(vals)
- line.write({
- 'pms_service_line_id': service.service_line_ids.id
- })
+ line.write({"pms_service_line_id": service.service_line_ids.id})
diff --git a/pos_pms_link/models/pos_payment.py b/pos_pms_link/models/pos_payment.py
index 22ddf2cdc..2f9e84aca 100644
--- a/pos_pms_link/models/pos_payment.py
+++ b/pos_pms_link/models/pos_payment.py
@@ -17,16 +17,20 @@
# along with this program. If not, see
.
#
##############################################################################
-from odoo import api, fields, models, _
+from odoo import api, models
class PosPayment(models.Model):
_inherit = "pos.payment"
- @api.constrains('payment_method_id')
+ @api.constrains("payment_method_id")
def _check_payment_method_id(self):
for payment in self:
- if payment.session_id.config_id.pay_on_reservation and payment.session_id.config_id.pay_on_reservation_method_id == payment.payment_method_id:
+ if (
+ payment.session_id.config_id.pay_on_reservation
+ and payment.session_id.config_id.pay_on_reservation_method_id
+ == payment.payment_method_id
+ ):
continue
else:
super(PosPayment, payment)._check_payment_method_id()
diff --git a/pos_pms_link/models/pos_session.py b/pos_pms_link/models/pos_session.py
index 20402e2cb..c25e06922 100644
--- a/pos_pms_link/models/pos_session.py
+++ b/pos_pms_link/models/pos_session.py
@@ -18,51 +18,70 @@
#
##############################################################################
-from collections import defaultdict
-import json
-from odoo import api, fields, models, _
-from odoo.exceptions import Warning, UserError
-
import logging
+from collections import defaultdict
+
+from odoo import models
+
_logger = logging.getLogger(__name__)
class PosSession(models.Model):
- _inherit = 'pos.session'
+ _inherit = "pos.session"
def _accumulate_amounts(self, data):
res = super(PosSession, self)._accumulate_amounts(data)
- if self.config_id.pay_on_reservation and self.config_id.pay_on_reservation_method_id:
- amounts = lambda: {'amount': 0.0, 'amount_converted': 0.0}
- tax_amounts = lambda: {'amount': 0.0, 'amount_converted': 0.0, 'base_amount': 0.0, 'base_amount_converted': 0.0}
+ if (
+ self.config_id.pay_on_reservation
+ and self.config_id.pay_on_reservation_method_id
+ ):
+ amounts = lambda: {"amount": 0.0, "amount_converted": 0.0}
+ tax_amounts = lambda: {
+ "amount": 0.0,
+ "amount_converted": 0.0,
+ "base_amount": 0.0,
+ "base_amount_converted": 0.0,
+ }
sales = defaultdict(amounts)
taxes = defaultdict(tax_amounts)
- rounded_globally = self.company_id.tax_calculation_rounding_method == 'round_globally'
+ rounded_globally = (
+ self.company_id.tax_calculation_rounding_method == "round_globally"
+ )
reservation_orders = self.order_ids.filtered(lambda x: x.pms_reservation_id)
-
+
order_taxes = defaultdict(tax_amounts)
for order_line in reservation_orders.lines:
line = self._prepare_line(order_line)
# Combine sales/refund lines
sale_key = (
# account
- line['income_account_id'],
+ line["income_account_id"],
# sign
- -1 if line['amount'] < 0 else 1,
+ -1 if line["amount"] < 0 else 1,
# for taxes
- tuple((tax['id'], tax['account_id'], tax['tax_repartition_line_id']) for tax in line['taxes']),
- line['base_tags'],
+ tuple(
+ (tax["id"], tax["account_id"], tax["tax_repartition_line_id"])
+ for tax in line["taxes"]
+ ),
+ line["base_tags"],
+ )
+ sales[sale_key] = self._update_amounts(
+ sales[sale_key], {"amount": line["amount"]}, line["date_order"]
)
- sales[sale_key] = self._update_amounts(sales[sale_key], {'amount': line['amount']}, line['date_order'])
# Combine tax lines
- for tax in line['taxes']:
- tax_key = (tax['account_id'] or line['income_account_id'], tax['tax_repartition_line_id'], tax['id'], tuple(tax['tag_ids']))
+ for tax in line["taxes"]:
+ tax_key = (
+ tax["account_id"] or line["income_account_id"],
+ tax["tax_repartition_line_id"],
+ tax["id"],
+ tuple(tax["tag_ids"]),
+ )
order_taxes[tax_key] = self._update_amounts(
order_taxes[tax_key],
- {'amount': tax['amount'], 'base_amount': tax['base']},
- tax['date_order'],
- round=not rounded_globally
+ {"amount": tax["amount"], "base_amount": tax["base"]},
+ tax["date_order"],
+ round=not rounded_globally,
)
for tax_key, amounts in order_taxes.items():
if rounded_globally:
@@ -72,25 +91,37 @@ class PosSession(models.Model):
for element, value in dict(res["taxes"]).items():
if element in taxes:
- value['amount'] = value['amount'] - taxes[element]['amount']
- value['amount_converted'] = value['amount_converted'] - taxes[element]['amount_converted']
- value['base_amount'] = value['base_amount'] - taxes[element]['base_amount']
- value['base_amount_converted'] = value['base_amount_converted'] - taxes[element]['base_amount_converted']
-
+ value["amount"] = value["amount"] - taxes[element]["amount"]
+ value["amount_converted"] = (
+ value["amount_converted"] - taxes[element]["amount_converted"]
+ )
+ value["base_amount"] = (
+ value["base_amount"] - taxes[element]["base_amount"]
+ )
+ value["base_amount_converted"] = (
+ value["base_amount_converted"]
+ - taxes[element]["base_amount_converted"]
+ )
+
for element, value in dict(res["sales"]).items():
if element in sales:
- value['amount'] = value['amount'] - sales[element]['amount']
- value['amount_converted'] = value['amount_converted'] - sales[element]['amount_converted']
-
+ value["amount"] = value["amount"] - sales[element]["amount"]
+ value["amount_converted"] = (
+ value["amount_converted"] - sales[element]["amount_converted"]
+ )
+
if self.config_id.pay_on_reservation_method_id.split_transactions:
for element, value in dict(res["split_receivables"]).items():
- if element.payment_method_id == self.config_id.pay_on_reservation_method_id:
- value['amount'] = 0.0
- value['amount_converted'] = 0.0
-
+ if (
+ element.payment_method_id
+ == self.config_id.pay_on_reservation_method_id
+ ):
+ value["amount"] = 0.0
+ value["amount_converted"] = 0.0
+
else:
for element, value in dict(res["combine_receivables"]).items():
if element == self.config_id.pay_on_reservation_method_id:
- value['amount'] = 0.0
- value['amount_converted'] = 0.0
- return res
\ No newline at end of file
+ value["amount"] = 0.0
+ value["amount_converted"] = 0.0
+ return res
diff --git a/pos_pms_link/models/product_pricelist.py b/pos_pms_link/models/product_pricelist.py
index 4e2b063ac..1fb670f64 100644
--- a/pos_pms_link/models/product_pricelist.py
+++ b/pos_pms_link/models/product_pricelist.py
@@ -17,24 +17,40 @@
# along with this program. If not, see
.
#
##############################################################################
-from odoo import models, api
+from odoo import api, models
+
class ProductPricelist(models.Model):
- _inherit = 'product.pricelist'
+ _inherit = "product.pricelist"
@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
if self.env.context.get("pos_user_force", False):
- return super().sudo().with_context(pos_user_force=False).search_read(domain, fields, offset, limit, order)
+ return (
+ super()
+ .sudo()
+ .with_context(pos_user_force=False)
+ .search_read(domain, fields, offset, limit, order)
+ )
else:
- return super(ProductPricelist, self).search_read(domain, fields, offset, limit, order)
+ return super(ProductPricelist, self).search_read(
+ domain, fields, offset, limit, order
+ )
+
class ProductPricelistItem(models.Model):
- _inherit = 'product.pricelist.item'
+ _inherit = "product.pricelist.item"
@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
if self.env.context.get("pos_user_force", False):
- return super().sudo().with_context(pos_user_force=False).search_read(domain, fields, offset, limit, order)
+ return (
+ super()
+ .sudo()
+ .with_context(pos_user_force=False)
+ .search_read(domain, fields, offset, limit, order)
+ )
else:
- return super(ProductPricelistItem, self).search_read(domain, fields, offset, limit, order)
+ return super(ProductPricelistItem, self).search_read(
+ domain, fields, offset, limit, order
+ )
diff --git a/pos_pms_link/static/src/js/ReservationSelectionButton.js b/pos_pms_link/static/src/js/ReservationSelectionButton.js
index e7e7d01ea..36b150ef5 100644
--- a/pos_pms_link/static/src/js/ReservationSelectionButton.js
+++ b/pos_pms_link/static/src/js/ReservationSelectionButton.js
@@ -1,39 +1,39 @@
-odoo.define('pos_pms_link.ReservationSelectionButton', function(require) {
- 'use strict';
+odoo.define("pos_pms_link.ReservationSelectionButton", function (require) {
+ "use strict";
- const PosComponent = require('point_of_sale.PosComponent');
- const ProductScreen = require('point_of_sale.ProductScreen');
- const { useListener } = require('web.custom_hooks');
- const Registries = require('point_of_sale.Registries');
- const { Gui } = require('point_of_sale.Gui');
- var core = require('web.core');
+ const PosComponent = require("point_of_sale.PosComponent");
+ const ProductScreen = require("point_of_sale.ProductScreen");
+ const {useListener} = require("web.custom_hooks");
+ const Registries = require("point_of_sale.Registries");
+ const {Gui} = require("point_of_sale.Gui");
+ var core = require("web.core");
var QWeb = core.qweb;
- var _t = core._t;
+ var _t = core._t;
class ReservationSelectionButton extends PosComponent {
constructor() {
super(...arguments);
- useListener('click', this.onClick);
+ useListener("click", this.onClick);
}
get currentOrder() {
return this.env.pos.get_order();
}
async onClick() {
- const { confirmed, payload: newReservation } = await this.showTempScreen(
- 'ReservationListScreen',
- { reservation: null }
- );
+ const {
+ confirmed,
+ payload: newReservation,
+ } = await this.showTempScreen("ReservationListScreen", {reservation: null});
if (confirmed) {
this.currentOrder.add_reservation_services(newReservation);
}
}
}
- ReservationSelectionButton.template = 'ReservationSelectionButton';
+ ReservationSelectionButton.template = "ReservationSelectionButton";
ProductScreen.addControlButton({
component: ReservationSelectionButton,
- condition: function() {
+ condition: function () {
return true;
},
});
diff --git a/pos_pms_link/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/pos_pms_link/static/src/js/Screens/PaymentScreen/PaymentScreen.js
index eb708d1c0..efff8ae5c 100644
--- a/pos_pms_link/static/src/js/Screens/PaymentScreen/PaymentScreen.js
+++ b/pos_pms_link/static/src/js/Screens/PaymentScreen/PaymentScreen.js
@@ -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);
}
}
diff --git a/pos_pms_link/static/src/js/Screens/ReceiptScreen/OrderReceipt.js b/pos_pms_link/static/src/js/Screens/ReceiptScreen/OrderReceipt.js
index 9855f8da7..798b4848e 100644
--- a/pos_pms_link/static/src/js/Screens/ReceiptScreen/OrderReceipt.js
+++ b/pos_pms_link/static/src/js/Screens/ReceiptScreen/OrderReceipt.js
@@ -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 || ""
+ );
}
};
diff --git a/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationDetailsEdit.js b/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationDetailsEdit.js
index 969f713df..29228b76f 100644
--- a/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationDetailsEdit.js
+++ b/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationDetailsEdit.js
@@ -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);
diff --git a/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationLine.js b/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationLine.js
index d85fa7baa..fa3e6aa1d 100644
--- a/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationLine.js
+++ b/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationLine.js
@@ -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);
diff --git a/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationListScreen.js b/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationListScreen.js
index 4b76c2df5..3289552b6 100644
--- a/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationListScreen.js
+++ b/pos_pms_link/static/src/js/Screens/ReservationListScreen/ReservationListScreen.js
@@ -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);
diff --git a/pos_pms_link/static/src/js/db.js b/pos_pms_link/static/src/js/db.js
index 063e4ad63..cf1ee350e 100644
--- a/pos_pms_link/static/src/js/db.js
+++ b/pos_pms_link/static/src/js/db.js
@@ -34,72 +34,89 @@ odoo.define("pos_pms_link.db", function (require) {
this.reservation_search_string = "";
this.reservation_id = null;
},
- get_reservation_by_id: function(id){
+ get_reservation_by_id: function (id) {
return this.reservation_by_id[id];
},
- get_reservations_sorted: function(max_count){
- max_count = max_count ? Math.min(this.reservation_sorted.length, max_count) : this.reservation_sorted.length;
+ get_reservations_sorted: function (max_count) {
+ max_count = max_count
+ ? Math.min(this.reservation_sorted.length, max_count)
+ : this.reservation_sorted.length;
var reservations = [];
for (var i = 0; i < max_count; i++) {
reservations.push(this.reservation_by_id[this.reservation_sorted[i]]);
}
return reservations;
},
- search_reservation: function(query){
+ search_reservation: function (query) {
try {
- query = query.replace(/[\[\]\(\)\+\*\?\.\-\!\&\^\$\|\~\_\{\}\:\,\\\/]/g,'.');
- query = query.replace(/ /g,'.+');
- var re = RegExp("([0-9]+):.*?"+utils.unaccent(query),"gi");
- }catch(e){
+ query = query.replace(
+ /[\[\]\(\)\+\*\?\.\-\!\&\^\$\|\~\_\{\}\:\,\\\/]/g,
+ "."
+ );
+ query = query.replace(/ /g, ".+");
+ var re = RegExp("([0-9]+):.*?" + utils.unaccent(query), "gi");
+ } catch (e) {
return [];
}
var results = [];
- for(var i = 0; i < this.limit; i++){
+ for (var i = 0; i < this.limit; i++) {
var r = re.exec(this.reservation_search_string);
- if(r){
+ if (r) {
var id = Number(r[1]);
results.push(this.get_reservation_by_id(id));
- }else{
+ } else {
break;
}
}
return results;
},
- _reservation_search_string: function(reservation){
- var str = reservation.name || '';
- var room_str = reservation.rooms || '';
- var partner_str = reservation.partner_name || '';
- str = '' + reservation.id + ':' + str.replace(':', '').replace(/\n/g, ' ') + ':' + room_str.replace(':', '').replace(/\n/g, ' ') + ':' + partner_str.replace(':', '').replace(/\n/g, ' ') + '\n';
+ _reservation_search_string: function (reservation) {
+ var str = reservation.name || "";
+ var room_str = reservation.rooms || "";
+ var partner_str = reservation.partner_name || "";
+ str =
+ String(reservation.id) +
+ ":" +
+ str.replace(":", "").replace(/\n/g, " ") +
+ ":" +
+ room_str.replace(":", "").replace(/\n/g, " ") +
+ ":" +
+ partner_str.replace(":", "").replace(/\n/g, " ") +
+ "\n";
return str;
},
- add_reservations: function(reservations){
+ add_reservations: function (reservations) {
var updated_count = 0;
var reservation;
- for(var i = 0, len = reservations.length; i < len; i++){
+ for (var i = 0, len = reservations.length; i < len; i++) {
reservation = reservations[i];
if (!this.reservation_by_id[reservation.id]) {
this.reservation_sorted.push(reservation.id);
}
this.reservation_by_id[reservation.id] = reservation;
-
+
updated_count += 1;
}
-
- if (updated_count) {
+
+ if (updated_count) {
this.reservation_search_string = "";
this.reservation_by_barcode = {};
-
+
for (var id in this.reservation_by_id) {
reservation = this.reservation_by_id[id];
-
- if(reservation.barcode){
+
+ if (reservation.barcode) {
this.reservation_by_barcode[reservation.barcode] = reservation;
}
- this.reservation_search_string += this._reservation_search_string(reservation);
+ this.reservation_search_string += this._reservation_search_string(
+ reservation
+ );
}
-
- this.reservation_search_string = utils.unaccent(this.reservation_search_string);
+
+ this.reservation_search_string = utils.unaccent(
+ this.reservation_search_string
+ );
}
return updated_count;
},
diff --git a/pos_pms_link/static/src/js/models.js b/pos_pms_link/static/src/js/models.js
index 0e0648d04..640915f71 100644
--- a/pos_pms_link/static/src/js/models.js
+++ b/pos_pms_link/static/src/js/models.js
@@ -20,130 +20,157 @@
##############################################################################
*/
-odoo.define('pos_pms_link.models', function (require) {
+odoo.define("pos_pms_link.models", function (require) {
"use strict";
- var models = require('point_of_sale.models');
- var utils = require('web.utils');
+ var models = require("point_of_sale.models");
+ var utils = require("web.utils");
var round_di = utils.round_decimals;
- var core = require('web.core');
- const { Gui } = require('point_of_sale.Gui');
+ var core = require("web.core");
+ const {Gui} = require("point_of_sale.Gui");
var QWeb = core.qweb;
- const session = require('web.session');
+ const session = require("web.session");
- var _t = core._t;
+ var _t = core._t;
var _super_order = models.Order.prototype;
models.Order = models.Order.extend({
- initialize: function(attr, options) {
- _super_order.initialize.apply(this,arguments);
+ initialize: function (attr, options) {
+ _super_order.initialize.apply(this, arguments);
this.paid_on_reservation = this.paid_on_reservation || null;
this.pms_reservation_id = this.pms_reservation_id || null;
},
- get_paid_on_reservation: function() {
+ get_paid_on_reservation: function () {
var paid_on_reservation = this.paid_on_reservation;
return paid_on_reservation;
},
- set_paid_on_reservation: function(value) {
+ set_paid_on_reservation: function (value) {
this.paid_on_reservation = value;
- this.trigger('change', this);
+ this.trigger("change", this);
},
- get_pms_reservation_id: function() {
+ get_pms_reservation_id: function () {
var pms_reservation_id = this.pms_reservation_id;
return pms_reservation_id;
},
- set_pms_reservation_id: function(value) {
+ set_pms_reservation_id: function (value) {
this.pms_reservation_id = value;
- this.trigger('change', this);
+ this.trigger("change", this);
},
- export_as_JSON: function() {
- var json = _super_order.export_as_JSON.apply(this,arguments);
+ export_as_JSON: function () {
+ var json = _super_order.export_as_JSON.apply(this, arguments);
json.paid_on_reservation = this.paid_on_reservation;
json.pms_reservation_id = this.pms_reservation_id;
return json;
- },
+ },
- init_from_JSON: function(json) {
- _super_order.init_from_JSON.apply(this,arguments);
+ init_from_JSON: function (json) {
+ _super_order.init_from_JSON.apply(this, arguments);
this.paid_on_reservation = json.paid_on_reservation;
this.pms_reservation_id = json.pms_reservation_id;
},
- apply_ms_data: function(data) {
+ apply_ms_data: function (data) {
if (typeof data.paid_on_reservation !== "undefined") {
this.set_paid_on_reservation(data.paid_on_reservation);
}
if (typeof data.pms_reservation_id !== "undefined") {
this.set_pms_reservation_id(data.pms_reservation_id);
}
- this.trigger('change', this);
+ this.trigger("change", this);
},
- add_reservation_services: function(reservation) {
+ add_reservation_services: function (reservation) {
var self = this;
var d = new Date();
- var month = d.getMonth()+1;
+ var month = d.getMonth() + 1;
var day = d.getDate();
- var current_date = d.getFullYear() + '-' +
- (month<10 ? '0' : '') + month + '-' +
- (day<10 ? '0' : '') + day;
+ var current_date =
+ d.getFullYear() +
+ "-" +
+ (month < 10 ? "0" : "") +
+ month +
+ "-" +
+ (day < 10 ? "0" : "") +
+ day;
- var service_line_ids = reservation.service_ids.map(x => x.service_line_ids) || false;
- var today_service_lines = []
- _.each(service_line_ids, function(service_array){
- today_service_lines.push(service_array.find(x => x.date === current_date));
+ var service_line_ids =
+ reservation.service_ids.map((x) => x.service_line_ids) || false;
+ var today_service_lines = [];
+ _.each(service_line_ids, function (service_array) {
+ today_service_lines.push(
+ service_array.find((x) => x.date === current_date)
+ );
});
-
- _.each(today_service_lines, function(service_line_id){
- if (service_line_id){
- var qty = service_line_id.day_qty
+
+ _.each(today_service_lines, function (service_line_id) {
+ if (service_line_id) {
+ var qty = service_line_id.day_qty;
if (service_line_id.pos_order_line_ids.length > 0) {
- _.each(service_line_id.pos_order_line_ids, function(order_line_id){
+ _.each(service_line_id.pos_order_line_ids, function (
+ order_line_id
+ ) {
qty -= order_line_id.qty;
});
}
if (qty > 0) {
var options = {
- 'quantity': qty,
- 'pms_service_line_id': service_line_id.id,
- 'price': 0.0,
+ quantity: qty,
+ pms_service_line_id: service_line_id.id,
+ price: 0.0,
};
- var service_product = self.pos.db.get_product_by_id(service_line_id.product_id[0]);
+ var service_product = self.pos.db.get_product_by_id(
+ service_line_id.product_id[0]
+ );
self.pos.get_order().add_product(service_product, options);
var last_line = self.pos.get_order().get_last_orderline();
- last_line.set_note("RESERVATION: " + reservation.name + " ROOMS: " + reservation.rooms);
- var r_service_line_id = reservation.service_ids.map(x => x.service_line_ids)[0].find(x=>x.id==service_line_id.id);
+ last_line.set_note(
+ "RESERVATION: " +
+ reservation.name +
+ " ROOMS: " +
+ reservation.rooms
+ );
+ var r_service_line_id = reservation.service_ids
+ .map((x) => x.service_line_ids)[0]
+ .find((x) => x.id == service_line_id.id);
if (r_service_line_id.pos_order_line_ids.length == 0) {
r_service_line_id.pos_order_line_ids.push({
- 'id': 0,
- 'qty': parseInt(qty)
+ id: 0,
+ qty: parseInt(qty),
});
- } else if (r_service_line_id.pos_order_line_ids.length == 1 && r_service_line_id.pos_order_line_ids[0].id == 0){
+ } else if (
+ r_service_line_id.pos_order_line_ids.length == 1 &&
+ r_service_line_id.pos_order_line_ids[0].id == 0
+ ) {
r_service_line_id.pos_order_line_ids[0].qty = parseInt(qty);
- } else if (r_service_line_id.pos_order_line_ids.length == 1 && r_service_line_id.pos_order_line_ids[0].id != 0){
+ } else if (
+ r_service_line_id.pos_order_line_ids.length == 1 &&
+ r_service_line_id.pos_order_line_ids[0].id != 0
+ ) {
r_service_line_id.pos_order_line_ids.push({
- 'id': 0,
- 'qty': parseInt(qty)
+ id: 0,
+ qty: parseInt(qty),
});
- } else if (r_service_line_id.pos_order_line_ids.length > 1){
+ } else if (r_service_line_id.pos_order_line_ids.length > 1) {
var id_in_lines = false;
- _.each(r_service_line_id.pos_order_line_ids, function(pos_line_id){
- if(pos_line_id.id == self.id) {
+ _.each(r_service_line_id.pos_order_line_ids, function (
+ pos_line_id
+ ) {
+ if (pos_line_id.id == self.id) {
pos_line_id.qty = parseInt(qty);
id_in_lines = true;
}
});
if (id_in_lines == false) {
r_service_line_id.pos_order_line_ids.push({
- 'id': self.id,
- 'qty': parseInt(qty)
+ id: self.id,
+ qty: parseInt(qty),
});
}
}
@@ -152,62 +179,62 @@ odoo.define('pos_pms_link.models', function (require) {
});
},
- add_product: function(product, options){
- _super_order.add_product.apply(this,arguments);
+ add_product: function (product, options) {
+ _super_order.add_product.apply(this, arguments);
if (options.pms_service_line_id) {
- this.selected_orderline.set_pms_service_line_id(options.pms_service_line_id);
+ this.selected_orderline.set_pms_service_line_id(
+ options.pms_service_line_id
+ );
}
},
export_for_printing: function () {
- let result = _super_order.export_for_printing.apply(this, arguments);
+ const result = _super_order.export_for_printing.apply(this, arguments);
result.paid_on_reservation = this.paid_on_reservation;
result.pms_reservation_id = this.pms_reservation_id;
return result;
},
-
- })
+ });
var _super_orderline = models.Orderline.prototype;
models.Orderline = models.Orderline.extend({
-
- initialize: function(attr, options) {
- _super_orderline.initialize.call(this,attr,options);
+ initialize: function (attr, options) {
+ _super_orderline.initialize.call(this, attr, options);
this.server_id = this.server_id || null;
this.pms_service_line_id = this.pms_service_line_id || null;
},
- get_pms_service_line_id: function() {
+ get_pms_service_line_id: function () {
var pms_service_line_id = this.pms_service_line_id;
return pms_service_line_id;
},
- set_pms_service_line_id: function(value) {
+ set_pms_service_line_id: function (value) {
this.pms_service_line_id = value;
- this.trigger('change', this);
+ this.trigger("change", this);
},
- export_as_JSON: function() {
- var json = _super_orderline.export_as_JSON.apply(this,arguments);
+ export_as_JSON: function () {
+ var json = _super_orderline.export_as_JSON.apply(this, arguments);
json.pms_service_line_id = this.pms_service_line_id;
return json;
- },
+ },
- init_from_JSON: function(json) {
- _super_orderline.init_from_JSON.apply(this,arguments);
+ init_from_JSON: function (json) {
+ _super_orderline.init_from_JSON.apply(this, arguments);
this.pms_service_line_id = json.pms_service_line_id;
this.server_id = json.server_id;
},
- apply_ms_data: function(data) {
+ apply_ms_data: function (data) {
if (typeof data.pms_service_line_id !== "undefined") {
this.set_pms_service_line_id(data.pms_service_line_id);
}
- this.trigger('change', this);
+ this.trigger("change", this);
},
- set_quantity: function(quantity, keep_price) {
+ set_quantity: function (quantity, keep_price) {
_super_orderline.set_quantity.apply(this, arguments);
var is_real_qty = true;
if (!quantity || quantity == "remove") {
@@ -215,123 +242,167 @@ odoo.define('pos_pms_link.models', function (require) {
}
var self = this;
if (self.pms_service_line_id) {
- this.pos.reservations.map(function(x) {
- _.each(x.service_ids, function(service){
- _.each(service.service_line_ids, function(line){
+ this.pos.reservations.map(function (x) {
+ _.each(x.service_ids, function (service) {
+ _.each(service.service_line_ids, function (line) {
if (line.id == self.pms_service_line_id) {
- if (line.pos_order_line_ids.length == 0 && is_real_qty) {
+ if (
+ line.pos_order_line_ids.length == 0 &&
+ is_real_qty
+ ) {
line.pos_order_line_ids.push({
- 'id': self.server_id || 0,
- 'qty': parseInt(quantity)
+ id: self.server_id || 0,
+ qty: parseInt(quantity),
});
- } else if (line.pos_order_line_ids.length == 1 && line.pos_order_line_ids[0].id == self.server_id){
+ } else if (
+ line.pos_order_line_ids.length == 1 &&
+ line.pos_order_line_ids[0].id == self.server_id
+ ) {
if (is_real_qty) {
- line.pos_order_line_ids[0].qty = parseInt(quantity);
+ line.pos_order_line_ids[0].qty = parseInt(
+ quantity
+ );
} else {
- line.pos_order_line_ids.pop(line.pos_order_line_ids[0]);
+ line.pos_order_line_ids.pop(
+ line.pos_order_line_ids[0]
+ );
}
- } else if (line.pos_order_line_ids.length == 1 && line.pos_order_line_ids[0].id != self.server_id && is_real_qty){
+ } else if (
+ line.pos_order_line_ids.length == 1 &&
+ line.pos_order_line_ids[0].id != self.server_id &&
+ is_real_qty
+ ) {
line.pos_order_line_ids.push({
- 'id': self.server_id || 0,
- 'qty': parseInt(quantity)
+ id: self.server_id || 0,
+ qty: parseInt(quantity),
});
- } else if (line.pos_order_line_ids.length > 1){
+ } else if (line.pos_order_line_ids.length > 1) {
var id_in_lines = false;
- _.each(line.pos_order_line_ids, function(pos_line_id){
- if(pos_line_id.id == self.server_id) {
+ _.each(line.pos_order_line_ids, function (
+ pos_line_id
+ ) {
+ if (pos_line_id.id == self.server_id) {
if (is_real_qty) {
pos_line_id.qty = parseInt(quantity);
} else {
- line.pos_order_line_ids.pop(pos_line_id);
- }
+ line.pos_order_line_ids.pop(
+ pos_line_id
+ );
+ }
id_in_lines = true;
}
});
- _.each(line.pos_order_line_ids, function(pos_line_id){
- if(pos_line_id.id == 0) {
+ _.each(line.pos_order_line_ids, function (
+ pos_line_id
+ ) {
+ if (pos_line_id.id == 0) {
if (is_real_qty) {
pos_line_id.qty = parseInt(quantity);
} else {
- line.pos_order_line_ids.pop(pos_line_id);
+ line.pos_order_line_ids.pop(
+ pos_line_id
+ );
}
id_in_lines = true;
}
});
if (id_in_lines == false && is_real_qty) {
line.pos_order_line_ids.push({
- 'id': self.server_id || 0,
- 'qty': parseInt(quantity)
+ id: self.server_id || 0,
+ qty: parseInt(quantity),
});
}
}
}
});
});
- })
+ });
}
},
-
});
var _super_posmodel = models.PosModel.prototype;
models.PosModel = models.PosModel.extend({
- initialize: function(attr, options) {
- _super_posmodel.initialize.apply(this,arguments);
+ initialize: function (attr, options) {
+ _super_posmodel.initialize.apply(this, arguments);
this.reservations = [];
},
});
-
models.load_models({
- model: 'pms.reservation',
- fields: ['name', 'id', 'state', 'service_ids', 'partner_name', 'adults', 'children', 'checkin', 'checkout', 'folio_internal_comment', 'rooms'],
- context: function(self){
- var ctx_copy = session.user_context
- ctx_copy['pos_user_force'] = true;
+ model: "pms.reservation",
+ fields: [
+ "name",
+ "id",
+ "state",
+ "service_ids",
+ "partner_name",
+ "adults",
+ "children",
+ "checkin",
+ "checkout",
+ "folio_internal_comment",
+ "rooms",
+ ],
+ context: function (self) {
+ var ctx_copy = session.user_context;
+ ctx_copy.pos_user_force = true;
return ctx_copy;
},
- domain: function(self){
+ domain: function (self) {
var d = new Date();
- var month = d.getMonth()+1;
+ var month = d.getMonth() + 1;
var day = d.getDate();
- var current_date = d.getFullYear() + '-' +
- (month<10 ? '0' : '') + month + '-' +
- (day<10 ? '0' : '') + day;
-
- var domain = [
- '|', ['state', '=', 'onboard'],
- '&', ['checkout', '=', current_date],
- ['state', '!=', 'cancel']
- ];
- if (self.config_id && self.config.reservation_allowed_propertie_ids) domain.push(['pms_property_id', 'in', self.config.reservation_allowed_propertie_ids]);
+ var current_date =
+ d.getFullYear() +
+ "-" +
+ (month < 10 ? "0" : "") +
+ month +
+ "-" +
+ (day < 10 ? "0" : "") +
+ day;
+
+ var domain = [
+ "|",
+ ["state", "=", "onboard"],
+ "&",
+ ["checkout", "=", current_date],
+ ["state", "!=", "cancel"],
+ ];
+ if (self.config_id && self.config.reservation_allowed_propertie_ids)
+ domain.push([
+ "pms_property_id",
+ "in",
+ self.config.reservation_allowed_propertie_ids,
+ ]);
return domain;
},
- loaded: function(self, reservations) {
+ loaded: function (self, reservations) {
self.reservations = reservations;
self.db.add_reservations(reservations);
},
});
models.load_models({
- model: 'pms.service',
- fields: ['name', 'id', 'service_line_ids', 'product_id', 'reservation_id'],
- context: function(self){
- var ctx_copy = session.user_context
- ctx_copy['pos_user_force'] = true;
+ model: "pms.service",
+ fields: ["name", "id", "service_line_ids", "product_id", "reservation_id"],
+ context: function (self) {
+ var ctx_copy = session.user_context;
+ ctx_copy.pos_user_force = true;
return ctx_copy;
},
- domain: function(self){
- return [['reservation_id', 'in', self.reservations.map(x => x.id)]];
+ domain: function (self) {
+ return [["reservation_id", "in", self.reservations.map((x) => x.id)]];
},
- loaded: function (self, services){
+ loaded: function (self, services) {
self.services = services;
- var services = []
- _.each(self.reservations, function(reservation){
+ var services = [];
+ _.each(self.reservations, function (reservation) {
services = [];
- _.each(reservation.service_ids, function(service_id){
- services.push(self.services.find(x => x.id === service_id));
+ _.each(reservation.service_ids, function (service_id) {
+ services.push(self.services.find((x) => x.id === service_id));
});
reservation.service_ids = services;
});
@@ -339,24 +410,33 @@ odoo.define('pos_pms_link.models', function (require) {
});
models.load_models({
- model: 'pms.service.line',
- fields: ['date', 'service_id', 'id', 'product_id', 'day_qty', 'pos_order_line_ids'],
- context: function(self){
- var ctx_copy = session.user_context
- ctx_copy['pos_user_force'] = true;
+ model: "pms.service.line",
+ fields: [
+ "date",
+ "service_id",
+ "id",
+ "product_id",
+ "day_qty",
+ "pos_order_line_ids",
+ ],
+ context: function (self) {
+ var ctx_copy = session.user_context;
+ ctx_copy.pos_user_force = true;
return ctx_copy;
},
- domain: function(self){
- return [['service_id', 'in', self.services.map(x => x.id)]];
+ domain: function (self) {
+ return [["service_id", "in", self.services.map((x) => x.id)]];
},
- loaded: function (self, service_lines){
+ loaded: function (self, service_lines) {
self.service_lines = service_lines;
- var service_lines = []
- _.each(self.reservations, function(reservation){
- _.each(reservation.service_ids, function(service_id){
+ var service_lines = [];
+ _.each(self.reservations, function (reservation) {
+ _.each(reservation.service_ids, function (service_id) {
service_lines = [];
- _.each(service_id.service_line_ids, function(line_id){
- service_lines.push(self.service_lines.find(x => x.id === line_id));
+ _.each(service_id.service_line_ids, function (line_id) {
+ service_lines.push(
+ self.service_lines.find((x) => x.id === line_id)
+ );
});
service_id.service_line_ids = service_lines;
});
@@ -365,25 +445,27 @@ odoo.define('pos_pms_link.models', function (require) {
});
models.load_models({
- model: 'pos.order.line',
- fields: ['qty', 'id'],
- domain: function(self){
+ model: "pos.order.line",
+ fields: ["qty", "id"],
+ domain: function (self) {
var order_line_ids = [];
- _.each(self.service_lines, function(service_line) {
- if(service_line.pos_order_line_ids.length > 0) {
- _.each(service_line.pos_order_line_ids, function(line_id) {
+ _.each(self.service_lines, function (service_line) {
+ if (service_line.pos_order_line_ids.length > 0) {
+ _.each(service_line.pos_order_line_ids, function (line_id) {
order_line_ids.push(line_id);
- })
+ });
}
});
- return [['id', 'in', order_line_ids]];
+ return [["id", "in", order_line_ids]];
},
- loaded: function (self, pos_order_lines){
+ loaded: function (self, pos_order_lines) {
self.pos_order_lines = pos_order_lines;
- _.each(self.service_lines, function(service_line){
- var order_lines = []
- _.each(service_line.pos_order_line_ids, function(order_line){
- order_lines.push(self.pos_order_lines.find(x => x.id === order_line));
+ _.each(self.service_lines, function (service_line) {
+ var order_lines = [];
+ _.each(service_line.pos_order_line_ids, function (order_line) {
+ order_lines.push(
+ self.pos_order_lines.find((x) => x.id === order_line)
+ );
});
service_line.pos_order_line_ids = order_lines;
});
@@ -399,11 +481,10 @@ odoo.define('pos_pms_link.models', function (require) {
const context = {};
if (superContext) {
context = superContext.apply(this, arguments);
- }
+ }
context.pos_user_force = true;
return context;
};
return true;
});
-
});
diff --git a/pos_pms_link/static/src/xml/ReservationSelectionButton.xml b/pos_pms_link/static/src/xml/ReservationSelectionButton.xml
index 091dbb6c9..8061bd351 100644
--- a/pos_pms_link/static/src/xml/ReservationSelectionButton.xml
+++ b/pos_pms_link/static/src/xml/ReservationSelectionButton.xml
@@ -1,4 +1,4 @@
-
+
diff --git a/pos_pms_link/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml b/pos_pms_link/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml
index 408f331e6..ef9c1e271 100644
--- a/pos_pms_link/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml
+++ b/pos_pms_link/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml
@@ -1,10 +1,19 @@
-
+
-
+
diff --git a/pos_pms_link/static/src/xml/Screens/ReceiptScreen/OrderReceipt.xml b/pos_pms_link/static/src/xml/Screens/ReceiptScreen/OrderReceipt.xml
index 5ce44673f..2b8197b32 100644
--- a/pos_pms_link/static/src/xml/Screens/ReceiptScreen/OrderReceipt.xml
+++ b/pos_pms_link/static/src/xml/Screens/ReceiptScreen/OrderReceipt.xml
@@ -1,13 +1,18 @@
-
+
-
+
-
+
- Signature:
-
+ Signature:
+
-------------------
diff --git a/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationDetailsEdit.xml b/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationDetailsEdit.xml
index bd3f6c221..0bb8e25fa 100644
--- a/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationDetailsEdit.xml
+++ b/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationDetailsEdit.xml
@@ -1,17 +1,35 @@
-
+
-
+
- Name:
- Checkin:
- Checkout:
- Adults:
- Children:
- Internal comment:
+ Name:
+ Checkin:
+ Checkout:
+ Adults:
+ Children:
+ Internal comment:
Services:
@@ -23,14 +41,28 @@
-
+
- |
+ |
diff --git a/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationLine.xml b/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationLine.xml
index b966adaec..86f568063 100644
--- a/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationLine.xml
+++ b/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationLine.xml
@@ -1,13 +1,19 @@
-
+
-
+
-
+
|
diff --git a/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationListScreen.xml b/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationListScreen.xml
index a27501090..c1dd3bcdc 100644
--- a/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationListScreen.xml
+++ b/pos_pms_link/static/src/xml/Screens/ReservationListScreen/ReservationListScreen.xml
@@ -1,43 +1,71 @@
-
+
- | |