[IMP]pms: compute precheckin partner mandatory state

This commit is contained in:
Darío Lodeiros
2021-10-19 08:16:35 +02:00
parent 75bd20882f
commit 5fd5a5008a
3 changed files with 36 additions and 8 deletions

View File

@@ -325,10 +325,12 @@ class PmsCheckinPartner(models.Model):
record.state = "draft" record.state = "draft"
if record.reservation_id.state == "cancel": if record.reservation_id.state == "cancel":
record.state = "cancel" record.state = "cancel"
elif record.state in ("draft", "cancel"): elif record.state in ("draft", "precheckin", "cancel"):
if any( if any(
not getattr(record, field) not getattr(record, field)
for field in record._checkin_mandatory_fields() for field in record._checkin_mandatory_fields(
country=record.nationality_id
)
): ):
record.state = "draft" record.state = "draft"
else: else:
@@ -610,14 +612,9 @@ class PmsCheckinPartner(models.Model):
return res return res
@api.model @api.model
def _checkin_mandatory_fields(self, depends=False): def _checkin_mandatory_fields(self, country=False, depends=False):
mandatory_fields = [ mandatory_fields = [
"name", "name",
"birthdate_date",
"gender",
"document_number",
"document_type",
"document_expedition_date",
] ]
# api.depends need "reservation_id.state" in the lambda function # api.depends need "reservation_id.state" in the lambda function
if depends: if depends:

View File

@@ -6,3 +6,4 @@ from . import res_country_state
from . import pms_ine_tourism_type_category from . import pms_ine_tourism_type_category
from . import pms_room from . import pms_room
from . import res_partner from . import res_partner
from . import pms_checkin_partner

View File

@@ -0,0 +1,30 @@
import logging
from odoo import api, models
CODE_SPAIN = "ES"
_logger = logging.getLogger(__name__)
class PmsCheckinParnert(models.Model):
_inherit = "pms.checkin.partner"
@api.model
def _checkin_mandatory_fields(self, country=False, depends=False):
mandatory_fields = super(PmsCheckinParnert, self)._checkin_mandatory_fields(
depends
)
mandatory_fields.extend(
[
"birthdate_date",
"gender",
"document_number",
"document_type",
"document_expedition_date",
"nationality_id",
]
)
if depends or (country and country.code == CODE_SPAIN):
mandatory_fields.append("state_id")
return mandatory_fields