mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: payment folio date
This commit is contained in:
@@ -2,12 +2,14 @@
|
|||||||
# Copyright 2017 Dario Lodeiros
|
# Copyright 2017 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import AccessError, UserError, ValidationError
|
from odoo.exceptions import AccessError, UserError, ValidationError
|
||||||
from odoo.tools import float_compare, float_is_zero
|
from odoo.tools import float_compare, float_is_zero
|
||||||
|
from odoo.tools.misc import get_lang
|
||||||
|
|
||||||
from odoo.addons.base.models.ir_mail_server import MailDeliveryException
|
from odoo.addons.base.models.ir_mail_server import MailDeliveryException
|
||||||
|
|
||||||
@@ -1833,17 +1835,15 @@ class PmsFolio(models.Model):
|
|||||||
if len(property_folio_id) != 1:
|
if len(property_folio_id) != 1:
|
||||||
raise ValidationError(_("Only can payment by property"))
|
raise ValidationError(_("Only can payment by property"))
|
||||||
ctx = dict(self.env.context, company_id=folios[0].company_id.id)
|
ctx = dict(self.env.context, company_id=folios[0].company_id.id)
|
||||||
statement = (
|
if not date:
|
||||||
self.env["account.bank.statement"]
|
date = fields.Date.today()
|
||||||
.sudo()
|
domain = [
|
||||||
.search(
|
("journal_id", "=", journal.id),
|
||||||
[
|
("pms_property_id", "=", property_folio_id[0]),
|
||||||
("journal_id", "=", journal.id),
|
("state", "=", "open"),
|
||||||
("pms_property_id", "=", property_folio_id[0]),
|
("date", "=", date),
|
||||||
("state", "=", "open"),
|
]
|
||||||
]
|
statement = self.env["account.bank.statement"].sudo().search(domain, limit=1)
|
||||||
)
|
|
||||||
)
|
|
||||||
reservation_ids = reservations.ids if reservations else []
|
reservation_ids = reservations.ids if reservations else []
|
||||||
service_ids = services.ids if services else []
|
service_ids = services.ids if services else []
|
||||||
if not statement:
|
if not statement:
|
||||||
@@ -1852,7 +1852,9 @@ class PmsFolio(models.Model):
|
|||||||
"journal_id": journal.id,
|
"journal_id": journal.id,
|
||||||
"user_id": self.env.user.id,
|
"user_id": self.env.user.id,
|
||||||
"pms_property_id": property_folio_id[0],
|
"pms_property_id": property_folio_id[0],
|
||||||
"name": str(fields.Datetime.now()),
|
"name": datetime.datetime.today().strftime(
|
||||||
|
get_lang(self.env).date_format
|
||||||
|
),
|
||||||
}
|
}
|
||||||
statement = (
|
statement = (
|
||||||
self.env["account.bank.statement"]
|
self.env["account.bank.statement"]
|
||||||
|
|||||||
@@ -261,19 +261,17 @@ class ReservationSplitJoinSwapWizard(models.TransientModel):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def reservations_swap(self, checkin, checkout, source, target):
|
def reservations_swap(self, checkin, checkout, source, target):
|
||||||
reservations = self.env["pms.reservation"].search(
|
dates = [
|
||||||
[("checkin", ">=", checkin), ("checkout", "<=", checkout)]
|
checkin + datetime.timedelta(days=x)
|
||||||
)
|
for x in range(0, (checkout - checkin).days + 1)
|
||||||
|
]
|
||||||
lines = self.env["pms.reservation.line"].search_count(
|
lines = self.env["pms.reservation.line"].search_count(
|
||||||
[("room_id", "=", source), ("reservation_id", "in", reservations.ids)]
|
[("room_id", "=", source), ("date", "in", dates)]
|
||||||
)
|
)
|
||||||
if not lines:
|
if not lines:
|
||||||
raise UserError(_("There's no reservations lines with provided room"))
|
raise UserError(_("There's no reservations lines with provided room"))
|
||||||
|
|
||||||
for date_iterator in [
|
for date_iterator in dates:
|
||||||
checkin + datetime.timedelta(days=x)
|
|
||||||
for x in range(0, (checkout - checkin).days)
|
|
||||||
]:
|
|
||||||
line_room_source = self.env["pms.reservation.line"].search(
|
line_room_source = self.env["pms.reservation.line"].search(
|
||||||
[("date", "=", date_iterator), ("room_id", "=", source)]
|
[("date", "=", date_iterator), ("room_id", "=", source)]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user