[IMP]pms: added compute_to_send_mail && delete compute_date_order

This commit is contained in:
braisab
2021-12-15 21:34:40 +01:00
parent 5cd69c498c
commit 7f102d6936
3 changed files with 15 additions and 11 deletions

View File

@@ -4,7 +4,7 @@
{
"name": "PMS (Property Management System)",
"summary": "A property management system",
"version": "14.0.2.23.0",
"version": "14.0.2.22.1",
"development_status": "Alpha",
"category": "Generic Modules/Property Management System",
"website": "https://github.com/OCA/pms",

View File

@@ -3,7 +3,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from datetime import datetime
from itertools import groupby
from odoo import _, api, fields, models
@@ -1091,12 +1090,6 @@ class PmsFolio(models.Model):
checkouts = record.reservation_ids.mapped("checkout")
record.last_checkout = max(checkouts)
@api.depends("create_date")
def _compute_date_creation(self):
for record in self:
if record.create_date:
record.date_creation = datetime.strftime(record.create_date, "%Y-%m-%d")
def _search_invoice_ids(self, operator, value):
if operator == "in" and value:
self.env.cr.execute(
@@ -1297,7 +1290,6 @@ class PmsFolio(models.Model):
def send_confirmation_mail(self):
folios = self.env["pms.folio"].search(
[
("reservation_type", "!=", "out"),
("pms_property_id.is_confirmed_auto_mail", "=", True),
("reservation_ids.to_send_mail", "=", True),
("reservation_ids.is_modified_reservation", "=", False),
@@ -1350,7 +1342,6 @@ class PmsFolio(models.Model):
def send_modification_mail(self):
folios = self.env["pms.folio"].search(
[
("reservation_type", "!=", "out"),
("pms_property_id.is_modified_auto_mail", "=", True),
("reservation_ids.to_send_mail", "=", True),
("reservation_ids.is_modified_reservation", "=", True),

View File

@@ -643,7 +643,12 @@ class PmsReservation(models.Model):
comodel_name="res.partner",
inverse_name="reservation_possible_customer_id",
)
to_send_mail = fields.Boolean(string="Mail Sent", default=True)
to_send_mail = fields.Boolean(
string="Mail Sent",
compute="_compute_to_send_mail",
readonly=False,
store=True,
)
is_modified_reservation = fields.Boolean(
string="Is A Modified Reservation",
@@ -1484,6 +1489,14 @@ class PmsReservation(models.Model):
else:
record.lang = self.env["res.lang"].get_installed()
@api.depends("reservation_type")
def _compute_to_send_mail(self):
for record in self:
if record.reservation_type == "out":
record.to_send_mail = False
else:
record.to_send_mail = True
def _search_allowed_checkin(self, operator, value):
if operator not in ("=",):
raise UserError(