[FIX] timedelta use

This commit is contained in:
Darío Lodeiros
2022-09-15 16:40:49 +02:00
parent c0cba08936
commit 5aa9fbc7d3
5 changed files with 15 additions and 5 deletions

View File

@@ -952,7 +952,7 @@ class PmsCheckinPartner(models.Model):
)[self.id]
self.reservation_id.message_post(body=body)
if self.reservation_id.to_send_mail:
if self.reservation_id.to_send_exit_mail:
emails = self.reservation_id.checkin_partner_ids.mapped("email")
if (
self.reservation_id.partner_id
@@ -972,4 +972,4 @@ class PmsCheckinPartner(models.Model):
"body_html", [6, 0, self.id], compute_lang=True, post_process=True
)[self.id]
self.reservation_id.message_post(body=body)
self.reservation_id.to_send_mail = False
self.reservation_id.to_send_exit_mail = False

View File

@@ -1391,7 +1391,7 @@ class PmsFolio(models.Model):
record.days_to_checkin = (record.first_checkin - fields.Date.today()).days
def _search_days_to_checkin(self, operator, value):
target_date = fields.Date.today() + timedelta(days=value)
target_date = fields.Date.today() + datetime.timedelta(days=value)
if operator in ("=", ">=", ">", "<=", "<"):
return [("first_checkin", operator, target_date)]
raise UserError(
@@ -1410,7 +1410,7 @@ class PmsFolio(models.Model):
record.days_to_checkout = (record.last_checkout - fields.Date.today()).days
def _search_days_to_checkout(self, operator, value):
target_date = fields.Date.today() + timedelta(days=value)
target_date = fields.Date.today() + datetime.timedelta(days=value)
if operator in ("=", ">=", ">", "<=", "<"):
return [("last_checkout", operator, target_date)]
raise UserError(

View File

@@ -497,6 +497,12 @@ class PmsReservationLine(models.Model):
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get("reservation_id") and not vals.get("sale_channel_id"):
reservation = self.env["pms.reservation"].browse(
vals.get("reservation_id")
)
vals["sale_channel_id"] = reservation.sale_channel_origin_id.id
records = super().create(vals_list)
for line in records:
reservation = line.reservation_id

View File

@@ -38,5 +38,6 @@ from . import test_pms_wizard_split_join_swap_reservation
from . import test_product_template
from . import test_pms_multiproperty
from . import test_shared_room
# from . import test_automated_mails
from . import test_pms_service

View File

@@ -455,7 +455,10 @@
name="force_update_origin"
attrs="{'invisible': [('is_origin_channel_check_visible','=',False)]}"
/>
<field name="is_origin_channel_check_visible" invisible="1" />
<field
name="is_origin_channel_check_visible"
invisible="1"
/>
<field
name="sale_channel_ids"
widget="many2many_tags"