From 729d789a97415132c3af1e6c8a687a735dcc0bcc Mon Sep 17 00:00:00 2001 From: Ammar Officewala <36848414+AmmarOfficewalaSerpentCS@users.noreply.github.com> Date: Tue, 19 Apr 2022 18:50:32 +0530 Subject: [PATCH] [ADD] pms_website_sale (#93) --- pms_website_sale/README.rst | 112 +++++ pms_website_sale/__init__.py | 3 + pms_website_sale/__manifest__.py | 21 + pms_website_sale/controllers/__init__.py | 3 + pms_website_sale/controllers/website.py | 227 +++++++++ pms_website_sale/data/website_menu.xml | 8 + pms_website_sale/i18n/es.po | 99 ++++ pms_website_sale/i18n/pms_website_sale.pot | 98 ++++ pms_website_sale/readme/CONFIGURE.rst | 1 + pms_website_sale/readme/CONTRIBUTORS.rst | 15 + pms_website_sale/readme/DESCRIPTION.rst | 3 + pms_website_sale/readme/USAGE.rst | 1 + pms_website_sale/security/ir.model.access.csv | 2 + .../security/pms_website_sale.xml | 24 + .../static/description/index.html | 455 ++++++++++++++++++ .../static/src/js/pms_property.js | 23 + .../tests/tours/pms_website_sale_tour.js | 33 ++ pms_website_sale/tests/__init__.py | 3 + .../tests/test_pms_sale_property.py | 44 ++ pms_website_sale/views/assets.xml | 31 ++ pms_website_sale/views/templates.xml | 336 +++++++++++++ .../odoo/addons/pms_website_sale | 1 + setup/pms_website_sale/setup.py | 6 + 23 files changed, 1549 insertions(+) create mode 100644 pms_website_sale/README.rst create mode 100644 pms_website_sale/__init__.py create mode 100644 pms_website_sale/__manifest__.py create mode 100644 pms_website_sale/controllers/__init__.py create mode 100644 pms_website_sale/controllers/website.py create mode 100644 pms_website_sale/data/website_menu.xml create mode 100644 pms_website_sale/i18n/es.po create mode 100644 pms_website_sale/i18n/pms_website_sale.pot create mode 100644 pms_website_sale/readme/CONFIGURE.rst create mode 100644 pms_website_sale/readme/CONTRIBUTORS.rst create mode 100644 pms_website_sale/readme/DESCRIPTION.rst create mode 100644 pms_website_sale/readme/USAGE.rst create mode 100644 pms_website_sale/security/ir.model.access.csv create mode 100644 pms_website_sale/security/pms_website_sale.xml create mode 100644 pms_website_sale/static/description/index.html create mode 100644 pms_website_sale/static/src/js/pms_property.js create mode 100644 pms_website_sale/static/tests/tours/pms_website_sale_tour.js create mode 100644 pms_website_sale/tests/__init__.py create mode 100644 pms_website_sale/tests/test_pms_sale_property.py create mode 100644 pms_website_sale/views/assets.xml create mode 100644 pms_website_sale/views/templates.xml create mode 120000 setup/pms_website_sale/odoo/addons/pms_website_sale create mode 100644 setup/pms_website_sale/setup.py diff --git a/pms_website_sale/README.rst b/pms_website_sale/README.rst new file mode 100644 index 000000000..c5dded4aa --- /dev/null +++ b/pms_website_sale/README.rst @@ -0,0 +1,112 @@ +================== +PMS - Website Sale +================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpms-lightgray.png?logo=github + :target: https://github.com/OCA/pms/tree/14.0-pms_base/pms_website_sale + :alt: OCA/pms +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pms-14-0-pms_base/pms-14-0-pms_base-pms_website_sale + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/293/14.0-pms_base + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module is the base module for the property management system (PMS) modules. + +It provides the "Properties" apps with menu, settings, groups and data. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +* Go to Properties > Configuration > Settings. + +Usage +===== + +To use this module, please read the complete user guide at ``_. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Open Source Integrators + +Contributors +~~~~~~~~~~~~ + +* Alexandre Díaz +* Pablo Quesada +* Jose Luis Algara +* `Commit [Sun] `: + + * Dario Lodeiros + * Eric Antones + * Sara Lago + * Brais Abeijon + * Miguel Padin + +* `Open Source Integrators `: + + * Maxime Chambreuil + * Ammar Officewala + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-max3903| image:: https://github.com/max3903.png?size=40px + :target: https://github.com/max3903 + :alt: max3903 + +Current `maintainer `__: + +|maintainer-max3903| + +This module is part of the `OCA/pms `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pms_website_sale/__init__.py b/pms_website_sale/__init__.py new file mode 100644 index 000000000..0f075ad0e --- /dev/null +++ b/pms_website_sale/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import controllers diff --git a/pms_website_sale/__manifest__.py b/pms_website_sale/__manifest__.py new file mode 100644 index 000000000..075aa6e83 --- /dev/null +++ b/pms_website_sale/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright (c) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "PMS - Website Sale", + "summary": "Allow online booking of your properties", + "version": "14.0.1.0.0", + "development_status": "Alpha", + "category": "Generic Modules/Property Management System", + "website": "https://github.com/OCA/pms", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["pms_website", "pms_sale", "website_sale"], + "data": [ + "data/website_menu.xml", + "security/ir.model.access.csv", + "security/pms_website_sale.xml", + "views/templates.xml", + "views/assets.xml", + ], + "maintainers": ["max3903"], +} diff --git a/pms_website_sale/controllers/__init__.py b/pms_website_sale/controllers/__init__.py new file mode 100644 index 000000000..abeb98b7b --- /dev/null +++ b/pms_website_sale/controllers/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import website diff --git a/pms_website_sale/controllers/website.py b/pms_website_sale/controllers/website.py new file mode 100644 index 000000000..187b77f33 --- /dev/null +++ b/pms_website_sale/controllers/website.py @@ -0,0 +1,227 @@ +# Copyright (c) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from datetime import datetime + +from odoo import http +from odoo.http import request + +from odoo.addons.http_routing.models.ir_http import slug +from odoo.addons.website.controllers.main import QueryURL +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class PropertyTableCompute(object): + def __init__(self): + self.table = {} + + def _check_place(self, posx, posy, sizex, sizey, ppr): + res = True + for y in range(sizey): + for x in range(sizex): + if posx + x >= ppr: + res = False + break + row = self.table.setdefault(posy + y, {}) + if row.setdefault(posx + x) is not None: + res = False + break + for x in range(ppr): + self.table[posy + y].setdefault(x, None) + return res + + def process(self, products, ppg=20, ppr=4): + # Compute products positions on the grid + minpos = 0 + index = 0 + maxy = 0 + x = 0 + for p in products: + x = min(1, ppr) + y = min(1, ppr) + if index >= ppg: + x = y = 1 + + pos = minpos + while not self._check_place(pos % ppr, pos // ppr, x, y, ppr): + pos += 1 + # if 21st products (index 20) and the last line is full (ppr products in it), break + # (pos + 1.0) / ppr is the line where the product would be inserted + # maxy is the number of existing lines + # + 1.0 is because pos begins at 0, thus pos 20 is actually the 21st block + # and to force python to not round the division operation + if index >= ppg and ((pos + 1.0) // ppr) > maxy: + break + + if x == 1 and y == 1: # simple heuristic for CPU optimization + minpos = pos // ppr + + for y2 in range(y): + for x2 in range(x): + self.table[(pos // ppr) + y2][(pos % ppr) + x2] = False + self.table[pos // ppr][pos % ppr] = {"product": p, "x": x, "y": y} + if index <= ppg: + maxy = max(maxy, y + (pos // ppr)) + index += 1 + + # Format table according to HTML needs + rows = sorted(self.table.items()) + rows = [r[1] for r in rows] + for col in range(len(rows)): + cols = sorted(rows[col].items()) + x += len(cols) + rows[col] = [r[1] for r in cols if r[1]] + + return rows + + +class WebsiteSale(WebsiteSale): + def _get_property_search_domain(self, search, category, guest, args): + domain = [] + if search: + domain += [("city", "ilike", search)] + if guest: + domain += [("no_of_guests", ">=", int(guest))] + if category: + domain += [("property_category_ids", "child_of", category.id)] + if args.get("date_range"): + date_range = args.get("date_range").split("-") + start = date_range[0].strip() + " 00:00:00" + end = date_range[1].strip() + " 23:59:59" + start = datetime.strptime(start, "%m/%d/%Y %H:%M:%S") + end = datetime.strptime(end, "%m/%d/%Y %H:%M:%S") + reservation_ids = ( + request.env["pms.reservation"] + .sudo() + .search( + [ + ("stop", "<=", end), + "|", + "|", + ("start", ">=", start), + ("start", ">=", end), + ("stop", ">=", start), + ] + ) + ) + property_ids = reservation_ids.mapped("property_id") + domain += [("id", "not in", property_ids.ids)] + domain += [("property_child_ids", "=", False)] + return domain + + def _get_pricelist_context(self): + pricelist_context = dict(request.env.context) + pricelist = False + if not pricelist_context.get("pricelist"): + pricelist = request.website.get_current_pricelist() + pricelist_context["pricelist"] = pricelist.id + else: + pricelist = request.env["product.pricelist"].browse( + pricelist_context["pricelist"] + ) + + return pricelist_context, pricelist + + def _update_property_values(self, Property, post): + values = { + "city": list( + { + property_rec.city + for property_rec in Property.search([]) + if property_rec.city + } + ) + } + return values + + @http.route( + [ + """/property""", + """/property/page/""", + """/property/category/""", + ], + type="http", + auth="public", + website=True, + ) + def property( + self, page=0, ppg=False, category=None, search="", guest_select="", **post + ): + Category = request.env["pms.website.category"] + if category: + category = Category.search([("id", "=", int(category))], limit=1) + else: + category = Category + + if ppg: + try: + ppg = int(ppg) + post["ppg"] = ppg + except ValueError: + ppg = False + if not ppg: + ppg = request.env["website"].get_current_website().shop_ppg or 20 + + ppr = request.env["website"].get_current_website().shop_ppr or 4 + + domain = self._get_property_search_domain( + search=search, category=category, guest=guest_select, args=post + ) + + keep = QueryURL("/property", category=category and int(category)) + + pricelist_context, pricelist = self._get_pricelist_context() + + request.context = dict( + request.context, pricelist=pricelist.id, partner=request.env.user.partner_id + ) + + Property = request.env["pms.property"].with_context(bin_size=True) + + search_property = Property.search(domain, order="name asc") + url = "/property" + + categs_domain = [("parent_id", "=", False)] + if search: + search_categories = Category.search( + [("property_ids", "in", search_property.ids)] + ).parents_and_self + categs_domain.append(("id", "in", search_categories.ids)) + else: + search_categories = Category + categs = Category.search(categs_domain) + + if category: + url = "/shop/category/%s" % slug(category) + + product_count = len(search_property) + pager = request.website.pager( + url=url, total=product_count, page=page, step=ppg, scope=7, url_args=post + ) + offset = pager["offset"] + properties = search_property[offset : offset + ppg] + + layout_mode = "grid" + + values = self._update_property_values(Property=Property, post=post) + # properties + values.update( + { + "category": category, + "search_city": search, + "search_guest": guest_select, + "search_raneg": post.get("date_range"), + "pager": pager, + "pricelist": pricelist, + "properties": properties, + "search_count": product_count, # common for all searchbox + "bins": PropertyTableCompute().process(properties, ppg, ppr), + "ppg": ppg, + "ppr": ppr, + "keep": keep, + "layout_mode": layout_mode, + "categories": categs, + "search_categories_ids": search_categories.ids, + } + ) + + return request.render("pms_website_sale.properties", values) diff --git a/pms_website_sale/data/website_menu.xml b/pms_website_sale/data/website_menu.xml new file mode 100644 index 000000000..c41cff46b --- /dev/null +++ b/pms_website_sale/data/website_menu.xml @@ -0,0 +1,8 @@ + + + Properties + /property + + 20 + + diff --git a/pms_website_sale/i18n/es.po b/pms_website_sale/i18n/es.po new file mode 100644 index 000000000..651c17026 --- /dev/null +++ b/pms_website_sale/i18n/es.po @@ -0,0 +1,99 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pms_website_sale +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0+e-20211202\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-12-23 19:43+0000\n" +"PO-Revision-Date: 2021-12-23 19:43+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.pms_search_box +msgid "Add one" +msgstr "Agregar una" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.property_categories +msgid "All Properties" +msgstr "Todas las propiedades" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.pms_search_box +msgid "City..." +msgstr "Ciudad..." + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "" +"Click 'New' in the top-right corner to create your first property." +msgstr "" +"Dale clic 'Nueva' en la esquina derecha arriba para crear tu primera propiedad." + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.pms_search_box +msgid "Guest..." +msgstr "Huesped..." + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "No Property defined" +msgstr "No se ha definido ninguna propiedad" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "No property defined in category \"" +msgstr "No hay propiedad definida en la categoría \"" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "No results" +msgstr "Sin resultados" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "No results for \"" +msgstr "Sin resultados para \"" + +#. module: pms_website_sale +#: model:website.menu,name:pms_website_sale.menu_property +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "Properties" +msgstr "Propiedades" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.sale_order_portal_content +msgid "Property" +msgstr "Propiedad" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.pms_search_box +msgid "Remove one" +msgstr "Quitar una" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.property_categories +msgid "Show categories" +msgstr "Mostrar categorías" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.property_item +msgid "This product is unpublished." +msgstr "Este producto no esta publicado." + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.property_item +msgid "Unpublished" +msgstr "Despublicada" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "in category \"" +msgstr "en categoría \"" diff --git a/pms_website_sale/i18n/pms_website_sale.pot b/pms_website_sale/i18n/pms_website_sale.pot new file mode 100644 index 000000000..3c1cddc55 --- /dev/null +++ b/pms_website_sale/i18n/pms_website_sale.pot @@ -0,0 +1,98 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pms_website_sale +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0+e-20211202\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-12-23 19:43+0000\n" +"PO-Revision-Date: 2021-12-23 19:43+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.pms_search_box +msgid "Add one" +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.property_categories +msgid "All Properties" +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.pms_search_box +msgid "City..." +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "" +"Click 'New' in the top-right corner to create your first property." +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.pms_search_box +msgid "Guest..." +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "No Property defined" +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "No property defined in category \"" +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "No results" +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "No results for \"" +msgstr "" + +#. module: pms_website_sale +#: model:website.menu,name:pms_website_sale.menu_property +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "Properties" +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.sale_order_portal_content +msgid "Property" +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.pms_search_box +msgid "Remove one" +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.property_categories +msgid "Show categories" +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.property_item +msgid "This product is unpublished." +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.property_item +msgid "Unpublished" +msgstr "" + +#. module: pms_website_sale +#: model_terms:ir.ui.view,arch_db:pms_website_sale.properties +msgid "in category \"" +msgstr "" diff --git a/pms_website_sale/readme/CONFIGURE.rst b/pms_website_sale/readme/CONFIGURE.rst new file mode 100644 index 000000000..173b6bdd6 --- /dev/null +++ b/pms_website_sale/readme/CONFIGURE.rst @@ -0,0 +1 @@ +* Go to Properties > Configuration > Settings. diff --git a/pms_website_sale/readme/CONTRIBUTORS.rst b/pms_website_sale/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..1f56f4671 --- /dev/null +++ b/pms_website_sale/readme/CONTRIBUTORS.rst @@ -0,0 +1,15 @@ +* Alexandre Díaz +* Pablo Quesada +* Jose Luis Algara +* `Commit [Sun] `: + + * Dario Lodeiros + * Eric Antones + * Sara Lago + * Brais Abeijon + * Miguel Padin + +* `Open Source Integrators `: + + * Maxime Chambreuil + * Ammar Officewala diff --git a/pms_website_sale/readme/DESCRIPTION.rst b/pms_website_sale/readme/DESCRIPTION.rst new file mode 100644 index 000000000..55ee4048c --- /dev/null +++ b/pms_website_sale/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module is the base module for the property management system (PMS) modules. + +It provides the "Properties" apps with menu, settings, groups and data. diff --git a/pms_website_sale/readme/USAGE.rst b/pms_website_sale/readme/USAGE.rst new file mode 100644 index 000000000..acb2b8f3d --- /dev/null +++ b/pms_website_sale/readme/USAGE.rst @@ -0,0 +1 @@ +To use this module, please read the complete user guide at ``_. diff --git a/pms_website_sale/security/ir.model.access.csv b/pms_website_sale/security/ir.model.access.csv new file mode 100644 index 000000000..02536f30f --- /dev/null +++ b/pms_website_sale/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +access_pm_property_reservation_public,access_pm_property_reservation,pms_sale.model_pms_property_reservation,,1,0,0,0 diff --git a/pms_website_sale/security/pms_website_sale.xml b/pms_website_sale/security/pms_website_sale.xml new file mode 100644 index 000000000..801e444fd --- /dev/null +++ b/pms_website_sale/security/pms_website_sale.xml @@ -0,0 +1,24 @@ + + + + Property + + [('website_published', '=', True)] + + + + + + + + + + + + diff --git a/pms_website_sale/static/description/index.html b/pms_website_sale/static/description/index.html new file mode 100644 index 000000000..6c5823e1a --- /dev/null +++ b/pms_website_sale/static/description/index.html @@ -0,0 +1,455 @@ + + + + + + +PMS - Website Sale + + + +
+

PMS - Website Sale

+ + +

Alpha License: AGPL-3 OCA/pms Translate me on Weblate Try me on Runbot

+

This module is the base module for the property management system (PMS) modules.

+

It provides the “Properties” apps with menu, settings, groups and data.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Configuration

+
    +
  • Go to Properties > Configuration > Settings.
  • +
+
+
+

Usage

+

To use this module, please read the complete user guide at roomdoo.com.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Open Source Integrators
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

max3903

+

This module is part of the OCA/pms project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/pms_website_sale/static/src/js/pms_property.js b/pms_website_sale/static/src/js/pms_property.js new file mode 100644 index 000000000..12eeccaef --- /dev/null +++ b/pms_website_sale/static/src/js/pms_property.js @@ -0,0 +1,23 @@ +odoo.define("pms_website_sale.pms_property", function (require) { + "use strict"; + + const publicWidget = require("web.public.widget"); + + publicWidget.registry.pmsProperty = publicWidget.Widget.extend({ + selector: ".oe_property_filtter", + jsLibs: [ + "/web/static/lib/daterangepicker/daterangepicker.js", + "/web/static/src/js/libs/daterangepicker.js", + ], + cssLibs: ["/web/static/lib/daterangepicker/daterangepicker.css"], + start: function () { + var def = this._super.apply(this, arguments); + $(".field_date_range_filtter").daterangepicker({ + autoApply: true, + mindate: new moment(), + }); + + return def; + }, + }); +}); diff --git a/pms_website_sale/static/tests/tours/pms_website_sale_tour.js b/pms_website_sale/static/tests/tours/pms_website_sale_tour.js new file mode 100644 index 000000000..2378543a0 --- /dev/null +++ b/pms_website_sale/static/tests/tours/pms_website_sale_tour.js @@ -0,0 +1,33 @@ +odoo.define("pms_website_sale.pms_website_sale_tour", function (require) { + "use strict"; + + var tour = require("web_tour.tour"); + + // This tour relies on data created on the Python test. + tour.register( + "property_load_homepage", + { + test: true, + url: "/property", + }, + [ + { + content: "Check Property", + trigger: ".oe_website_sale", + }, + ] + ); + tour.register( + "property_search_homepage", + { + test: true, + url: "/property?date_range=04/18/2022-04/18/2022&guest_select=2", + }, + [ + { + content: "Check Property", + trigger: ".oe_website_sale", + }, + ] + ); +}); diff --git a/pms_website_sale/tests/__init__.py b/pms_website_sale/tests/__init__.py new file mode 100644 index 000000000..56b3eb91b --- /dev/null +++ b/pms_website_sale/tests/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import test_pms_sale_property diff --git a/pms_website_sale/tests/test_pms_sale_property.py b/pms_website_sale/tests/test_pms_sale_property.py new file mode 100644 index 000000000..39c90e2b0 --- /dev/null +++ b/pms_website_sale/tests/test_pms_sale_property.py @@ -0,0 +1,44 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.tests import tagged + +from odoo.addons.base.tests.common import HttpCaseWithUserPortal + + +@tagged("post_install", "-at_install") +class TestWebsiteSaleCartRecovery(HttpCaseWithUserPortal): + def test_01_property_page(self): + self.start_tour("/", "property_load_homepage", login="portal") + self.env["pms.property"].create( + { + "name": "Property 1", + "website_published": True, + "owner_id": self.env.ref("base.res_partner_12").id, + "no_of_guests": 2, + } + ) + self.env["pms.property"].create( + { + "name": "Property 2", + "website_published": True, + "owner_id": self.env.ref("base.res_partner_12").id, + "no_of_guests": 2, + } + ) + self.env["pms.property"].create( + { + "name": "Property 3", + "website_published": True, + "owner_id": self.env.ref("base.res_partner_12").id, + "no_of_guests": 2, + } + ) + self.env["pms.property"].create( + { + "name": "Property 4", + "website_published": True, + "owner_id": self.env.ref("base.res_partner_12").id, + "no_of_guests": 2, + } + ) + self.start_tour("/", "property_search_homepage") diff --git a/pms_website_sale/views/assets.xml b/pms_website_sale/views/assets.xml new file mode 100644 index 000000000..90c4a917b --- /dev/null +++ b/pms_website_sale/views/assets.xml @@ -0,0 +1,31 @@ + + + +