Merge PR #115 into 14.0

Signed-off-by DarioLodeiros
This commit is contained in:
OCA-git-bot
2022-02-12 08:08:01 +00:00
6 changed files with 1143 additions and 1641 deletions

View File

@@ -6,6 +6,7 @@ from odoo.http import request
from odoo.addons.payment.controllers.portal import PaymentProcessing from odoo.addons.payment.controllers.portal import PaymentProcessing
from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager
from odoo.addons.portal.models.portal_mixin import PortalMixin
class PortalFolio(CustomerPortal): class PortalFolio(CustomerPortal):
@@ -182,38 +183,6 @@ class PortalFolio(CustomerPortal):
values = self._folio_get_page_view_values(folio_sudo, access_token, **kw) values = self._folio_get_page_view_values(folio_sudo, access_token, **kw)
return request.render("pms.folio_portal_template", values) return request.render("pms.folio_portal_template", values)
@http.route(
["/my/folios/<int:folio_id>/precheckin"],
type="http",
auth="public",
website=True,
)
def portal_my_folio_precheckin(
self, folio_id, access_token=None, report_type=None, download=False, **kw
):
values = self._prepare_portal_layout_values()
try:
folio_sudo = self._document_check_access(
"pms.folio",
folio_id,
access_token=access_token,
)
except (AccessError, MissingError):
return request.redirect("/my")
values.update(self._folio_get_page_view_values(folio_sudo, access_token, **kw))
values.update({"no_breadcrumbs": True, "error": {}})
country_ids = request.env["res.country"].search([])
state_ids = request.env["res.country.state"].search([])
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
values.update(
{
"country_ids": country_ids,
"state_ids": state_ids,
"doc_type_ids": doc_type_ids,
}
)
return request.render("pms.portal_my_folio_precheckin", values)
class PortalReservation(CustomerPortal): class PortalReservation(CustomerPortal):
def _prepare_home_portal_values(self, counters): def _prepare_home_portal_values(self, counters):
@@ -316,41 +285,13 @@ class PortalReservation(CustomerPortal):
) )
return request.render("pms.portal_my_reservation_detail", values) return request.render("pms.portal_my_reservation_detail", values)
@http.route(
["/my/reservations/<int:reservation_id>/precheckin"],
type="http",
auth="public",
website=True,
)
def portal_my_reservation_precheckin(self, reservation_id, access_token=None, **kw):
try:
reservation_sudo = self._document_check_access(
"pms.reservation",
reservation_id,
access_token=access_token,
)
except (AccessError, MissingError):
return request.redirect("/my")
values = self._reservation_get_page_view_values(
reservation_sudo, access_token, **kw
)
values.update({"no_breadcrumbs": True, "error": {}})
country_ids = request.env["res.country"].search([])
state_ids = request.env["res.country.state"].search([])
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
values.update(
{
"country_ids": country_ids,
"state_ids": state_ids,
"doc_type_ids": doc_type_ids,
}
)
return request.render("pms.portal_my_reservation_precheckin", values)
class PortalPrecheckin(CustomerPortal): class PortalPrecheckin(CustomerPortal):
def _precheckin_get_page_view_values(self, checkin_partner, access_token, **kwargs): def _precheckin_get_page_view_values(
values = {"checkin_partner": checkin_partner, "token": access_token} self, checkin_partner_id, access_token, **kwargs
):
checkin_partner = request.env["pms.checkin.partner"].browse(checkin_partner_id)
values = {"checkin_partner_id": checkin_partner, "token": access_token}
return self._get_page_view_values( return self._get_page_view_values(
checkin_partner, checkin_partner,
access_token, access_token,
@@ -361,280 +302,187 @@ class PortalPrecheckin(CustomerPortal):
) )
@http.route( @http.route(
["/my/precheckin/<int:checkin_partner_id>"], ["/my/folios/<int:folio_id>/precheckin"],
type="http", type="http",
auth="public", auth="public",
website=True, website=True,
) )
def portal_my_precheckin_detail(self, checkin_partner_id, access_token=None, **kw): def portal_my_precheckin(
self,
folio_id,
access_token=None,
):
country_ids = request.env["res.country"].search([])
state_ids = request.env["res.country.state"].search([])
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
values = self._prepare_portal_layout_values()
try: try:
checkin_sudo = self._document_check_access( folio_sudo = self._document_check_access(
"pms.checkin.partner", "pms.folio",
checkin_partner_id, folio_id,
access_token=access_token, access_token=access_token,
) )
except (AccessError, MissingError): except (AccessError, MissingError):
return request.redirect("/my") return request.redirect("/my")
values = self._precheckin_get_page_view_values(checkin_sudo, access_token, **kw) checkin_partner = folio_sudo.checkin_partner_ids[0]
country_ids = request.env["res.country"].search([])
state_ids = request.env["res.country.state"].search([])
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
values.update( values.update(
{ {
"doc_type_ids": doc_type_ids,
"country_ids": country_ids,
"state_ids": state_ids,
"no_breadcrumbs": True, "no_breadcrumbs": True,
"error": {}, "error": {},
"country_ids": country_ids,
"state_ids": state_ids,
"doc_type_ids": doc_type_ids,
"folio": folio_sudo,
"checkin_partner_id": checkin_partner,
"checkin_pos": 0,
} }
) )
return request.render("pms.portal_my_precheckin_detail", values) if checkin_partner.state != "draft":
return request.render("pms.portal_not_checkin", values)
return request.render("pms.portal_my_reservation_precheckin", values)
@http.route( @http.route(
["/my/precheckin"], type="http", auth="public", website=True, csrf=False ["/my/precheckin/<int:folio_id>/checkin/<int:checkin_partner_id>"],
)
def portal_precheckin_submit(self, **kw):
values = dict()
checkin_partner = request.env["pms.checkin.partner"].browse(int(kw.get("id")))
values.update(
{
"checkin_partner": checkin_partner,
"error": {},
"error_message": {},
}
)
country_ids = request.env["res.country"].search([])
state_ids = request.env["res.country.state"].search([])
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
if kw:
error, error_message = self.form_validate(kw, None)
values.update(
{
"no_breadcrumbs": True,
"error": error,
"error_message": error_message,
"country_ids": country_ids,
"state_ids": state_ids,
"doc_type_ids": doc_type_ids,
}
)
if error:
return request.render("pms.portal_my_precheckin_detail", values)
else:
try:
values = kw
if values.get("document_type"):
doc_type = (
request.env["res.partner.id_category"]
.sudo()
.search([("name", "=", values.get("document_type"))])
)
values.update(
{
"document_type": doc_type.id,
}
)
request.env["pms.checkin.partner"].sudo()._save_data_from_portal(
values
)
doc_type_ids = (
request.env["res.partner.id_category"].sudo().search([])
)
values.update(
{
"doc_type_ids": doc_type_ids,
}
)
country_ids = request.env["res.country"].search([])
state_ids = request.env["res.country.state"].search([])
values.update(
{
"country_ids": country_ids,
"state_ids": state_ids,
}
)
values.update(
{
"success": True,
"checkin_partner": checkin_partner,
"no_breadcrumbs": True,
"error": {},
}
)
return request.render("pms.portal_my_precheckin_detail", values)
except (AccessError, MissingError):
return request.redirect("/my")
@http.route(
["/my/precheckin/folio_reservation"],
type="http", type="http",
auth="public", auth="public",
website=True, website=True,
csrf=False, csrf=False,
) )
def portal_precheckin_folio_submit(self, **kw): def portal_precheckin_submit(self, folio_id, checkin_partner_id, **kw):
errors = {} error, error_message = {}, {}
e_messages = {} if kw.get("checkin_pos"):
counter = 1 checkin_pos = int(kw.get("checkin_pos"))
has_error = False else:
checkin_partners = False checkin_pos = -2
if kw.get("folio_id"): folio_id = request.env["pms.folio"].sudo().browse(folio_id)
folio = request.env["pms.folio"].sudo().browse(int(kw.get("folio_id")))
checkin_partners = folio.checkin_partner_ids
elif kw.get("reservation_id"):
reservation = (
request.env["pms.reservation"]
.sudo()
.browse(int(kw.get("reservation_id")))
)
checkin_partners = reservation.checkin_partner_ids
for checkin in checkin_partners:
values = {
"id": kw.get("id-" + str(counter)),
"firstname": kw.get("firstname-" + str(counter)),
"lastname": kw.get("lastname-" + str(counter)),
"lastname2": kw.get("lastname2-" + str(counter)),
"gender": kw.get("gender-" + str(counter)),
"birthdate_date": kw.get("birthdate_date-" + str(counter))
if kw.get("birthdate_date-" + str(counter))
else False,
"document_type": kw.get("document_type-" + str(counter)),
"document_number": kw.get("document_number-" + str(counter)),
"document_expedition_date": kw.get(
"document_expedition_date-" + str(counter)
)
if kw.get("document_expedition_date-" + str(counter))
else False,
"mobile": kw.get("mobile-" + str(counter)),
"email": kw.get("email-" + str(counter)),
"nationality_id": kw.get("nationality_id-" + str(counter)),
"state": kw.get("state-" + str(counter)),
}
if values.get("document_type"):
doc_type_code = values.get("document_type")
doc_type = (
request.env["res.partner.id_category"]
.sudo()
.search([("name", "=", doc_type_code)])
)
values.update(
{
"document_type": doc_type.id,
}
)
error, error_message = self.form_validate(kw, counter)
errors.update(error)
e_messages.update(error_message)
if error_message:
has_error = True
else:
checkin.sudo()._save_data_from_portal(values)
counter = counter + 1
values = {"no_breadcrumbs": True}
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
country_ids = request.env["res.country"].search([]) country_ids = request.env["res.country"].search([])
state_ids = request.env["res.country.state"].search([]) state_ids = request.env["res.country.state"].search([])
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
values = kw
if not kw.get("first") and kw.get("checkin_pos") and not kw.get("back"):
error, error_message = self.form_validate(kw, None)
if not kw.get("first") and not kw.get("back") and not error:
kw.update({"checkin_partner_id": checkin_partner_id})
request.env["pms.checkin.partner"]._save_data_from_portal(kw)
if error:
checkin_pos = checkin_pos - 1
values.update({"checkin_pos": checkin_pos})
if checkin_pos == len(folio_id.checkin_partner_ids):
values = {
"folio": folio_id,
"no_breadcrumbs": True,
}
return request.render("pms.portal_my_precheckin_end", values)
values.update( values.update(
{ {
"doc_type_ids": doc_type_ids, "folio": folio_id,
"error": error,
"error_message": error_message,
"country_ids": country_ids, "country_ids": country_ids,
"state_ids": state_ids, "state_ids": state_ids,
"doc_type_ids": doc_type_ids,
"checkin_pos": checkin_pos,
} }
) )
if has_error: if checkin_pos >= 0:
filtered_dict_error = {k: v for k, v in errors.items() if v} checkin_partner_id = folio_id.checkin_partner_ids[checkin_pos]
filtered_dict_error_messages = {k: v for k, v in e_messages.items() if v} elif checkin_pos == -2:
values.update( checkin_partner_id = request.env["pms.checkin.partner"].browse(
{ checkin_partner_id
"error": filtered_dict_error,
"error_message": filtered_dict_error_messages,
}
) )
else: elif checkin_pos == -1:
values.update({"success": True, "error": {}}) return
if kw.get("folio_id"): access_token = checkin_partner_id.access_token
folio = request.env["pms.folio"].sudo().browse(int(kw.get("folio_id"))) if not checkin_partner_id.access_token:
values.update( access_token = PortalMixin._portal_ensure_token(checkin_partner_id)
{ values.update(
"folio": folio, self._precheckin_get_page_view_values(checkin_partner_id.id, access_token)
} )
values.update({"no_breadcrumbs": True})
if checkin_partner_id.state != "draft":
return request.render("pms.portal_not_checkin", values)
return request.render("pms.portal_my_precheckin_detail", values)
@http.route(
["/my/folios/<int:folio_id>/invitations"],
type="http",
auth="public",
website=True,
csrf=False,
)
def portal_precheckin_invitation(self, folio_id, access_token=None, **kw):
try:
folio_sudo = self._document_check_access(
"pms.folio",
folio_id,
access_token=access_token,
) )
return request.render("pms.portal_my_folio_precheckin", values) except (AccessError, MissingError):
elif kw.get("reservation_id"): return request.redirect("/my")
reservation = request.env["pms.reservation"].browse( web_url = request.env["ir.config_parameter"].search(
int(kw.get("reservation_id")) [("key", "=", "web.base.url")]
) )
values.update( values = self._folio_get_page_view_values(folio_sudo, access_token, **kw)
{ values.update({"no_breadcrumbs": True, "error": {}, "web_url": web_url.value})
"reservation": reservation, return request.render("pms.portal_my_folio_invitations", values)
}
)
return request.render("pms.portal_my_reservation_precheckin", values)
def form_validate(self, data, counter): def form_validate(self, data, counter):
error, error_message = self.form_document_validate(data, counter) error, error_message = {}, {}
keys = data.keys() if data.get("checkin_pos") != "-1":
mobile = "mobile" if "mobile" in keys else "mobile-" + str(counter) error, error_message = self.form_document_validate(data, counter)
if data[mobile]: mobile = "mobile"
if not re.match( if data.get("mobile"):
r"^(\d{3}[\-\s]?\d{2}[\-\s]?\d{2}[\-\s]?\d{2}[\-\s]?|" if not re.match(
r"\d{3}[\-\s]?\d{3}[\-\s]?\d{3})$", r"^(\d{3}[\-\s]?\d{2}[\-\s]?\d{2}[\-\s]?\d{2}[\-\s]?|"
data[mobile], r"\d{3}[\-\s]?\d{3}[\-\s]?\d{3})$",
data[mobile],
):
error[mobile] = "error"
error_message[mobile] = "Invalid phone"
birthdate_date = "birthdate_date"
if data.get("birthdate_date") and data.get("birthdate_date") > str(
fields.Datetime.today()
): ):
error[mobile] = "error" error[birthdate_date] = "error"
error_message[mobile] = "Invalid phone" error_message[birthdate_date] = "Birthdate must be less than today"
birthdate_date = ( email = "email"
"birthdate_date" if data.get("email") and not tools.single_email_re.match(data.get("email")):
if "birthdate_date" in keys error[email] = "error"
else "birthdate_date-" + str(counter) error_message[email] = "Email format is wrong"
) firstname = "firstname"
if data[birthdate_date] and data[birthdate_date] > str(fields.Datetime.today()): if (
error[birthdate_date] = "error" not data.get("firstname")
error_message[birthdate_date] = "Birthdate must be less than today" and not data.get("lastname")
email = "email" if "email" in keys else "email-" + str(counter) and not data.get("lastname2")
if data[email] and not tools.single_email_re.match(data[email]): ):
error[email] = "error" error[firstname] = "error"
error_message[email] = "Email format is wrong" error_message[firstname] = "Firstname or any lastname are not included"
firstname = "firstname" if "firstname" in keys else "firstname-" + str(counter)
lastname = "lastname" if "lastname" in keys else "lastname-" + str(counter)
lastname2 = "lastname2" if "lastname2" in keys else "lastname2-" + str(counter)
if not data[firstname] and not data[lastname] and not data[lastname2]:
error[firstname] = "error"
error_message[firstname] = "Firstname or any lastname are not included"
return error, error_message return error, error_message
def form_document_validate(self, data, counter): def form_document_validate(self, data, counter):
error = dict() error = dict()
error_message = {} error_message = {}
keys = data.keys() data.keys()
document_number = ( document_number = "document_number"
"document_number" document_type = "document_type"
if "document_number" in keys document_expedition_date = "document_expedition_date"
else "document_number-" + str(counter) if data.get("document_expedition_date") and not data.get("document_number"):
)
document_type = (
"document_type"
if "document_type" in keys
else "document_type-" + str(counter)
)
document_expedition_date = (
"document_expedition_date"
if "document_expedition_date" in keys
else "document_expedition_date-" + str(counter)
)
if data[document_expedition_date] and not data[document_number]:
error[document_expedition_date] = "error" error[document_expedition_date] = "error"
error_message[ error_message[
document_expedition_date document_expedition_date
] = "Document Number not entered and Document Type is not selected" ] = "Document Number not entered and Document Type is not selected"
if data[document_number]: if data.get("document_number"):
if not data[document_type]: if not data[document_type]:
error[document_type] = "error" error[document_type] = "error"
error_message[document_type] = "Document Type is not selected" error_message[document_type] = "Document Type is not selected"
if data[document_type] == "D": if data[document_type] == "D":
if len(data[document_number]) == 9 or len(data[document_number]) == 10: if (
if not re.match(r"^\d{8}[ -]?[a-zA-Z]$", data[document_number]): len(data.get("document_number")) == 9
or len(data.get("document_number")) == 10
):
if not re.match(
r"^\d{8}[ -]?[a-zA-Z]$", data.get("document_number")
):
error[document_number] = "error" error[document_number] = "error"
error_message[document_number] = "The DNI format is wrong" error_message[document_number] = "The DNI format is wrong"
letters = { letters = {
@@ -662,9 +510,10 @@ class PortalPrecheckin(CustomerPortal):
21: "K", 21: "K",
22: "E", 22: "E",
} }
dni_number = data[document_number][0:8] dni_number = data.get("document_number")[0:8]
dni_letter = data[document_number][ dni_letter = data.get("document_number")[
len(data[document_number]) - 1 : len(data[document_number]) len(data.get("document_number"))
- 1 : len(data.get("document_number"))
] ]
if letters.get(int(dni_number) % 23) != dni_letter.upper(): if letters.get(int(dni_number) % 23) != dni_letter.upper():
error[document_number] = "error" error[document_number] = "error"
@@ -673,25 +522,25 @@ class PortalPrecheckin(CustomerPortal):
error[document_number] = "error" error[document_number] = "error"
error_message[document_number] = "DNI is invalid" error_message[document_number] = "DNI is invalid"
if data[document_type] == "C" and not re.match( if data[document_type] == "C" and not re.match(
r"^\d{8}[ -]?[a-zA-Z]$", data[document_number] r"^\d{8}[ -]?[a-zA-Z]$", data.get("document_number")
): ):
error[document_number] = "error" error[document_number] = "error"
error_message[document_number] = "The Driving License format is wrong" error_message[document_number] = "The Driving License format is wrong"
if data[document_type] == "N" and not re.match( if data[document_type] == "N" and not re.match(
r"^[X|Y]{1}[ -]?\d{7,8}[ -]?[a-zA-Z]$", data[document_number] r"^[X|Y]{1}[ -]?\d{7,8}[ -]?[a-zA-Z]$", data.get("document_number")
): ):
error[document_number] = "error" error[document_number] = "error"
error_message[ error_message[
document_number document_number
] = "The Spanish Residence Permit format is wrong" ] = "The Spanish Residence Permit format is wrong"
if data[document_type] == "X" and not re.match( if data[document_type] == "X" and not re.match(
r"^[X|Y]{1}[ -]?\d{7,8}[ -]?[a-zA-Z]$", data[document_number] r"^[X|Y]{1}[ -]?\d{7,8}[ -]?[a-zA-Z]$", data.get("document_number")
): ):
error[document_number] = "error" error[document_number] = "error"
error_message[ error_message[
document_number document_number
] = "The European Residence Permit format is wrong" ] = "The European Residence Permit format is wrong"
elif data[document_type]: elif data.get("document_type"):
error[document_number] = "error" error[document_number] = "error"
error_message[document_number] = "Document Number not entered" error_message[document_number] = "Document Number not entered"
return error, error_message return error, error_message

View File

@@ -29,7 +29,7 @@
<tr> <tr>
<td align="center"> <td align="center">
<a <a
href="/my/precheckin/${object.id}?access_token=${object.access_token}" href="${object.get_portal_url()}"
target="_blank" target="_blank"
style="text-decoration: none; color: #FFFFFF; font-size: 2em; padding: 10px 20px 10px 20px;" style="text-decoration: none; color: #FFFFFF; font-size: 2em; padding: 10px 20px 10px 20px;"
> >
@@ -42,7 +42,7 @@
alt="Hacer check-in" alt="Hacer check-in"
width="80px" width="80px"
height="80px" height="80px"
href="${object.url}" href="${object.get_portal_url()}"
/></center></a> /></center></a>
</td> </td>
</tr> </tr>

File diff suppressed because it is too large Load Diff

View File

@@ -467,7 +467,10 @@ class PmsCheckinPartner(models.Model):
def _compute_access_url(self): def _compute_access_url(self):
super(PmsCheckinPartner, self)._compute_access_url() super(PmsCheckinPartner, self)._compute_access_url()
for checkin in self: for checkin in self:
checkin.access_url = "/my/precheckin/%s" % (checkin.id) checkin.access_url = "/my/precheckin/%s/checkin/%s" % (
checkin.folio_id.id,
checkin.id,
)
# Constraints and onchanges # Constraints and onchanges
@@ -665,16 +668,14 @@ class PmsCheckinPartner(models.Model):
return datetime_doc_date return datetime_doc_date
datetime_birthdate = datetime.strptime(birthdate, DEFAULT_SERVER_DATE_FORMAT) datetime_birthdate = datetime.strptime(birthdate, DEFAULT_SERVER_DATE_FORMAT)
age = today.year - datetime_birthdate.year age = today.year - datetime_birthdate.year
document_type = self.env["res.partner.id_category"].search(
[("id", "=", doc_type)]
)
document_expedition_date = False document_expedition_date = False
if document_type.code == "D" or document_type.code == "P": if doc_type.code == "D" or doc_type.code == "P":
if age < 30: if age < 30:
document_expedition_date = datetime_doc_date - relativedelta(years=5) document_expedition_date = datetime_doc_date - relativedelta(years=5)
else: else:
document_expedition_date = datetime_doc_date - relativedelta(years=10) document_expedition_date = datetime_doc_date - relativedelta(years=10)
if document_type.code == "C": if doc_type.code == "C":
if age < 70: if age < 70:
document_expedition_date = datetime_doc_date - relativedelta(years=10) document_expedition_date = datetime_doc_date - relativedelta(years=10)
return document_expedition_date return document_expedition_date
@@ -736,7 +737,15 @@ class PmsCheckinPartner(models.Model):
} }
def _save_data_from_portal(self, values): def _save_data_from_portal(self, values):
checkin_partner = self.env["pms.checkin.partner"].browse(int(values.get("id"))) checkin_partner = self.env["pms.checkin.partner"].browse(
int(values.get("checkin_partner_id"))
)
if values.get("checkin_partner_id"):
values.pop("checkin_partner_id")
if values.get("checkin_pos"):
values.pop("checkin_pos")
if values.get("first"):
values.pop("first")
if values.get("nationality_id"): if values.get("nationality_id"):
nationality_id = self.env["res.country"].search( nationality_id = self.env["res.country"].search(
[("id", "=", values.get("nationality_id"))] [("id", "=", values.get("nationality_id"))]
@@ -754,6 +763,9 @@ class PmsCheckinPartner(models.Model):
values.pop("state") values.pop("state")
if values.get("document_expedition_date"): if values.get("document_expedition_date"):
doc_type = values.get("document_type") doc_type = values.get("document_type")
doc_type = self.env["res.partner.id_category"].search(
[("name", "=", doc_type)]
)
doc_date = values.get("document_expedition_date") doc_date = values.get("document_expedition_date")
birthdate = values.get("birthdate_date") birthdate = values.get("birthdate_date")
document_expedition_date = ( document_expedition_date = (
@@ -761,7 +773,13 @@ class PmsCheckinPartner(models.Model):
doc_type, doc_date, birthdate doc_type, doc_date, birthdate
) )
) )
values.update({"document_expedition_date": document_expedition_date}) values.update(
{
"document_expedition_date": document_expedition_date,
"document_type": doc_type,
}
)
checkin_partner.sudo().write(values) checkin_partner.sudo().write(values)
def send_portal_invitation_email(self, invitation_firstname=None, email=None): def send_portal_invitation_email(self, invitation_firstname=None, email=None):

View File

@@ -1201,9 +1201,7 @@ class TestPmsCheckinPartner(TestPms):
is = 20 years old and document_date = today + 1 year. The expected is = 20 years old and document_date = today + 1 year. The expected
expedition date has to be doc_date - 5 years expedition date has to be doc_date - 5 years
""" """
doc_type_id = ( doc_type_id = self.env["res.partner.id_category"].search([("code", "=", "D")])
self.env["res.partner.id_category"].search([("code", "=", "D")]).id
)
doc_date = fields.date.today() + datetime.timedelta(days=366) doc_date = fields.date.today() + datetime.timedelta(days=366)
doc_date_str = str(doc_date) doc_date_str = str(doc_date)
@@ -1240,9 +1238,7 @@ class TestPmsCheckinPartner(TestPms):
is = 40 years old and document_date = today + 1 year. The expected is = 40 years old and document_date = today + 1 year. The expected
expedition date has to be doc_date - 10 years expedition date has to be doc_date - 10 years
""" """
doc_type_id = ( doc_type_id = self.env["res.partner.id_category"].search([("code", "=", "D")])
self.env["res.partner.id_category"].search([("code", "=", "D")]).id
)
doc_date = fields.date.today() + datetime.timedelta(days=366) doc_date = fields.date.today() + datetime.timedelta(days=366)
doc_date_str = str(doc_date) doc_date_str = str(doc_date)
@@ -1279,9 +1275,7 @@ class TestPmsCheckinPartner(TestPms):
is = 20 years old and document_date = today + 1 year. The expected is = 20 years old and document_date = today + 1 year. The expected
expedition date has to be doc_date - 5 years expedition date has to be doc_date - 5 years
""" """
doc_type_id = ( doc_type_id = self.env["res.partner.id_category"].search([("code", "=", "P")])
self.env["res.partner.id_category"].search([("code", "=", "P")]).id
)
doc_date = fields.date.today() + datetime.timedelta(days=366) doc_date = fields.date.today() + datetime.timedelta(days=366)
doc_date_str = str(doc_date) doc_date_str = str(doc_date)
@@ -1318,9 +1312,7 @@ class TestPmsCheckinPartner(TestPms):
is = 40 years old and document_date = today + 1 year. The expected is = 40 years old and document_date = today + 1 year. The expected
expedition date has to be doc_date - 10 years expedition date has to be doc_date - 10 years
""" """
doc_type_id = ( doc_type_id = self.env["res.partner.id_category"].search([("code", "=", "P")])
self.env["res.partner.id_category"].search([("code", "=", "P")]).id
)
doc_date = fields.date.today() + datetime.timedelta(days=366) doc_date = fields.date.today() + datetime.timedelta(days=366)
doc_date_str = str(doc_date) doc_date_str = str(doc_date)
@@ -1357,9 +1349,7 @@ class TestPmsCheckinPartner(TestPms):
is = 40 years old and document_date = today + 1 year. The expected is = 40 years old and document_date = today + 1 year. The expected
expedition date has to be doc_date - 10 years expedition date has to be doc_date - 10 years
""" """
doc_type_id = ( doc_type_id = self.env["res.partner.id_category"].search([("code", "=", "C")])
self.env["res.partner.id_category"].search([("code", "=", "C")]).id
)
doc_date = fields.date.today() + datetime.timedelta(days=366) doc_date = fields.date.today() + datetime.timedelta(days=366)
doc_date_str = str(doc_date) doc_date_str = str(doc_date)
@@ -1396,9 +1386,7 @@ class TestPmsCheckinPartner(TestPms):
is = 20 years old and document_date = today - 1 year. The expected is = 20 years old and document_date = today - 1 year. The expected
expedition date has to be the value of doc_date. expedition date has to be the value of doc_date.
""" """
doc_type_id = ( doc_type_id = self.env["res.partner.id_category"].search([("code", "=", "D")])
self.env["res.partner.id_category"].search([("code", "=", "D")]).id
)
doc_date = fields.date.today() - datetime.timedelta(days=366) doc_date = fields.date.today() - datetime.timedelta(days=366)
doc_date_str = str(doc_date) doc_date_str = str(doc_date)
birthdate = fields.date.today() - datetime.timedelta(days=7305) birthdate = fields.date.today() - datetime.timedelta(days=7305)
@@ -1443,11 +1431,12 @@ class TestPmsCheckinPartner(TestPms):
) )
checkin_partner_id = self.reservation.checkin_partner_ids[0] checkin_partner_id = self.reservation.checkin_partner_ids[0]
checkin_partner_vals = { checkin_partner_vals = {
"checkin_partner_id": checkin_partner_id.id,
"id": checkin_partner_id.id, "id": checkin_partner_id.id,
"firstname": "Serafín", "firstname": "Serafín",
"lastname": "Rivas", "lastname": "Rivas",
"lastname2": "Gonzalez", "lastname2": "Gonzalez",
"document_type": self.id_category, "document_type": self.id_category.name,
"document_number": "18038946T", "document_number": "18038946T",
"document_expedition_date": "2015-10-07", "document_expedition_date": "2015-10-07",
"birthdate_date": "1983-10-05", "birthdate_date": "1983-10-05",

File diff suppressed because it is too large Load Diff