[IMP]pms: checkin partner residence state

This commit is contained in:
Darío Lodeiros
2022-03-20 22:12:30 +01:00
parent a23a26fb8c
commit 2bd9ca2ff0
7 changed files with 12 additions and 92 deletions

View File

@@ -143,18 +143,6 @@ class PmsCheckinPartner(models.Model):
compute="_compute_nationality_id",
comodel_name="res.country",
)
# TODO: Use new partner contact "other or "private" with
# personal contact address complete??
# to avoid user country_id on companies contacts.
# View to res.partner state_id inherit
state_id = fields.Many2one(
string="Country State",
help="host state",
readonly=False,
store=True,
compute="_compute_state_id",
comodel_name="res.country.state",
)
residence_street = fields.Char(
string="Street",
help="Street of the guest's residence",
@@ -360,14 +348,6 @@ class PmsCheckinPartner(models.Model):
elif not record.nationality_id:
record.nationality_id = False
@api.depends("partner_id")
def _compute_state_id(self):
for record in self:
if not record.state_id and record.partner_id.state_id:
record.state_id = record.partner_id.state_id
elif not record.state_id:
record.state_id = False
@api.depends("partner_id")
def _compute_residence_street(self):
for record in self:
@@ -876,10 +856,10 @@ class PmsCheckinPartner(models.Model):
if not values.get("document_type"):
values.update({"document_type": False})
if values.get("state"):
state_id = self.env["res.country.state"].search(
residence_state_id = self.env["res.country.state"].search(
[("id", "=", values.get("state"))]
)
values.update({"state_id": state_id})
values.update({"residence_state_id": residence_state_id})
values.pop("state")
if values.get("document_expedition_date"):
doc_type = values.get("document_type")

View File

@@ -86,15 +86,6 @@ class ResPartner(models.Model):
store=True,
compute="_compute_nationality_id",
)
# TODO: Use new partner contact "other or "private" with
# personal contact address complete??
# to avoid user country_id on companies contacts.
# view to checkin partner state_id field
state_id = fields.Many2one(
readonly=False,
store=True,
compute="_compute_state_id",
)
email = fields.Char(
readonly=False,
store=True,
@@ -302,25 +293,6 @@ class ResPartner(models.Model):
elif not record.nationality_id:
record.nationality_id = False
@api.depends("pms_checkin_partner_ids", "pms_checkin_partner_ids.state_id")
def _compute_state_id(self):
if hasattr(super(), "_compute_state_id"):
super()._compute_state_id()
for record in self:
if not record.state_id and record.pms_checkin_partner_ids:
state_id = list(
filter(
None,
set(record.pms_checkin_partner_ids.mapped("state_id")),
)
)
if len(state_id) == 1:
record.state_id = state_id[0]
else:
record.state_id = False
elif not record.state_id:
record.state_id = False
@api.depends("pms_checkin_partner_ids", "pms_checkin_partner_ids.phone")
def _compute_phone(self):
if hasattr(super(), "_compute_phone"):

View File

@@ -67,7 +67,6 @@
<field name="document_number" />
<field name="document_expedition_date" />
<field name="nationality_id" />
<field name="state_id" />
<field name="email" />
<field name="mobile" />
<field name="phone" />
@@ -163,7 +162,7 @@
<field name="document_number" />
<field name="document_expedition_date" />
<field name="nationality_id" />
<field name="state_id" />
<field name="residence_state_id" />
<field name="mobile" />
<field name="email" />
<field name="arrival" />
@@ -209,7 +208,7 @@
<field name="document_number" />
<field name="document_expedition_date" />
<field name="nationality_id" />
<field name="state_id" />
<field name="residence_state_id" />
<field name="mobile" />
<field name="email" />
<field name="arrival" invisible="1" />
@@ -252,7 +251,7 @@
<field name="document_number" />
<field name="document_expedition_date" />
<field name="nationality_id" />
<field name="state_id" />
<field name="residence_state_id" />
<field name="mobile" />
<field name="email" />
<field name="arrival" />
@@ -291,7 +290,7 @@
<field name="document_number" />
<field name="document_expedition_date" />
<field name="nationality_id" />
<field name="state_id" />
<field name="residence_state_id" />
<field name="email" />
<field name="mobile" />
<field name="arrival" />

View File

@@ -242,24 +242,6 @@
</t>
</select>
</div>
<div class="form-group col-12 col-md-6">
<label
class="col-form-label"
for="state"
>Country State</label>
<select class="form-control" id="state" name='state'>
<option value="">Select an option</option>
<t t-foreach="state_ids" t-as='state'>
<option
t-att-value="state.id"
t-att-country_id="state.country_id.id"
t-att-selected="state.id == checkin_partner_id.state_id.id"
>
<t t-esc="state.name" />
</option>
</t>
</select>
</div>
<div t-attf-class="form-group col-12 col-md-6 pt-5">
<label
id="label_mobile"
@@ -1248,19 +1230,6 @@
/>
</span>
</div>
<div
t-attf-class="form-group col-12 col-md-6 font-weight-bold"
>
Country State:
<br />
<span
class="font-weight-normal ml-3"
>
<t
t-esc="checkin_partner.state_id.name"
/>
</span>
</div>
<div
t-attf-class="form-group col-12 col-md-6 font-weight-bold"
>

View File

@@ -49,5 +49,5 @@ class PmsCheckinParnert(models.Model):
]
)
if depends or (country and country.code == CODE_SPAIN):
mandatory_fields.append("state_id")
mandatory_fields.append("residence_state_id")
return mandatory_fields

View File

@@ -16,7 +16,7 @@ class ResPartner(models.Model):
store=True,
)
@api.depends("nationality_id", "state_id")
@api.depends("nationality_id", "residence_state_id")
def _compute_ine_code(self):
for record in self:
if not record.nationality_id:
@@ -24,9 +24,9 @@ class ResPartner(models.Model):
elif record.nationality_id.code != CODE_SPAIN:
record.ine_code = record.nationality_id.code_alpha3
else:
if not record.state_id:
if not record.residence_state_id:
record.ine_code = False
record.ine_code = record.state_id.ine_code
record.ine_code = record.residence_state_id.ine_code
def _check_enought_invoice_data(self):
self.ensure_one()

View File

@@ -255,10 +255,10 @@ class WizardIne(models.TransientModel):
spanish_guests_with_no_state,
)
)
state_id = self.env["res.country.state"].browse(
residence_state_id = self.env["res.country.state"].browse(
entry_from_spain["residence_state_id"][0]
) # .ine_code
ine_code = state_id.ine_code
ine_code = residence_state_id.ine_code
# get count of each result
num_spain = entry_from_spain["__count"]