mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] pms_l10n_es: test cases
This commit is contained in:
@@ -135,14 +135,14 @@ class PmsCheckinPartner(models.Model):
|
||||
|
||||
@api.model
|
||||
def _checkin_mandatory_fields(self, depends=False):
|
||||
# api.depends need "reservation_id.state" in de lambda function
|
||||
# api.depends need "reservation_id.state" in the lambda function
|
||||
if depends:
|
||||
return ["reservation_id.state", "name"]
|
||||
return ["name"]
|
||||
|
||||
@api.model
|
||||
def _checkin_partner_fields(self):
|
||||
# api.depends need "reservation_id.state" in de lambda function
|
||||
# api.depends need "reservation_id.state" in the lambda function
|
||||
checkin_fields = self._checkin_mandatory_fields()
|
||||
checkin_fields.extend(["mobile", "email"])
|
||||
return checkin_fields
|
||||
@@ -261,6 +261,10 @@ class PmsCheckinPartner(models.Model):
|
||||
raise ValidationError(_("It is not yet checkin day!"))
|
||||
if record.reservation_id.checkout <= fields.Date.today():
|
||||
raise ValidationError(_("Its too late to checkin"))
|
||||
if any(
|
||||
not getattr(record, field) for field in self._checkin_mandatory_fields()
|
||||
):
|
||||
raise ValidationError(_("Personal data is missing for check-in"))
|
||||
vals = {
|
||||
"state": "onboard",
|
||||
"arrival": fields.Datetime.now(),
|
||||
|
||||
@@ -9,26 +9,6 @@ from odoo.tests import common
|
||||
|
||||
@freeze_time("2011-03-16")
|
||||
class TestResPartner(common.SavepointCase):
|
||||
def test_check_reservation_draft_state(self):
|
||||
# arrange
|
||||
partner = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "partner1",
|
||||
}
|
||||
)
|
||||
reservation_vals = {
|
||||
"checkin": "2011-03-16",
|
||||
"checkout": "2011-03-19",
|
||||
"partner_id": partner.id,
|
||||
"adults": 1,
|
||||
}
|
||||
# action
|
||||
reservation = self.env["pms.reservation"].create(reservation_vals)
|
||||
|
||||
# assert
|
||||
|
||||
self.assertEqual(reservation.state, "draf", "partner's fields weren't checked")
|
||||
|
||||
def test_check_precheckin_state(self):
|
||||
# arrange
|
||||
today = fields.date.today()
|
||||
@@ -37,9 +17,11 @@ class TestResPartner(common.SavepointCase):
|
||||
"name": "name1",
|
||||
# "lastname": "lastname1",
|
||||
"lastname2": "secondlastname",
|
||||
"expedition_date": "2011-02-20",
|
||||
"document_expedition_date": "2011-02-20",
|
||||
"birthdate_date": "1995-12-10",
|
||||
"gender": "M",
|
||||
"gender": "male",
|
||||
"document_type": "D",
|
||||
"document_number": "30065089H",
|
||||
}
|
||||
)
|
||||
reservation_vals = {
|
||||
@@ -50,7 +32,7 @@ class TestResPartner(common.SavepointCase):
|
||||
}
|
||||
# action
|
||||
reservation = self.env["pms.reservation"].create(reservation_vals)
|
||||
checkin = self.env["pms_checkin_partner"].create(
|
||||
checkin = self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": partner.id,
|
||||
"reservation_id": reservation.id,
|
||||
@@ -79,7 +61,7 @@ class TestResPartner(common.SavepointCase):
|
||||
}
|
||||
# action
|
||||
reservation = self.env["pms.reservation"].create(reservation_vals)
|
||||
checkin = self.env["pms_checkin_partner"].create(
|
||||
checkin = self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": partner.id,
|
||||
"reservation_id": reservation.id,
|
||||
@@ -99,26 +81,28 @@ class TestResPartner(common.SavepointCase):
|
||||
"name": "name1",
|
||||
# "lastname": "lastname1",
|
||||
"lastname2": "secondlastname",
|
||||
"expedition_date": "2011-02-20",
|
||||
"document_expedition_date": "2011-02-20",
|
||||
"birthdate_date": "1995-12-10",
|
||||
"gender": "M",
|
||||
"gender": "male",
|
||||
"document_type": "D",
|
||||
"document_number": "30065089H",
|
||||
}
|
||||
)
|
||||
reservation_vals = {
|
||||
"checkin": today(),
|
||||
"checkout": today() + datetime.timedelta(days=3),
|
||||
"checkin": today,
|
||||
"checkout": today + datetime.timedelta(days=3),
|
||||
"partner_id": partner.id,
|
||||
"adults": 1,
|
||||
}
|
||||
# action
|
||||
reservation = self.env["pms.reservation"].create(reservation_vals)
|
||||
checkin = self.env["pms_checkin_partner"].create(
|
||||
checkin = self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": partner.id,
|
||||
"reservation_id": reservation.id,
|
||||
}
|
||||
)
|
||||
|
||||
checkin.action_on_board()
|
||||
# arrange
|
||||
self.assertEqual(reservation.state, "onboard", "reservation's state is wrong")
|
||||
self.assertEqual(checkin.state, "onboard", "checkin's state is wrong")
|
||||
|
||||
Reference in New Issue
Block a user