[DEL] Cleanup

This commit is contained in:
Maxime Chambreuil
2022-01-06 11:12:15 -06:00
parent bad19e534d
commit 7919b2acbb
335 changed files with 0 additions and 80593 deletions

View File

@@ -1,19 +0,0 @@
# Copyright 2018 Alexandre Díaz
# Copyright 2018 Dario Lodeiros
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import (
pms_stage,
pms_tag,
pms_team,
pms_room_type,
pms_amenity_type,
pms_room,
pms_amenity,
pms_service,
pms_property,
res_company,
res_config_settings,
res_partner,
)

View File

@@ -1,33 +0,0 @@
# Copyright 2017 Alexandre Díaz
# Copyright 2017 Dario Lodeiros
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PmsAmenity(models.Model):
_name = "pms.amenity"
_description = "Property Amenity"
active = fields.Boolean(
string="Active", help="Determines if amenity is active", default=True
)
name = fields.Char(
string="Name", help="Name of the amenity", required=True, translate=True
)
property_ids = fields.Many2many(
string="Properties",
help="Properties with access to the amenity",
comodel_name="pms.property",
ondelete="restrict",
relation="pms_property_amenity_rel",
column1="amenity_id",
column2="property_id",
)
type_id = fields.Many2one(
string="Type",
help="Organize amenities by type (multimedia, comfort, etc ...)",
comodel_name="pms.amenity.type",
)
default_code = fields.Char(
string="Internal Reference", help="Internal unique identifier of the amenity"
)

View File

@@ -1,14 +0,0 @@
# Copyright 2017 Alexandre Díaz
# Copyright 2017 Dario Lodeiros
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PmsRoomAmenityType(models.Model):
_name = "pms.amenity.type"
_description = "Amenity Type"
active = fields.Boolean(
string="Active", help="Determines if amenity type is active", default=True
)
name = fields.Char(string="Name", required=True, translate=True)

View File

@@ -1,288 +0,0 @@
# Copyright 2019 Pablo Quesada
# Copyright 2019 Dario Lodeiros
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo.addons.base.models.res_partner import _tz_get
class PmsProperty(models.Model):
_name = "pms.property"
_description = "Property"
_inherit = ["mail.thread", "mail.activity.mixin"]
_inherits = {"res.partner": "partner_id"}
def _default_team_id(self):
return self.env.ref("pms_base.pms_team_default", raise_if_not_found=False)
partner_id = fields.Many2one(
string="Property",
help="Current property",
comodel_name="res.partner",
required=True,
ondelete="cascade",
)
owner_id = fields.Many2one(
string="Owner",
help="The owner of the property.",
comodel_name="res.partner",
required=True,
)
parent_id = fields.Many2one(string="Parent Property", comodel_name="pms.property")
property_child_ids = fields.One2many(
"pms.property", "parent_id", string="Children Property"
)
company_id = fields.Many2one(string="Company", comodel_name="res.company")
team_id = fields.Many2one(
"pms.team", string="Team", default=lambda self: self._default_team_id()
)
room_ids = fields.One2many(
string="Rooms",
help="List of rooms in the property.",
comodel_name="pms.room",
inverse_name="property_id",
)
room_count = fields.Integer(string="Number of rooms", compute="_compute_room_count")
amenity_ids = fields.Many2many(
string="Amenities",
help="Amenities available in this property",
comodel_name="pms.amenity",
ondelete="restrict",
relation="pms_property_amenity_rel",
column1="property_id",
column2="amenity_id",
)
service_ids = fields.One2many(
string="Services",
help="List of services available in the property.",
comodel_name="pms.service",
inverse_name="property_id",
)
tag_ids = fields.Many2many(
string="Tags",
comodel_name="pms.tag",
relation="pms_property_tag_rel",
column1="property_id",
column2="tag_id",
)
tz = fields.Selection(
string="Timezone",
help="This field is used to determine the timezone of the property.",
required=True,
default=lambda self: self.env.user.tz or "UTC",
selection=_tz_get,
)
area = fields.Float(string="Area")
heating = fields.Selection(
string="Heating",
selection=[
("tankless_gas", "Gas (Tankless)"),
("boiler_gas", "Gas Boiler"),
("tankless_electric", "Electric (Tankless)"),
("boiler_electric", "Electric Boiler"),
("boiler_building", "Building Boiler"),
],
)
childs_property_count = fields.Integer(
"Children Count", compute="_compute_childs_property"
)
floors_num = fields.Integer(string="Floor")
unit_floor = fields.Integer(string="Unit Floor")
balcony = fields.Boolean(string="Balcony", compute="_compute_balcony", store=True)
laundry_room = fields.Boolean(
string="Laundry Room", compute="_compute_laundry_room", store=True
)
parking_lot = fields.Boolean(
string="Parking Lot", compute="_compute_parking_lot", store=True
)
pets = fields.Boolean(string="Pets", compute="_compute_pets", store=True)
terrace = fields.Boolean(string="Terrace", compute="_compute_terrace", store=True)
qty_half_bathroom = fields.Integer(
string="Qty Half Bathroom", compute="_compute_qty_half_bathroom", store=True
)
qty_living_room = fields.Integer(
string="Qty Living Room", compute="_compute_qty_living_room", store=True
)
qty_dining_room = fields.Integer(
string="Qty Dining Room", compute="_compute_qty_dining_room", store=True
)
qty_kitchen = fields.Integer(
string="Qty Kitchen", compute="_compute_qty_kitchen", store=True
)
qty_bedroom = fields.Integer(
string="Qty Bedroom", compute="_compute_qty_bedroom", store=True
)
@api.depends("property_child_ids")
def _compute_childs_property(self):
for rec in self:
rec.childs_property_count = len(rec.property_child_ids)
@api.depends("room_ids")
def _compute_room_count(self):
for rec in self:
rec.room_count = len(rec.room_ids)
@api.depends("room_ids")
def _compute_balcony(self):
for rec in self:
type_id = self.env.ref(
"pms_base.pms_room_type_balcony", raise_if_not_found=False
)
balcony = len(rec.room_ids.filtered(lambda x: x.type_id == type_id))
if balcony:
rec.balcony = True
else:
rec.balcony = False
@api.depends("room_ids", "amenity_ids")
def _compute_laundry_room(self):
for rec in self:
room_type_id = self.env.ref(
"pms_base.pms_room_type_laundry", raise_if_not_found=False
)
amenity_type_id = self.env.ref(
"pms_base.pms_amenity_type_3", raise_if_not_found=False
)
room_count_laundry = len(
rec.room_ids.filtered(lambda x: x.type_id == room_type_id)
)
amenity_count_laundry = len(
rec.amenity_ids.filtered(lambda x: x.type_id == amenity_type_id)
)
if room_count_laundry or amenity_count_laundry:
rec.laundry_room = True
else:
rec.laundry_room = False
@api.depends("room_ids", "amenity_ids")
def _compute_parking_lot(self):
for rec in self:
room_type_id = self.env.ref(
"pms_base.pms_room_type_parking_lot", raise_if_not_found=False
)
amenity_type_id = self.env.ref(
"pms_base.pms_amenity_type_4", raise_if_not_found=False
)
room_count_parking = len(
rec.room_ids.filtered(lambda x: x.type_id == room_type_id)
)
amenity_count_parking = len(
rec.amenity_ids.filtered(lambda x: x.type_id == amenity_type_id)
)
if room_count_parking or amenity_count_parking:
rec.parking_lot = True
else:
rec.parking_lot = False
@api.depends("room_ids", "amenity_ids")
def _compute_pets(self):
for rec in self:
room_type_id = self.env.ref(
"pms_base.pms_room_type_pets", raise_if_not_found=False
)
amenity_type_id = self.env.ref(
"pms_base.pms_amenity_type_5", raise_if_not_found=False
)
room_count_pets = len(
rec.room_ids.filtered(lambda x: x.type_id == room_type_id)
)
amenity_count_pets = len(
rec.amenity_ids.filtered(lambda x: x.type_id == amenity_type_id)
)
if room_count_pets or amenity_count_pets:
rec.pets = True
else:
rec.pets = False
@api.depends("room_ids")
def _compute_terrace(self):
for rec in self:
type_id = self.env.ref(
"pms_base.pms_room_type_patio", raise_if_not_found=False
)
terrace = len(rec.room_ids.filtered(lambda x: x.type_id == type_id))
if terrace:
rec.terrace = True
else:
rec.terrace = False
@api.depends("room_ids")
def _compute_qty_half_bathroom(self):
for rec in self:
type_id = self.env.ref(
"pms_base.pms_room_type_half_bath", raise_if_not_found=False
)
rec.qty_half_bathroom = len(
rec.room_ids.filtered(lambda x: x.type_id == type_id)
)
@api.depends("room_ids")
def _compute_qty_living_room(self):
for rec in self:
type_id = self.env.ref(
"pms_base.pms_room_type_living", raise_if_not_found=False
)
rec.qty_living_room = len(
rec.room_ids.filtered(lambda x: x.type_id == type_id)
)
@api.depends("room_ids")
def _compute_qty_dining_room(self):
for rec in self:
type_id = self.env.ref(
"pms_base.pms_room_type_dining", raise_if_not_found=False
)
rec.qty_dining_room = len(
rec.room_ids.filtered(lambda x: x.type_id == type_id)
)
@api.depends("room_ids")
def _compute_qty_kitchen(self):
for rec in self:
type_id = self.env.ref(
"pms_base.pms_room_type_kitchen", raise_if_not_found=False
)
rec.qty_kitchen = len(rec.room_ids.filtered(lambda x: x.type_id == type_id))
@api.depends("room_ids")
def _compute_qty_bedroom(self):
for rec in self:
type_id = self.env.ref(
"pms_base.pms_room_type_bed", raise_if_not_found=False
)
rec.qty_bedroom = len(rec.room_ids.filtered(lambda x: x.type_id == type_id))
def action_view_childs_property_list(self):
action = self.env["ir.actions.actions"]._for_xml_id(
"pms_base.action_pms_property"
)
action["domain"] = [("id", "in", self.property_child_ids.ids)]
return action
@api.model
def create(self, vals):
vals.update({"is_property": True})
return super(PmsProperty, self).create(vals)
def name_get(self):
# Prefetch the fields used by the `name_get`, so `browse` doesn't fetch other fields
self.browse(self.ids).read(["name", "ref"])
return [
(
property.id,
"%s%s" % (property.ref and "[%s] " % property.ref or "", property.name),
)
for property in self
]
@api.model
def _name_search(
self, name, args=None, operator="ilike", limit=100, name_get_uid=None
):
args = args or []
domain = []
if name:
domain = ["|", ("name", operator, name), ("ref", operator, name)]
return self._search(domain + args, limit=limit, access_rights_uid=name_get_uid)

View File

@@ -1,47 +0,0 @@
# Copyright 2017 Alexandre Díaz
# Copyright 2017 Dario Lodeiros
# Copyright 2018 Pablo Quesada
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PmsRoom(models.Model):
_name = "pms.room"
_description = "Property Room"
_order = "sequence, type_id, name"
name = fields.Char(string="Room Name", help="Room Name", required=True)
active = fields.Boolean(
string="Active", help="Determines if room is active", default=True
)
sequence = fields.Integer(
string="Sequence",
help="Field used to change the position of the rooms in tree view."
"Changing the position changes the sequence",
default=0,
)
property_id = fields.Many2one(
string="Property",
required=True,
comodel_name="pms.property",
ondelete="restrict",
)
type_id = fields.Many2one(
string="Room Type",
help="Unique room type for the rooms",
required=True,
comodel_name="pms.room.type",
ondelete="restrict",
)
capacity = fields.Integer(
string="Capacity", help="The maximum number of people that can occupy a room"
)
area = fields.Float(string="Area")
_sql_constraints = [
(
"room_property_unique",
"unique(name, property_id)",
"You cannot have more 2 rooms with the same name in the same property.",
)
]

View File

@@ -1,17 +0,0 @@
# Copyright 2017 Alexandre Díaz
# Copyright 2017 Dario Lodeiros
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PmsRoomType(models.Model):
_name = "pms.room.type"
_description = "Room Type"
name = fields.Char(string="Name", required=True, translate=True)
sequence = fields.Integer(string="Sequence", default=0)
icon = fields.Char(
string="Website Icon", help="Set Icon name from https://fontawesome.com/"
)

View File

@@ -1,41 +0,0 @@
# Copyright 2017 Alexandre Díaz
# Copyright 2017 Dario Lodeiros
# Copyright 2018 Pablo Quesada
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PmsService(models.Model):
_name = "pms.service"
_description = "Property Service"
name = fields.Many2one(
string="Service",
help="Service",
required=True,
comodel_name="product.product",
ondelete="restrict",
domain="[('type', '=', 'service')]",
)
active = fields.Boolean(
string="Active", help="Determines if service is active", default=True
)
sequence = fields.Integer(
string="Sequence",
help="Field used to change the position of the rooms in tree view."
"Changing the position changes the sequence",
default=0,
)
property_id = fields.Many2one(
string="Property",
required=True,
comodel_name="pms.property",
ondelete="restrict",
)
vendor_id = fields.Many2one(
string="Vendor", required=True, comodel_name="res.partner", ondelete="restrict"
)
icon = fields.Char(
string="Website Icon", help="Set Icon name from https://fontawesome.com/"
)

View File

@@ -1,50 +0,0 @@
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class PMSStage(models.Model):
_name = "pms.stage"
_description = "PMS Stage"
_order = "sequence, name, id"
def _default_team_ids(self):
default_team_id = self.env.context.get("default_team_id")
return [default_team_id] if default_team_id else None
name = fields.Char(string="Name", required=True, translate=True)
sequence = fields.Integer("Sequence", default=1)
fold = fields.Boolean(
"Folded in Kanban",
help="This stage is folded in the kanban view when "
"there are no record in that stage to display.",
)
is_closed = fields.Boolean(
"Is a close stage", help="Services in this stage are considered " "as closed."
)
is_default = fields.Boolean("Is a default stage", help="Used as default stage")
description = fields.Text(translate=True)
company_id = fields.Many2one(
"res.company",
string="Company",
required=False,
index=True,
default=lambda self: self.env.user.company_id,
)
team_ids = fields.Many2many(
"pms.team", string="Teams", default=lambda self: self._default_team_ids()
)
stage_type = fields.Selection([("property", "Property")], "Type", required=True)
custom_color = fields.Char(
"Color Code", default="#FFFFFF", help="Use Hex Code only Ex:-#FFFFFF"
)
@api.constrains("custom_color")
def _check_custom_color_hex_code(self):
if (
self.custom_color
and not self.custom_color.startswith("#")
or len(self.custom_color) != 7
):
raise ValidationError(_("Color code should be Hex Code. Ex:-#FFFFFF"))

View File

@@ -1,33 +0,0 @@
# Copyright 2017 Alexandre Díaz
# Copyright 2017 Dario Lodeiros
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PmsTag(models.Model):
_name = "pms.tag"
_description = "PMS Tag"
name = fields.Char(string="Name", required=True, translate=True)
parent_id = fields.Many2one("pms.tag", string="Parent")
color = fields.Integer("Color Index", default=10)
full_name = fields.Char(string="Full Name", compute="_compute_full_name")
company_id = fields.Many2one(
"res.company",
string="Company",
required=True,
index=True,
default=lambda self: self.env.user.company_id,
help="Company related to this tag",
)
_sql_constraints = [("name_uniq", "unique (name)", "Tag name already exists!")]
def _compute_full_name(self):
for record in self:
if record.parent_id:
record.full_name = record.parent_id.name + "/" + record.name
else:
record.full_name = record.name

View File

@@ -1,41 +0,0 @@
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PMSTeam(models.Model):
_name = "pms.team"
_description = "PMS Team"
_inherit = ["mail.thread", "mail.activity.mixin"]
def _default_stages(self):
return self.env["pms.stage"].search([("is_default", "=", True)])
def _compute_property_count(self):
property_count = 0
property_obj = self.env["pms.property"]
for rec in self:
property_count = property_obj.search_count([("team_id", "=", rec.id)])
rec.property_count = property_count
name = fields.Char(required=True, translate=True)
description = fields.Text(translate=True)
color = fields.Integer("Color Index")
stage_ids = fields.Many2many("pms.stage", string="Stages", default=_default_stages)
property_ids = fields.One2many("pms.property", "team_id", string="Properties")
property_count = fields.Integer(
compute="_compute_property_count", string="Properties Count"
)
sequence = fields.Integer(
"Sequence", default=1, help="Used to sort teams. Lower is better."
)
company_id = fields.Many2one(
"res.company",
string="Company",
required=False,
index=True,
default=lambda self: self.env.user.company_id,
help="Company related to this team",
)
_sql_constraints = [("name_uniq", "unique (name)", "Team name already exists!")]

View File

@@ -1,15 +0,0 @@
# Copyright 2017 Alexandre Díaz
# Copyright 2017 Dario Lodeiros
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResCompany(models.Model):
_inherit = "res.company"
pms_uom = fields.Selection(
[("ft", "Square Foot"), ("m", "Square Meter")],
string="Unit of Measure",
default="m",
)

View File

@@ -1,39 +0,0 @@
# Copyright 2017 Alexandre Díaz
# Copyright 2017 Dario Lodeiros
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
# Groups
group_pms_show_amenity = fields.Boolean(
string="Show Amenities", implied_group="pms_base.group_pms_show_amenity"
)
group_pms_show_room = fields.Boolean(
string="Show Rooms", implied_group="pms_base.group_pms_show_room"
)
group_pms_show_service = fields.Boolean(
string="Show Services", implied_group="pms_base.group_pms_show_service"
)
group_pms_show_team = fields.Boolean(
string="Show Teams", implied_group="pms_base.group_pms_show_team"
)
# Modules
module_pms_account = fields.Boolean(string="Manage Accounting")
module_pms_account_asset = fields.Boolean(string="Manage Assets")
module_pms_contract = fields.Boolean(string="Manage Contracts")
module_pms_crm = fields.Boolean(string="Link a property to a lead")
module_pms_sale = fields.Boolean(string="Manage Reservations")
module_pms_website = fields.Boolean(string="Publish properties")
module_pms_website_sale = fields.Boolean(string="Allow online booking")
module_connector_guesty = fields.Boolean(string="Connect with Guesty")
module_connector_wubook = fields.Boolean(string="Connect with Wubook")
# Companies
pms_uom = fields.Selection(
string="Unit of Measure", related="company_id.pms_uom", readonly=False
)

View File

@@ -1,9 +0,0 @@
# Copyright (c) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResPartner(models.Model):
_inherit = "res.partner"
is_property = fields.Boolean(string="Is a Property")