Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pms/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

================================
PMS (Property Management System)
================================
Expand All @@ -17,7 +13,7 @@ PMS (Property Management System)
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |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
Expand Down
1 change: 0 additions & 1 deletion pms/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"sales_team",
"multi_pms_properties",
"partner_firstname",
"partner_second_lastname",
"partner_contact_gender",
"partner_contact_birthdate",
"partner_contact_nationality",
Expand Down
93 changes: 49 additions & 44 deletions pms/models/pms_checkin_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,21 @@ class PmsCheckinPartner(models.Model):
readonly=False,
store=True,
compute="_compute_email",
inverse=lambda r: r._inverse_partner_fields("email", "email"),
)
mobile = fields.Char(
help="Checkin Partner Mobile",
readonly=False,
store=True,
compute="_compute_mobile",
inverse=lambda r: r._inverse_partner_fields("mobile", "mobile"),
)
phone = fields.Char(
help="Checkin Partner Phone",
readonly=False,
store=True,
compute="_compute_phone",
inverse=lambda r: r._inverse_partner_fields("phone", "phone"),
)
image_128 = fields.Image(
string="Image",
Expand Down Expand Up @@ -130,6 +133,7 @@ class PmsCheckinPartner(models.Model):
store=True,
compute="_compute_gender",
selection=[("male", "Male"), ("female", "Female"), ("other", "Other")],
inverse=lambda r: r._inverse_partner_fields("gender", "gender"),
)
nationality_id = fields.Many2one(
string="Nationality",
Expand All @@ -139,6 +143,7 @@ class PmsCheckinPartner(models.Model):
index=True,
compute="_compute_nationality_id",
comodel_name="res.country",
inverse=lambda r: r._inverse_partner_fields("nationality_id", "nationality_id"),
)
residence_street = fields.Char(
string="Street",
Expand Down Expand Up @@ -194,27 +199,23 @@ class PmsCheckinPartner(models.Model):
readonly=False,
store=True,
compute="_compute_firstname",
inverse=lambda r: r._inverse_partner_fields("firstname", "firstname"),
)
lastname = fields.Char(
string="Last Name",
help="host lastname",
readonly=False,
store=True,
compute="_compute_lastname",
)
lastname2 = fields.Char(
string="Second Last Name",
help="host second lastname",
readonly=False,
store=True,
compute="_compute_lastname2",
inverse=lambda r: r._inverse_partner_fields("lastname", "lastname"),
)
birthdate_date = fields.Date(
string="Birthdate",
help="host birthdate",
readonly=False,
store=True,
compute="_compute_birth_date",
inverse=lambda r: r._inverse_partner_fields("birthdate_date", "birthdate_date"),
)
document_number = fields.Char(
help="Host document number",
Expand Down Expand Up @@ -285,6 +286,11 @@ class PmsCheckinPartner(models.Model):
compute="_compute_sign_on",
)

def _inverse_partner_fields(self, checkin_field_name, partner_field_name):
for record in self:
if record.partner_id:
record.partner_id[partner_field_name] = record[checkin_field_name]

@api.depends("partner_id")
def _compute_document_number(self):
for record in self:
Expand Down Expand Up @@ -345,14 +351,6 @@ def _compute_lastname(self):
elif not record.lastname:
record.lastname = False

@api.depends("partner_id")
def _compute_lastname2(self):
for record in self:
if not record.lastname2 and record.partner_id.lastname2:
record.lastname2 = record.partner_id.lastname2
elif not record.lastname2:
record.lastname2 = False

@api.depends("partner_id")
def _compute_birth_date(self):
for record in self:
Expand Down Expand Up @@ -520,13 +518,26 @@ def get_document_vals(self):
"country_id": self.document_country_id.id,
}

@api.depends(
"document_number",
"document_type",
"firstname",
"lastname",
"lastname2",
)
@api.model
def _get_compute_partner_id_field_names(self):
return ["document_number", "document_type", "firstname", "lastname"]

def _completed_partner_creation_fields(self):
self.ensure_one()
if self.firstname or self.lastname:
return True
return False

def _get_partner_create_vals(self):
return {
"firstname": self.firstname,
"lastname": self.lastname,
"gender": self.gender,
"birthdate_date": self.birthdate_date,
"nationality_id": self.nationality_id.id,
}

@api.depends(lambda self: self._get_compute_partner_id_field_names())
def _compute_partner_id(self):
for record in self:
if not record.partner_id:
Expand All @@ -535,15 +546,8 @@ def _compute_partner_id(self):
record.document_number, record.document_type
)
if not partner:
if record.firstname or record.lastname or record.lastname2:
partner_values = {
"firstname": record.firstname,
"lastname": record.lastname,
"lastname2": record.lastname2,
"gender": record.gender,
"birthdate_date": record.birthdate_date,
"nationality_id": record.nationality_id.id,
}
if self._completed_partner_creation_fields():
partner_values = self._get_partner_create_vals()
partner = (
self.env["res.partner"]
.with_context(avoid_document_restriction=True)
Expand Down Expand Up @@ -578,17 +582,20 @@ def _compute_possible_existing_customer_ids(self):
else:
record.possible_existing_customer_ids = False

@api.depends(
"firstname",
"lastname",
"lastname2",
"gender",
"birthdate_date",
"nationality_id",
"email",
"mobile",
"partner_id",
)
@api.model
def _get_partner_incongruences_field_names(self):
return [
"firstname",
"lastname",
"gender",
"birthdate_date",
"nationality_id",
"email",
"mobile",
"partner_id",
]

@api.depends(lambda self: self._get_partner_incongruences_field_names())
def _compute_partner_incongruences(self):
for record in self:
incongruous_fields = False
Expand Down Expand Up @@ -803,7 +810,6 @@ def _checkin_manual_fields(self, country=False):
"gender",
"firstname",
"lastname",
"lastname2",
"birthdate_date",
"document_number",
"document_expedition_date",
Expand Down Expand Up @@ -837,7 +843,6 @@ def _checkin_partner_fields(self):
checkin_fields = [
"firstname",
"lastname",
"lastname2",
"mobile",
"email",
"gender",
Expand Down
8 changes: 4 additions & 4 deletions pms/models/pms_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ def _compute_reservation_line_ids(self):
reservation.reservation_line_ids = False
reservation.check_in_out_dates()

@api.depends("board_service_room_id")
@api.depends("board_service_room_id", "adults", "children")
def _compute_board_service_ids(self):
if self.env.context.get("skip_compute_board_service_ids", False):
return
Expand Down Expand Up @@ -2185,10 +2185,10 @@ def _check_clousure_reason(self, reservation_type, closure_reason_id):
)

def _check_services(self, vals):
# If we create a reservation with board service and other service at the
# same time, compute_service_ids dont run (compute with readonly to False), and
# If we create a reservation with board service, compute_service_ids dont run
# (compute with readonly to False), and
# we must force it to compute the services linked with the board service:
if "board_service_room_id" in vals and "service_ids" in vals:
if "board_service_room_id" in vals:
self._compute_board_service_ids()

def get_folios_to_update_channel(self, vals):
Expand Down
2 changes: 1 addition & 1 deletion pms/models/pms_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def _compute_address_id(self):
"type": "other",
"is_company": False,
"active": True,
"parent_id": record.pms_property_id.id,
"parent_id": record.pms_property_id.partner_id.id,
}
)
)
Expand Down
Loading