mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP]pms: Added warning in inconsistencies before saving res.partner if it already exists
This commit is contained in:
@@ -191,6 +191,12 @@ class PmsCheckinPartner(models.Model):
|
||||
compute="_compute_document_id",
|
||||
)
|
||||
|
||||
incongruences = fields.Char(
|
||||
string="Incongruences",
|
||||
help="Technical field",
|
||||
compute="_compute_incongruences",
|
||||
)
|
||||
|
||||
@api.depends("partner_id", "partner_id.id_numbers")
|
||||
def _compute_document_number(self):
|
||||
for record in self:
|
||||
@@ -368,6 +374,35 @@ class PmsCheckinPartner(models.Model):
|
||||
partner = self.env["res.partner"].create(partner_values)
|
||||
record.partner_id = partner
|
||||
|
||||
@api.depends(
|
||||
"firstname",
|
||||
"lastname",
|
||||
"lastname2",
|
||||
"gender",
|
||||
"birthdate_date",
|
||||
"nationality_id",
|
||||
"email",
|
||||
"mobile",
|
||||
)
|
||||
def _compute_incongruences(self):
|
||||
for record in self:
|
||||
incongruous_fields = ""
|
||||
if record.partner_id:
|
||||
for field in record._checkin_partner_fields():
|
||||
if (
|
||||
record.partner_id[field]
|
||||
and record.partner_id[field] != record[field]
|
||||
):
|
||||
incongruous_fields += record._fields[field].string + ", "
|
||||
if incongruous_fields:
|
||||
record.incongruences = (
|
||||
incongruous_fields + "field/s don't correspond to saved host"
|
||||
)
|
||||
else:
|
||||
record.incongruences = False
|
||||
else:
|
||||
record.incongruences = False
|
||||
|
||||
@api.constrains("departure", "arrival")
|
||||
def _check_departure(self):
|
||||
for record in self:
|
||||
|
||||
@@ -125,7 +125,7 @@ class ResPartner(models.Model):
|
||||
super()._compute_field()
|
||||
for record in self:
|
||||
birthdate = record.pms_checkin_partner_ids.mapped("birthdate_date")
|
||||
if not record.birthdate_date and birthdate:
|
||||
if birthdate:
|
||||
record.birthdate_date = birthdate[0]
|
||||
|
||||
@api.depends("pms_checkin_partner_ids", "pms_checkin_partner_ids.nationality_id")
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
<field name="state" widget="statusbar" />
|
||||
</header>
|
||||
<sheet>
|
||||
<div
|
||||
class="alert alert-danger"
|
||||
role="danger"
|
||||
style="margin-bottom:0px;"
|
||||
attrs="{'invisible': [('incongruences','=',False)]}"
|
||||
>
|
||||
<field name="incongruences" />
|
||||
</div>
|
||||
<group name="group_top">
|
||||
<group name="group_left">
|
||||
<field
|
||||
@@ -165,7 +173,7 @@
|
||||
/>
|
||||
<field name="identifier" />
|
||||
<field name="partner_id" domain="[('is_company','=', False)]" />
|
||||
<field name="reservation_id" />
|
||||
<field name="reservation_id" />
|
||||
<field name="pms_property_id" invisible="1" />
|
||||
<field name="firstname" />
|
||||
<field name="lastname" />
|
||||
|
||||
Reference in New Issue
Block a user