mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
@@ -11,13 +11,15 @@ class PortalAccount(PortalAccount):
|
|||||||
values = super(PortalAccount, self)._invoice_get_page_view_values(
|
values = super(PortalAccount, self)._invoice_get_page_view_values(
|
||||||
invoice, access_token, **kwargs
|
invoice, access_token, **kwargs
|
||||||
)
|
)
|
||||||
for acquirer in values["acquirers"]:
|
acquirers = values.get("acquirers")
|
||||||
|
for acquirer in acquirers:
|
||||||
if (
|
if (
|
||||||
acquirer.pms_property_ids
|
acquirer.pms_property_ids
|
||||||
and invoice.pms_property_id.id not in acquirer.pms_property_ids.ids
|
and invoice.pms_property_id.id not in acquirer.pms_property_ids.ids
|
||||||
):
|
):
|
||||||
values["acquirers"] -= acquirer
|
values["acquirers"] -= acquirer
|
||||||
for pms in values["pms"]:
|
payment_tokens = values.get("payment_tokens")
|
||||||
|
for pms in payment_tokens:
|
||||||
if pms.acquirer_id not in values["acquirers"].ids:
|
if pms.acquirer_id not in values["acquirers"].ids:
|
||||||
values["pms"] -= pms
|
values["pms"] -= pms
|
||||||
return values
|
return values
|
||||||
|
|||||||
@@ -982,31 +982,30 @@ class PmsFolio(models.Model):
|
|||||||
automatic_included=True
|
automatic_included=True
|
||||||
)
|
)
|
||||||
paid_out = 0
|
paid_out = 0
|
||||||
for journal in journals:
|
paid_out += sum(
|
||||||
paid_out += sum(
|
self.env["account.move.line"]
|
||||||
self.env["account.move.line"]
|
.search(
|
||||||
.search(
|
[
|
||||||
[
|
("folio_ids", "in", record.id),
|
||||||
("folio_ids", "in", record.id),
|
(
|
||||||
(
|
"account_id",
|
||||||
"account_id",
|
"in",
|
||||||
"in",
|
tuple(
|
||||||
tuple(
|
journals.default_account_id.ids
|
||||||
journal.default_account_id.ids
|
+ journals.payment_debit_account_id.ids
|
||||||
+ journal.payment_debit_account_id.ids
|
+ journals.payment_credit_account_id.ids
|
||||||
+ journal.payment_credit_account_id.ids
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
(
|
),
|
||||||
"display_type",
|
(
|
||||||
"not in",
|
"display_type",
|
||||||
("line_section", "line_note"),
|
"not in",
|
||||||
),
|
("line_section", "line_note"),
|
||||||
("move_id.state", "!=", "cancel"),
|
),
|
||||||
]
|
("move_id.state", "!=", "cancel"),
|
||||||
)
|
]
|
||||||
.mapped("balance")
|
|
||||||
)
|
)
|
||||||
|
.mapped("balance")
|
||||||
|
)
|
||||||
total = record.amount_total
|
total = record.amount_total
|
||||||
# REVIEW: Must We ignored services in cancelled folios
|
# REVIEW: Must We ignored services in cancelled folios
|
||||||
# pending amount?
|
# pending amount?
|
||||||
@@ -1641,9 +1640,13 @@ class PmsFolio(models.Model):
|
|||||||
(making sure to call super() to establish a clean extension chain).
|
(making sure to call super() to establish a clean extension chain).
|
||||||
"""
|
"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|
||||||
journal = (
|
journal = (
|
||||||
self.env["account.move"]
|
self.env["account.move"]
|
||||||
.with_context(default_move_type="out_invoice")
|
.with_context(
|
||||||
|
default_move_type="out_invoice",
|
||||||
|
default_company_id=self.company_id.id,
|
||||||
|
)
|
||||||
._get_default_journal()
|
._get_default_journal()
|
||||||
)
|
)
|
||||||
if not journal:
|
if not journal:
|
||||||
|
|||||||
@@ -490,3 +490,58 @@ class PmsProperty(models.Model):
|
|||||||
vals.update({"checkin_sequence_id": checkin_sequence.id})
|
vals.update({"checkin_sequence_id": checkin_sequence.id})
|
||||||
record = super(PmsProperty, self).create(vals)
|
record = super(PmsProperty, self).create(vals)
|
||||||
return record
|
return record
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def daily_closing(
|
||||||
|
self, pms_property_ids, room_type_ids=False, availability_plan_ids=False
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
This method is used to close the daily availability of rooms
|
||||||
|
"""
|
||||||
|
pms_properties = self.browse(pms_property_ids)
|
||||||
|
for pms_property in pms_properties:
|
||||||
|
if not room_type_ids:
|
||||||
|
room_type_ids = self.env["pms.room.type"].search(
|
||||||
|
[
|
||||||
|
"|",
|
||||||
|
("pms_property_id", "=", pms_property.id),
|
||||||
|
("pms_property_id", "=", False),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
if not availability_plan_ids:
|
||||||
|
availability_plan_ids = self.env["pms.availability.plan"].search(
|
||||||
|
[
|
||||||
|
"|",
|
||||||
|
("pms_property_id", "=", pms_property.id),
|
||||||
|
("pms_property_id", "=", False),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
for room_type in self.env["pms.room.type"].browse(room_type_ids):
|
||||||
|
for availability_plan in self.env["pms.availability.plan"].browse(
|
||||||
|
availability_plan_ids
|
||||||
|
):
|
||||||
|
rule = self.env["pms.availability.plan.rule"].search(
|
||||||
|
[
|
||||||
|
("pms_property_id", "=", pms_property.id),
|
||||||
|
("room_type_id", "=", room_type.id),
|
||||||
|
("availability_plan_id", "=", availability_plan.id),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
if not rule:
|
||||||
|
rule = self.env["pms.availability.plan.rule"].create(
|
||||||
|
{
|
||||||
|
"pms_property_id": pms_property.id,
|
||||||
|
"room_type_id": room_type.id,
|
||||||
|
"availability_plan_id": availability_plan.id,
|
||||||
|
"date": fields.date.today(),
|
||||||
|
"closed": True,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
elif not rule.closed:
|
||||||
|
rule.write(
|
||||||
|
{
|
||||||
|
"closed": True,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|||||||
@@ -248,7 +248,9 @@ class PmsReservationLine(models.Model):
|
|||||||
):
|
):
|
||||||
if self.env.context.get("force_overbooking"):
|
if self.env.context.get("force_overbooking"):
|
||||||
reservation.overbooking = True
|
reservation.overbooking = True
|
||||||
line.room_id = reservation.room_type_id.room_ids[0]
|
line.room_id = reservation.room_type_id.room_ids.filtered(
|
||||||
|
lambda r: r.pms_property_id == line.pms_property_id
|
||||||
|
)[0]
|
||||||
else:
|
else:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_("%s: No room type available")
|
_("%s: No room type available")
|
||||||
|
|||||||
@@ -380,6 +380,7 @@ class AvailabilityWizard(models.TransientModel):
|
|||||||
def _rules_to_overwrite_by_plans(self, availability_plans):
|
def _rules_to_overwrite_by_plans(self, availability_plans):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
domain = [
|
domain = [
|
||||||
|
("pms_property_id", "in", self.pms_property_ids.ids),
|
||||||
("availability_plan_id", "in", availability_plans.ids),
|
("availability_plan_id", "in", availability_plans.ids),
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -806,7 +807,9 @@ class AvailabilityWizard(models.TransientModel):
|
|||||||
"date"
|
"date"
|
||||||
) and room_type in rules_to_overwrite.mapped("room_type_id"):
|
) and room_type in rules_to_overwrite.mapped("room_type_id"):
|
||||||
overwrite = rules_to_overwrite.filtered(
|
overwrite = rules_to_overwrite.filtered(
|
||||||
lambda x: x.room_type_id == room_type and x.date == date
|
lambda x: x.room_type_id == room_type
|
||||||
|
and x.date == date
|
||||||
|
and x.pms_property_id.id == pms_property.id
|
||||||
)
|
)
|
||||||
overwrite.write(vals)
|
overwrite.write(vals)
|
||||||
new_items += overwrite.ids
|
new_items += overwrite.ids
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import datetime
|
|||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
from datetime import date
|
|
||||||
|
|
||||||
import PyPDF2
|
import PyPDF2
|
||||||
import requests
|
import requests
|
||||||
@@ -21,12 +20,19 @@ class TravellerReport(models.TransientModel):
|
|||||||
txt_filename = fields.Text()
|
txt_filename = fields.Text()
|
||||||
txt_binary = fields.Binary(string="File Download")
|
txt_binary = fields.Binary(string="File Download")
|
||||||
txt_message = fields.Char(string="File Preview")
|
txt_message = fields.Char(string="File Preview")
|
||||||
|
date_target = fields.Date(
|
||||||
|
string="Date", required=True, default=lambda self: fields.Date.today()
|
||||||
|
)
|
||||||
|
pms_property_id = fields.Many2one(
|
||||||
|
comodel_name="pms.property",
|
||||||
|
string="Property",
|
||||||
|
required=True,
|
||||||
|
default=lambda self: self.env.user.get_active_property_ids()[0],
|
||||||
|
)
|
||||||
|
|
||||||
def generate_file_from_user_action(self):
|
def generate_file_from_user_action(self):
|
||||||
|
|
||||||
# get the active property
|
|
||||||
pms_property = self.env["pms.property"].search(
|
pms_property = self.env["pms.property"].search(
|
||||||
[("id", "=", self.env.user.get_active_property_ids()[0])]
|
[("id", "=", self.pms_property_id.id)]
|
||||||
)
|
)
|
||||||
# check if there's institution settings properly established
|
# check if there's institution settings properly established
|
||||||
if (
|
if (
|
||||||
@@ -40,7 +46,10 @@ class TravellerReport(models.TransientModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# build content
|
# build content
|
||||||
content = self.generate_checkin_list(pms_property.id)
|
content = self.generate_checkin_list(
|
||||||
|
property_id=pms_property.id,
|
||||||
|
date_target=self.date_target,
|
||||||
|
)
|
||||||
|
|
||||||
if content:
|
if content:
|
||||||
txt_binary = self.env["traveller.report.wizard"].create(
|
txt_binary = self.env["traveller.report.wizard"].create(
|
||||||
@@ -61,25 +70,29 @@ class TravellerReport(models.TransientModel):
|
|||||||
"view_type": "form",
|
"view_type": "form",
|
||||||
}
|
}
|
||||||
|
|
||||||
def generate_checkin_list(self, property_id):
|
def generate_checkin_list(self, property_id, date_target=False):
|
||||||
|
if not date_target:
|
||||||
|
date_target = fields.date.today()
|
||||||
# check if there's guests info pending to send
|
# check if there's guests info pending to send
|
||||||
if self.env["pms.checkin.partner"].search_count(
|
if self.env["pms.checkin.partner"].search_count(
|
||||||
[
|
[
|
||||||
("state", "=", "onboard"),
|
("state", "=", "onboard"),
|
||||||
("arrival", ">=", str(date.today()) + " 0:00:00"),
|
("arrival", ">=", str(date_target) + " 0:00:00"),
|
||||||
|
("pms_property_id", "=", property_id),
|
||||||
]
|
]
|
||||||
):
|
):
|
||||||
|
pms_property = (
|
||||||
# get the active property
|
self.env["pms.property"]
|
||||||
pms_property = self.env["pms.property"].search([("id", "=", property_id)])
|
.with_context(lang="es_ES")
|
||||||
|
.search([("id", "=", property_id)])
|
||||||
|
)
|
||||||
# get checkin partners info to send
|
# get checkin partners info to send
|
||||||
lines = self.env["pms.checkin.partner"].search(
|
lines = self.env["pms.checkin.partner"].search(
|
||||||
[
|
[
|
||||||
("state", "=", "onboard"),
|
("state", "=", "onboard"),
|
||||||
("arrival", ">=", str(date.today()) + " 0:00:00"),
|
("arrival", ">=", str(date_target) + " 0:00:00"),
|
||||||
("arrival", "<=", str(date.today()) + " 23:59:59"),
|
("arrival", "<=", str(date_target) + " 23:59:59"),
|
||||||
("pms_property_id", "=", pms_property.id),
|
("pms_property_id", "=", property_id),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
# build the property info record
|
# build the property info record
|
||||||
@@ -98,7 +111,7 @@ class TravellerReport(models.TransientModel):
|
|||||||
# build each checkin partner line's record
|
# build each checkin partner line's record
|
||||||
# 2|DNI nº|Doc.number|doc.type|exp.date|lastname|lastname2|name|...
|
# 2|DNI nº|Doc.number|doc.type|exp.date|lastname|lastname2|name|...
|
||||||
# ...gender|birthdate|nation.|checkin
|
# ...gender|birthdate|nation.|checkin
|
||||||
|
lines = lines.with_context(lang="es_ES")
|
||||||
for line in lines:
|
for line in lines:
|
||||||
content += "2"
|
content += "2"
|
||||||
# [P|N|..]
|
# [P|N|..]
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
<field name="txt_filename" invisible="1" />
|
<field name="txt_filename" invisible="1" />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
<group>
|
||||||
|
<field name="pms_property_id" />
|
||||||
|
<field name="date_target" />
|
||||||
|
</group>
|
||||||
<group attrs="{'invisible': [('txt_message','=',False)]}">
|
<group attrs="{'invisible': [('txt_message','=',False)]}">
|
||||||
<field name="txt_message" readonly="1" />
|
<field name="txt_message" readonly="1" />
|
||||||
</group>
|
</group>
|
||||||
|
|||||||
Reference in New Issue
Block a user