mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: compute precheckin partner mandatory state
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
30
pms_l10n_es/models/pms_checkin_partner.py
Normal file
30
pms_l10n_es/models/pms_checkin_partner.py
Normal 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
|
||||||
Reference in New Issue
Block a user