From c3ccc321b0e2815b3bbaa5e83ca75d5ffcc62753 Mon Sep 17 00:00:00 2001 From: Robin Keunen Date: Thu, 3 Aug 2023 17:02:34 +0200 Subject: [PATCH] [FIX] pms: set possible_existing_customer_ids to false When creating a new folio from the interface, odoo fails to assign possible_existing_customer_ids to the record. Setting it to False for the cas when there are no partner_name nor possible_customer fixes the issue. --- pms/models/pms_folio.py | 3 +-- pms/tests/test_pms_folio.py | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pms/models/pms_folio.py b/pms/models/pms_folio.py index 35d32c048..67478cbfb 100644 --- a/pms/models/pms_folio.py +++ b/pms/models/pms_folio.py @@ -1371,14 +1371,13 @@ class PmsFolio(models.Model): @api.depends("email", "mobile", "partner_name") def _compute_possible_existing_customer_ids(self): for record in self: + record.possible_existing_customer_ids = False if record.partner_name: possible_customer = self._apply_possible_existing_customer_ids( record.email, record.mobile, record.partner_id ) if possible_customer: record.possible_existing_customer_ids = possible_customer - else: - record.possible_existing_customer_ids = False @api.depends("reservation_ids", "reservation_ids.checkin") def _compute_first_checkin(self): diff --git a/pms/tests/test_pms_folio.py b/pms/tests/test_pms_folio.py index 0c176ce5e..0415f6d80 100644 --- a/pms/tests/test_pms_folio.py +++ b/pms/tests/test_pms_folio.py @@ -4,7 +4,7 @@ from freezegun import freeze_time from odoo import fields from odoo.exceptions import ValidationError - +from odoo.tests import Form from .common import TestPms @@ -1537,3 +1537,7 @@ class TestPmsFolio(TestPms): "sale_channel_origin_id of reservations that coincided " "with sale_channel_origin_id of folio de should be updated", ) + + def test_pms_folio_form_creation(self): + folio_form = Form(self.env["pms.folio"]) + self.assertFalse(folio_form.possible_existing_customer_ids)