diff --git a/pms/models/pms_service.py b/pms/models/pms_service.py index d69d72205..dd47e93ca 100644 --- a/pms/models/pms_service.py +++ b/pms/models/pms_service.py @@ -50,7 +50,7 @@ class PmsService(models.Model): string="Folio", compute="_compute_folio_id", readonly=False, - store=True + store=True, ) reservation_id = fields.Many2one( "pms.reservation", "Room", default=_default_reservation_id @@ -66,7 +66,10 @@ class PmsService(models.Model): related="folio_id.company_id", string="Company", store=True, readonly=True ) pms_property_id = fields.Many2one( - comodel_name="pms.property", store=True, readonly=True, related="folio_id.pms_property_id" + comodel_name="pms.property", + store=True, + readonly=True, + related="folio_id.pms_property_id", ) tax_ids = fields.Many2many( "account.tax", @@ -370,9 +373,7 @@ class PmsService(models.Model): else: service.price_unit = 0 - @api.depends( - "reservation_id" - ) + @api.depends("reservation_id") def _compute_folio_id(self): for record in self: if record.reservation_id: diff --git a/pms/static/src/js/pms_list_controller.js b/pms/static/src/js/pms_list_controller.js new file mode 100644 index 000000000..6f0837a95 --- /dev/null +++ b/pms/static/src/js/pms_list_controller.js @@ -0,0 +1,41 @@ +odoo.define("booking.engine.tree", function (require) { + "use strict"; + var ListController = require("web.ListController"); + var ListView = require("web.ListView"); + var viewRegistry = require("web.view_registry"); + + function renderBookingEngineButton() { + if (this.$buttons) { + var self = this; + this.$buttons.on("click", ".o_button_booking_engine", function () { + self.do_action({ + name: "Booking Engine", + type: "ir.actions.act_window", + res_model: "pms.folio.wizard", + target: "new", + views: [[false, "form"]], + context: {is_modal: true}, + }); + }); + } + } + + var BookingEngineRequestListController = ListController.extend({ + start: function () { + return this._super.apply(this, arguments); + }, + buttons_template: "BookingEngineRequestListView.buttons", + renderButtons: function () { + this._super.apply(this, arguments); + renderBookingEngineButton.apply(this, arguments); + }, + }); + + var BookingEngineRequestListView = ListView.extend({ + config: _.extend({}, ListView.prototype.config, { + Controller: BookingEngineRequestListController, + }), + }); + + viewRegistry.add("pms_booking_engine_request_tree", BookingEngineRequestListView); +}); diff --git a/pms/static/src/js/views/list/pms_list_controller.js b/pms/static/src/js/views/list/pms_list_controller.js deleted file mode 100644 index 89f312ef8..000000000 --- a/pms/static/src/js/views/list/pms_list_controller.js +++ /dev/null @@ -1,54 +0,0 @@ -odoo.define("pms.group.reservation.wizard", function (require) { - "use strict"; - - var core = require("web.core"); - var _t = core._t; - - var qweb = core.qweb; - - var ReservationWizard = { - start: function () { - // Define a unique uploadId and a callback method - // this.fileUploadID = _.uniqueId("account_bill_file_upload"); - // $(window).on(this.fileUploadID, this._onFileUploaded.bind(this)); - return this._super.apply(this, arguments); - }, - - _onNewReservationGroup: function (event) { - var self = this; - - return this.do_action("pms.action_wizard_folio", { - on_close: function () { - self.reload(); - }, - }); - }, - }; - return ReservationWizard; -}); - -odoo.define("pms.reservation.group", function (require) { - "use strict"; - var core = require("web.core"); - var ListController = require("web.ListController"); - var ListView = require("web.ListView"); - var viewRegistry = require("web.view_registry"); - - var ReservationGroupRequestListController = ListController.extend( - ReservationWizard, - { - buttons_template: "ReservationGroupList.buttons", - events: _.extend({}, ListController.prototype.events, { - "click .o_button_wizard_resevation": "_onNewReservationGroup", - }), - } - ); - - var ReservationGroupRequestListView = ListView.extend({ - config: _.extend({}, ListView.prototype.config, { - Controller: ReservationGroupRequestListController, - }), - }); - - viewRegistry.add("reservation_group", ReservationGroupRequestListView); -}); diff --git a/pms/static/src/xml/reservation_group_button_views.xml b/pms/static/src/xml/reservation_group_button_views.xml index d093d678c..05e713adb 100644 --- a/pms/static/src/xml/reservation_group_button_views.xml +++ b/pms/static/src/xml/reservation_group_button_views.xml @@ -1,8 +1,8 @@ - + - diff --git a/pms/tests/test_pms_room.py b/pms/tests/test_pms_room.py index b955a7e3f..29223a39d 100644 --- a/pms/tests/test_pms_room.py +++ b/pms/tests/test_pms_room.py @@ -1,5 +1,6 @@ from odoo.exceptions import ValidationError -from odoo.tests import common, tagged +from odoo.tests import common + class TestPmsRoom(common.TransactionCase): def create_common_scenario(self): @@ -26,7 +27,6 @@ class TestPmsRoom(common.TransactionCase): } ) - self.room_type_class = self.env["pms.room.type.class"].create( {"name": "Room Class"} ) @@ -42,17 +42,17 @@ class TestPmsRoom(common.TransactionCase): ) def test_check_property_floor(self): - #ARRANGE + # ARRANGE self.create_common_scenario() floor = self.env["pms.floor"].create( { "name": "Floor", "pms_property_ids": [ (4, self.property1.id), - ] + ], } ) - #ACT & ARRANGE + # ACT & ARRANGE with self.assertRaises( ValidationError, msg="Room has been created and it should't" ): diff --git a/pms/views/pms_reservation_views.xml b/pms/views/pms_reservation_views.xml index 5c696fe79..f37a2b8c5 100644 --- a/pms/views/pms_reservation_views.xml +++ b/pms/views/pms_reservation_views.xml @@ -584,8 +584,11 @@ class="o_sale_order" decoration-warning="splitted" decoration-bf="splitted" + js_class="pms_booking_engine_request_tree" > - + + @@ -852,12 +855,12 @@ enable_counters="1" select="multi" /> - + /> diff --git a/pms/views/webclient_templates.xml b/pms/views/webclient_templates.xml index d8805c83e..61c2147a7 100644 --- a/pms/views/webclient_templates.xml +++ b/pms/views/webclient_templates.xml @@ -12,6 +12,10 @@ type="text/javascript" src="/pms/static/src/js/widgets/switch_property_menu.js" /> +