Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pms/models/pms_checkin_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def _compute_country_id(self):
for record in self:
if not record.country_id and record.partner_id.country_id:
record.country_id = record.partner_id.country_id
elif not record.state_id:
elif not record.country_id:
record.country_id = False

@api.depends("partner_id")
Expand Down
18 changes: 18 additions & 0 deletions pms/tests/test_pms_checkin_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,3 +1424,21 @@ def test_partner_created_with_folio_lang(self):
lang_es.code,
"Partner lang should match folio lang",
)

def test_country_without_state_survives_partner_and_nationality(self):
"""A residence country without state (most foreign countries) must not
be cleared when the guest gets a partner or a nationality.
"""
france = self.env.ref("base.fr")
checkin = self.reservation_1.checkin_partner_ids.filtered(
lambda c: not c.partner_id
)[:1]
checkin.write(
{"firstname": "Jean", "lastname": "Dupont", "country_id": france.id}
)
checkin.partner_id = self.env["res.partner"].create(
{"firstname": "Jean", "lastname": "Dupont"}
)
self.assertEqual(checkin.country_id, france)
checkin.nationality_id = france
self.assertEqual(checkin.country_id, france)
Loading