mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] state_id on checkin partner
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Alexandre Díaz
|
# Copyright 2021 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|||||||
@@ -125,13 +125,25 @@ class PmsCheckinPartner(models.Model):
|
|||||||
selection=[("male", "Male"), ("female", "Female"), ("other", "Other")],
|
selection=[("male", "Male"), ("female", "Female"), ("other", "Other")],
|
||||||
)
|
)
|
||||||
nationality_id = fields.Many2one(
|
nationality_id = fields.Many2one(
|
||||||
string="Nationality ID",
|
string="Nationality",
|
||||||
help="host nationality",
|
help="host nationality",
|
||||||
readonly=False,
|
readonly=False,
|
||||||
store=True,
|
store=True,
|
||||||
compute="_compute_nationality",
|
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="State",
|
||||||
|
help="host state",
|
||||||
|
readonly=False,
|
||||||
|
store=True,
|
||||||
|
compute="_compute_state_id",
|
||||||
|
comodel_name="res.country.state",
|
||||||
|
)
|
||||||
firstname = fields.Char(
|
firstname = fields.Char(
|
||||||
string="First Name",
|
string="First Name",
|
||||||
help="host firstname",
|
help="host firstname",
|
||||||
@@ -273,13 +285,21 @@ class PmsCheckinPartner(models.Model):
|
|||||||
record.gender = False
|
record.gender = False
|
||||||
|
|
||||||
@api.depends("partner_id")
|
@api.depends("partner_id")
|
||||||
def _compute_nationality(self):
|
def _compute_nationality_id(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if not record.nationality_id and record.partner_id.nationality_id:
|
if not record.nationality_id and record.partner_id.nationality_id:
|
||||||
record.nationality_id = record.partner_id.nationality_id
|
record.nationality_id = record.partner_id.nationality_id
|
||||||
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("reservation_id", "reservation_id.folio_id")
|
@api.depends("reservation_id", "reservation_id.folio_id")
|
||||||
def _compute_folio_id(self):
|
def _compute_folio_id(self):
|
||||||
for record in self.filtered("reservation_id"):
|
for record in self.filtered("reservation_id"):
|
||||||
|
|||||||
@@ -88,6 +88,15 @@ 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,
|
||||||
@@ -172,6 +181,25 @@ 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_field()
|
||||||
|
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(
|
@api.depends(
|
||||||
"pms_checkin_partner_ids",
|
"pms_checkin_partner_ids",
|
||||||
"pms_checkin_partner_ids.email",
|
"pms_checkin_partner_ids.email",
|
||||||
|
|||||||
@@ -53,6 +53,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="email" />
|
<field name="email" />
|
||||||
<field name="mobile" />
|
<field name="mobile" />
|
||||||
<field name="document_id" invisible="1" />
|
<field name="document_id" invisible="1" />
|
||||||
@@ -111,6 +112,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="mobile" />
|
<field name="mobile" />
|
||||||
<field name="email" />
|
<field name="email" />
|
||||||
<field name="arrival" />
|
<field name="arrival" />
|
||||||
@@ -156,6 +158,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="mobile" />
|
<field name="mobile" />
|
||||||
<field name="email" />
|
<field name="email" />
|
||||||
<field name="arrival" invisible="1" />
|
<field name="arrival" invisible="1" />
|
||||||
@@ -198,6 +201,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="mobile" />
|
<field name="mobile" />
|
||||||
<field name="email" />
|
<field name="email" />
|
||||||
<field name="arrival" />
|
<field name="arrival" />
|
||||||
@@ -236,6 +240,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="email" />
|
<field name="email" />
|
||||||
<field name="mobile" />
|
<field name="mobile" />
|
||||||
<field name="arrival" />
|
<field name="arrival" />
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
from odoo import models
|
|
||||||
|
|
||||||
|
|
||||||
class PmsCheckinPartner(models.Model):
|
|
||||||
_inherit = "pms.checkin.partner"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
from odoo import models
|
|
||||||
|
|
||||||
|
|
||||||
class ResPartner(models.Model):
|
|
||||||
_inherit = "res.partner"
|
|
||||||
Reference in New Issue
Block a user