mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: checkin partner residence state
This commit is contained in:
@@ -143,18 +143,6 @@ class PmsCheckinPartner(models.Model):
|
|||||||
compute="_compute_nationality_id",
|
compute="_compute_nationality_id",
|
||||||
comodel_name="res.country",
|
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(
|
residence_street = fields.Char(
|
||||||
string="Street",
|
string="Street",
|
||||||
help="Street of the guest's residence",
|
help="Street of the guest's residence",
|
||||||
@@ -360,14 +348,6 @@ class PmsCheckinPartner(models.Model):
|
|||||||
elif not record.nationality_id:
|
elif not record.nationality_id:
|
||||||
record.nationality_id = False
|
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")
|
@api.depends("partner_id")
|
||||||
def _compute_residence_street(self):
|
def _compute_residence_street(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
@@ -876,10 +856,10 @@ class PmsCheckinPartner(models.Model):
|
|||||||
if not values.get("document_type"):
|
if not values.get("document_type"):
|
||||||
values.update({"document_type": False})
|
values.update({"document_type": False})
|
||||||
if values.get("state"):
|
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"))]
|
[("id", "=", values.get("state"))]
|
||||||
)
|
)
|
||||||
values.update({"state_id": state_id})
|
values.update({"residence_state_id": residence_state_id})
|
||||||
values.pop("state")
|
values.pop("state")
|
||||||
if values.get("document_expedition_date"):
|
if values.get("document_expedition_date"):
|
||||||
doc_type = values.get("document_type")
|
doc_type = values.get("document_type")
|
||||||
|
|||||||
@@ -86,15 +86,6 @@ class ResPartner(models.Model):
|
|||||||
store=True,
|
store=True,
|
||||||
compute="_compute_nationality_id",
|
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(
|
email = fields.Char(
|
||||||
readonly=False,
|
readonly=False,
|
||||||
store=True,
|
store=True,
|
||||||
@@ -302,25 +293,6 @@ class ResPartner(models.Model):
|
|||||||
elif not record.nationality_id:
|
elif not record.nationality_id:
|
||||||
record.nationality_id = False
|
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")
|
@api.depends("pms_checkin_partner_ids", "pms_checkin_partner_ids.phone")
|
||||||
def _compute_phone(self):
|
def _compute_phone(self):
|
||||||
if hasattr(super(), "_compute_phone"):
|
if hasattr(super(), "_compute_phone"):
|
||||||
|
|||||||
@@ -67,7 +67,6 @@
|
|||||||
<field name="document_number" />
|
<field name="document_number" />
|
||||||
<field name="document_expedition_date" />
|
<field name="document_expedition_date" />
|
||||||
<field name="nationality_id" />
|
<field name="nationality_id" />
|
||||||
<field name="state_id" />
|
|
||||||
<field name="email" />
|
<field name="email" />
|
||||||
<field name="mobile" />
|
<field name="mobile" />
|
||||||
<field name="phone" />
|
<field name="phone" />
|
||||||
@@ -163,7 +162,7 @@
|
|||||||
<field name="document_number" />
|
<field name="document_number" />
|
||||||
<field name="document_expedition_date" />
|
<field name="document_expedition_date" />
|
||||||
<field name="nationality_id" />
|
<field name="nationality_id" />
|
||||||
<field name="state_id" />
|
<field name="residence_state_id" />
|
||||||
<field name="mobile" />
|
<field name="mobile" />
|
||||||
<field name="email" />
|
<field name="email" />
|
||||||
<field name="arrival" />
|
<field name="arrival" />
|
||||||
@@ -209,7 +208,7 @@
|
|||||||
<field name="document_number" />
|
<field name="document_number" />
|
||||||
<field name="document_expedition_date" />
|
<field name="document_expedition_date" />
|
||||||
<field name="nationality_id" />
|
<field name="nationality_id" />
|
||||||
<field name="state_id" />
|
<field name="residence_state_id" />
|
||||||
<field name="mobile" />
|
<field name="mobile" />
|
||||||
<field name="email" />
|
<field name="email" />
|
||||||
<field name="arrival" invisible="1" />
|
<field name="arrival" invisible="1" />
|
||||||
@@ -252,7 +251,7 @@
|
|||||||
<field name="document_number" />
|
<field name="document_number" />
|
||||||
<field name="document_expedition_date" />
|
<field name="document_expedition_date" />
|
||||||
<field name="nationality_id" />
|
<field name="nationality_id" />
|
||||||
<field name="state_id" />
|
<field name="residence_state_id" />
|
||||||
<field name="mobile" />
|
<field name="mobile" />
|
||||||
<field name="email" />
|
<field name="email" />
|
||||||
<field name="arrival" />
|
<field name="arrival" />
|
||||||
@@ -291,7 +290,7 @@
|
|||||||
<field name="document_number" />
|
<field name="document_number" />
|
||||||
<field name="document_expedition_date" />
|
<field name="document_expedition_date" />
|
||||||
<field name="nationality_id" />
|
<field name="nationality_id" />
|
||||||
<field name="state_id" />
|
<field name="residence_state_id" />
|
||||||
<field name="email" />
|
<field name="email" />
|
||||||
<field name="mobile" />
|
<field name="mobile" />
|
||||||
<field name="arrival" />
|
<field name="arrival" />
|
||||||
|
|||||||
@@ -242,24 +242,6 @@
|
|||||||
</t>
|
</t>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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">
|
<div t-attf-class="form-group col-12 col-md-6 pt-5">
|
||||||
<label
|
<label
|
||||||
id="label_mobile"
|
id="label_mobile"
|
||||||
@@ -1248,19 +1230,6 @@
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</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
|
<div
|
||||||
t-attf-class="form-group col-12 col-md-6 font-weight-bold"
|
t-attf-class="form-group col-12 col-md-6 font-weight-bold"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -49,5 +49,5 @@ class PmsCheckinParnert(models.Model):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
if depends or (country and country.code == CODE_SPAIN):
|
if depends or (country and country.code == CODE_SPAIN):
|
||||||
mandatory_fields.append("state_id")
|
mandatory_fields.append("residence_state_id")
|
||||||
return mandatory_fields
|
return mandatory_fields
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class ResPartner(models.Model):
|
|||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.depends("nationality_id", "state_id")
|
@api.depends("nationality_id", "residence_state_id")
|
||||||
def _compute_ine_code(self):
|
def _compute_ine_code(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if not record.nationality_id:
|
if not record.nationality_id:
|
||||||
@@ -24,9 +24,9 @@ class ResPartner(models.Model):
|
|||||||
elif record.nationality_id.code != CODE_SPAIN:
|
elif record.nationality_id.code != CODE_SPAIN:
|
||||||
record.ine_code = record.nationality_id.code_alpha3
|
record.ine_code = record.nationality_id.code_alpha3
|
||||||
else:
|
else:
|
||||||
if not record.state_id:
|
if not record.residence_state_id:
|
||||||
record.ine_code = False
|
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):
|
def _check_enought_invoice_data(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|||||||
@@ -255,10 +255,10 @@ class WizardIne(models.TransientModel):
|
|||||||
spanish_guests_with_no_state,
|
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]
|
entry_from_spain["residence_state_id"][0]
|
||||||
) # .ine_code
|
) # .ine_code
|
||||||
ine_code = state_id.ine_code
|
ine_code = residence_state_id.ine_code
|
||||||
|
|
||||||
# get count of each result
|
# get count of each result
|
||||||
num_spain = entry_from_spain["__count"]
|
num_spain = entry_from_spain["__count"]
|
||||||
|
|||||||
Reference in New Issue
Block a user