odoo-addon-pms 16.0.0.29.0__py3-none-any.whl → 16.0.2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/pms/README.rst +1 -1
- odoo/addons/pms/__manifest__.py +6 -5
- odoo/addons/pms/data/pms_data.xml +0 -11
- odoo/addons/pms/i18n/de.po +79 -142
- odoo/addons/pms/i18n/es.po +79 -142
- odoo/addons/pms/i18n/it.po +26 -138
- odoo/addons/pms/i18n/pms.pot +18 -302
- odoo/addons/pms/migrations/16.0.1.0.0/pre-migration.py +48 -0
- odoo/addons/pms/models/__init__.py +0 -2
- odoo/addons/pms/models/pms_checkin_partner.py +98 -376
- odoo/addons/pms/models/pms_folio.py +0 -1
- odoo/addons/pms/models/pms_reservation.py +0 -1
- odoo/addons/pms/models/res_company.py +0 -6
- odoo/addons/pms/models/res_partner.py +0 -366
- odoo/addons/pms/static/description/index.html +1 -1
- odoo/addons/pms/tests/test_pms_checkin_partner.py +15 -453
- odoo/addons/pms/tests/test_pms_folio.py +0 -6
- odoo/addons/pms/tests/test_pms_reservation.py +7 -53
- odoo/addons/pms/tests/test_pms_reservation_line.py +0 -3
- odoo/addons/pms/views/pms_checkin_partner_views.xml +11 -32
- odoo/addons/pms/views/res_company_views.xml +0 -1
- odoo/addons/pms/views/res_partner_views.xml +0 -40
- {odoo_addon_pms-16.0.0.29.0.dist-info → odoo_addon_pms-16.0.2.0.0.dist-info}/METADATA +3 -3
- {odoo_addon_pms-16.0.0.29.0.dist-info → odoo_addon_pms-16.0.2.0.0.dist-info}/RECORD +26 -29
- odoo/addons/pms/models/res_partner_id_category.py +0 -14
- odoo/addons/pms/models/res_partner_id_number.py +0 -141
- odoo/addons/pms/views/res_partner_id_category_views.xml +0 -29
- odoo/addons/pms/views/res_partner_id_number_views.xml +0 -29
- {odoo_addon_pms-16.0.0.29.0.dist-info → odoo_addon_pms-16.0.2.0.0.dist-info}/WHEEL +0 -0
- {odoo_addon_pms-16.0.0.29.0.dist-info → odoo_addon_pms-16.0.2.0.0.dist-info}/top_level.txt +0 -0
|
@@ -5,12 +5,8 @@
|
|
|
5
5
|
import json
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
|
|
8
|
-
from dateutil.relativedelta import relativedelta
|
|
9
|
-
|
|
10
8
|
from odoo import _, api, fields, models
|
|
11
|
-
from odoo.exceptions import
|
|
12
|
-
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
|
13
|
-
from odoo.tools.safe_eval import safe_eval
|
|
9
|
+
from odoo.exceptions import ValidationError
|
|
14
10
|
|
|
15
11
|
|
|
16
12
|
class PmsCheckinPartner(models.Model):
|
|
@@ -145,51 +141,47 @@ class PmsCheckinPartner(models.Model):
|
|
|
145
141
|
comodel_name="res.country",
|
|
146
142
|
inverse=lambda r: r._inverse_partner_fields("nationality_id", "nationality_id"),
|
|
147
143
|
)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
help="Street of the guest's residence",
|
|
144
|
+
street = fields.Char(
|
|
145
|
+
help="Street of the guest",
|
|
151
146
|
readonly=False,
|
|
152
147
|
store=True,
|
|
153
|
-
compute="
|
|
148
|
+
compute="_compute_street",
|
|
154
149
|
)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
help="Second street of the guest's residence",
|
|
150
|
+
street2 = fields.Char(
|
|
151
|
+
help="Second street of the guest",
|
|
158
152
|
readonly=False,
|
|
159
153
|
store=True,
|
|
160
|
-
compute="
|
|
154
|
+
compute="_compute_street2",
|
|
161
155
|
)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
help="Zip of the guest's residence",
|
|
156
|
+
zip = fields.Char(
|
|
157
|
+
help="Zip of the guest",
|
|
165
158
|
readonly=False,
|
|
166
159
|
store=True,
|
|
167
|
-
compute="
|
|
160
|
+
compute="_compute_zip",
|
|
168
161
|
change_default=True,
|
|
169
162
|
)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
help="City of the guest's residence",
|
|
163
|
+
city = fields.Char(
|
|
164
|
+
help="City of the guest",
|
|
173
165
|
readonly=False,
|
|
174
166
|
store=True,
|
|
175
|
-
compute="
|
|
167
|
+
compute="_compute_city",
|
|
176
168
|
)
|
|
177
|
-
|
|
169
|
+
country_id = fields.Many2one(
|
|
178
170
|
string="Country of residence",
|
|
179
|
-
help="Country of the guest
|
|
171
|
+
help="Country of the guest",
|
|
180
172
|
readonly=False,
|
|
181
173
|
store=True,
|
|
182
174
|
index=True,
|
|
183
|
-
compute="
|
|
175
|
+
compute="_compute_country_id",
|
|
184
176
|
comodel_name="res.country",
|
|
185
177
|
)
|
|
186
|
-
|
|
178
|
+
state_id = fields.Many2one(
|
|
187
179
|
string="State of residence",
|
|
188
|
-
help="State of the guest
|
|
180
|
+
help="State of the guest",
|
|
189
181
|
readonly=False,
|
|
190
182
|
store=True,
|
|
191
183
|
index=True,
|
|
192
|
-
compute="
|
|
184
|
+
compute="_compute_state_id",
|
|
193
185
|
comodel_name="res.country.state",
|
|
194
186
|
)
|
|
195
187
|
|
|
@@ -217,50 +209,6 @@ class PmsCheckinPartner(models.Model):
|
|
|
217
209
|
compute="_compute_birth_date",
|
|
218
210
|
inverse=lambda r: r._inverse_partner_fields("birthdate_date", "birthdate_date"),
|
|
219
211
|
)
|
|
220
|
-
document_number = fields.Char(
|
|
221
|
-
help="Host document number",
|
|
222
|
-
readonly=False,
|
|
223
|
-
store=True,
|
|
224
|
-
compute="_compute_document_number",
|
|
225
|
-
)
|
|
226
|
-
document_type = fields.Many2one(
|
|
227
|
-
help="Select a valid document type",
|
|
228
|
-
readonly=False,
|
|
229
|
-
store=True,
|
|
230
|
-
index=True,
|
|
231
|
-
comodel_name="res.partner.id_category",
|
|
232
|
-
compute="_compute_document_type",
|
|
233
|
-
domain="['|', ('country_ids', '=', False),"
|
|
234
|
-
" ('country_ids', 'in', document_country_id)]",
|
|
235
|
-
)
|
|
236
|
-
document_expedition_date = fields.Date(
|
|
237
|
-
string="Expedition Date",
|
|
238
|
-
help="Date on which document_type was issued",
|
|
239
|
-
readonly=False,
|
|
240
|
-
store=True,
|
|
241
|
-
compute="_compute_document_expedition_date",
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
document_id = fields.Many2one(
|
|
245
|
-
string="Document",
|
|
246
|
-
help="Technical field",
|
|
247
|
-
readonly=False,
|
|
248
|
-
store=True,
|
|
249
|
-
index=True,
|
|
250
|
-
comodel_name="res.partner.id_number",
|
|
251
|
-
compute="_compute_document_id",
|
|
252
|
-
ondelete="restrict",
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
document_country_id = fields.Many2one(
|
|
256
|
-
string="Document Country",
|
|
257
|
-
help="Country of the document",
|
|
258
|
-
comodel_name="res.country",
|
|
259
|
-
compute="_compute_document_country_id",
|
|
260
|
-
store=True,
|
|
261
|
-
readonly=False,
|
|
262
|
-
)
|
|
263
|
-
|
|
264
212
|
partner_incongruences = fields.Char(
|
|
265
213
|
help="indicates that some partner fields \
|
|
266
214
|
on the checkin do not correspond to that of \
|
|
@@ -272,7 +220,6 @@ class PmsCheckinPartner(models.Model):
|
|
|
272
220
|
string="Possible existing customer",
|
|
273
221
|
compute="_compute_possible_existing_customer_ids",
|
|
274
222
|
comodel_name="res.partner",
|
|
275
|
-
inverse_name="checkin_partner_possible_customer_id",
|
|
276
223
|
)
|
|
277
224
|
|
|
278
225
|
partner_relationship = fields.Char(help="Family relationship between travelers")
|
|
@@ -291,50 +238,6 @@ class PmsCheckinPartner(models.Model):
|
|
|
291
238
|
if record.partner_id:
|
|
292
239
|
record.partner_id[partner_field_name] = record[checkin_field_name]
|
|
293
240
|
|
|
294
|
-
@api.depends("partner_id")
|
|
295
|
-
def _compute_document_number(self):
|
|
296
|
-
for record in self:
|
|
297
|
-
if not record.document_number and record.partner_id.id_numbers:
|
|
298
|
-
last_update_document = record.partner_id.id_numbers.filtered(
|
|
299
|
-
lambda x, record=record: x.write_date
|
|
300
|
-
== max(record.partner_id.id_numbers.mapped("write_date"))
|
|
301
|
-
)
|
|
302
|
-
if last_update_document and last_update_document[0].name:
|
|
303
|
-
record.document_number = last_update_document[0].name
|
|
304
|
-
|
|
305
|
-
@api.depends("partner_id")
|
|
306
|
-
def _compute_document_type(self):
|
|
307
|
-
for record in self:
|
|
308
|
-
if not record.document_type and record.partner_id.id_numbers:
|
|
309
|
-
last_update_document = record.partner_id.id_numbers.filtered(
|
|
310
|
-
lambda x, record=record: x.write_date
|
|
311
|
-
== max(record.partner_id.id_numbers.mapped("write_date"))
|
|
312
|
-
)
|
|
313
|
-
if last_update_document and last_update_document[0].category_id:
|
|
314
|
-
record.document_type = last_update_document[0].category_id
|
|
315
|
-
|
|
316
|
-
@api.depends("partner_id")
|
|
317
|
-
def _compute_document_expedition_date(self):
|
|
318
|
-
for record in self:
|
|
319
|
-
if not record.document_expedition_date and record.partner_id.id_numbers:
|
|
320
|
-
last_update_document = record.partner_id.id_numbers.filtered(
|
|
321
|
-
lambda x, record=record: x.write_date
|
|
322
|
-
== max(record.partner_id.id_numbers.mapped("write_date"))
|
|
323
|
-
)
|
|
324
|
-
if last_update_document and last_update_document[0].valid_from:
|
|
325
|
-
record.document_expedition_date = last_update_document[0].valid_from
|
|
326
|
-
|
|
327
|
-
@api.depends("partner_id")
|
|
328
|
-
def _compute_document_country_id(self):
|
|
329
|
-
for record in self:
|
|
330
|
-
if not record.document_country_id and record.partner_id.id_numbers:
|
|
331
|
-
last_update_document = record.partner_id.id_numbers.filtered(
|
|
332
|
-
lambda x, record=record: x.write_date
|
|
333
|
-
== max(record.partner_id.id_numbers.mapped("write_date"))
|
|
334
|
-
)
|
|
335
|
-
if last_update_document and last_update_document[0].country_id:
|
|
336
|
-
record.document_country_id = last_update_document[0].country_id
|
|
337
|
-
|
|
338
241
|
@api.depends("partner_id")
|
|
339
242
|
def _compute_firstname(self):
|
|
340
243
|
for record in self:
|
|
@@ -376,53 +279,52 @@ class PmsCheckinPartner(models.Model):
|
|
|
376
279
|
record.nationality_id = False
|
|
377
280
|
|
|
378
281
|
@api.depends("partner_id")
|
|
379
|
-
def
|
|
282
|
+
def _compute_street(self):
|
|
380
283
|
for record in self:
|
|
381
|
-
if not record.
|
|
382
|
-
record.
|
|
383
|
-
elif not record.
|
|
384
|
-
record.
|
|
284
|
+
if not record.street and record.partner_id.street:
|
|
285
|
+
record.street = record.partner_id.street
|
|
286
|
+
elif not record.street:
|
|
287
|
+
record.street = False
|
|
385
288
|
|
|
386
289
|
@api.depends("partner_id")
|
|
387
|
-
def
|
|
290
|
+
def _compute_street2(self):
|
|
388
291
|
for record in self:
|
|
389
|
-
if not record.
|
|
390
|
-
record.
|
|
391
|
-
elif not record.
|
|
392
|
-
record.
|
|
292
|
+
if not record.street2 and record.partner_id.street2:
|
|
293
|
+
record.street2 = record.partner_id.street2
|
|
294
|
+
elif not record.street2:
|
|
295
|
+
record.street2 = False
|
|
393
296
|
|
|
394
297
|
@api.depends("partner_id")
|
|
395
|
-
def
|
|
298
|
+
def _compute_zip(self):
|
|
396
299
|
for record in self:
|
|
397
|
-
if not record.
|
|
398
|
-
record.
|
|
399
|
-
elif not record.
|
|
400
|
-
record.
|
|
300
|
+
if not record.zip and record.partner_id.zip:
|
|
301
|
+
record.zip = record.partner_id.zip
|
|
302
|
+
elif not record.zip:
|
|
303
|
+
record.zip = False
|
|
401
304
|
|
|
402
305
|
@api.depends("partner_id")
|
|
403
|
-
def
|
|
306
|
+
def _compute_city(self):
|
|
404
307
|
for record in self:
|
|
405
|
-
if not record.
|
|
406
|
-
record.
|
|
407
|
-
elif not record.
|
|
408
|
-
record.
|
|
308
|
+
if not record.city and record.partner_id.city:
|
|
309
|
+
record.city = record.partner_id.city
|
|
310
|
+
elif not record.city:
|
|
311
|
+
record.city = False
|
|
409
312
|
|
|
410
313
|
@api.depends("partner_id", "nationality_id")
|
|
411
|
-
def
|
|
314
|
+
def _compute_country_id(self):
|
|
412
315
|
for record in self:
|
|
413
|
-
if
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
record.residence_country_id = record.partner_id.residence_country_id
|
|
316
|
+
if not record.country_id and record.partner_id.country_id:
|
|
317
|
+
record.country_id = record.partner_id.country_id
|
|
318
|
+
elif not record.state_id:
|
|
319
|
+
record.country_id = False
|
|
418
320
|
|
|
419
321
|
@api.depends("partner_id")
|
|
420
|
-
def
|
|
322
|
+
def _compute_state_id(self):
|
|
421
323
|
for record in self:
|
|
422
|
-
if not record.
|
|
423
|
-
record.
|
|
424
|
-
elif not record.
|
|
425
|
-
record.
|
|
324
|
+
if not record.state_id and record.partner_id.state_id:
|
|
325
|
+
record.state_id = record.partner_id.state_id
|
|
326
|
+
elif not record.state_id:
|
|
327
|
+
record.state_id = False
|
|
426
328
|
|
|
427
329
|
@api.depends(lambda self: self._checkin_manual_fields())
|
|
428
330
|
def _compute_state(self):
|
|
@@ -439,11 +341,7 @@ class PmsCheckinPartner(models.Model):
|
|
|
439
341
|
record.state = "dummy"
|
|
440
342
|
elif any(
|
|
441
343
|
not getattr(record, field)
|
|
442
|
-
for field in record._checkin_mandatory_fields(
|
|
443
|
-
residence_country=record.residence_country_id,
|
|
444
|
-
document_type=record.document_type,
|
|
445
|
-
birthdate_date=record.birthdate_date,
|
|
446
|
-
)
|
|
344
|
+
for field in record._checkin_mandatory_fields()
|
|
447
345
|
):
|
|
448
346
|
record.state = "draft"
|
|
449
347
|
else:
|
|
@@ -479,48 +377,9 @@ class PmsCheckinPartner(models.Model):
|
|
|
479
377
|
elif not record.phone:
|
|
480
378
|
record.phone = False
|
|
481
379
|
|
|
482
|
-
@api.depends("partner_id")
|
|
483
|
-
def _compute_document_id(self):
|
|
484
|
-
for record in self:
|
|
485
|
-
if record.partner_id:
|
|
486
|
-
if (
|
|
487
|
-
not record.document_id
|
|
488
|
-
and record.document_number
|
|
489
|
-
and record.document_type
|
|
490
|
-
):
|
|
491
|
-
id_number_id = (
|
|
492
|
-
self.sudo()
|
|
493
|
-
.env["res.partner.id_number"]
|
|
494
|
-
.search(
|
|
495
|
-
[
|
|
496
|
-
("partner_id", "=", record.partner_id.id),
|
|
497
|
-
("name", "=", record.document_number),
|
|
498
|
-
("category_id", "=", record.document_type.id),
|
|
499
|
-
]
|
|
500
|
-
)
|
|
501
|
-
)
|
|
502
|
-
if not id_number_id:
|
|
503
|
-
document_vals = record.get_document_vals()
|
|
504
|
-
id_number_id = self.env["res.partner.id_number"].create(
|
|
505
|
-
document_vals
|
|
506
|
-
)
|
|
507
|
-
|
|
508
|
-
record.document_id = id_number_id
|
|
509
|
-
else:
|
|
510
|
-
record.document_id = False
|
|
511
|
-
|
|
512
|
-
def get_document_vals(self):
|
|
513
|
-
return {
|
|
514
|
-
"name": self.document_number,
|
|
515
|
-
"partner_id": self.partner_id.id,
|
|
516
|
-
"category_id": self.document_type.id,
|
|
517
|
-
"valid_from": self.document_expedition_date,
|
|
518
|
-
"country_id": self.document_country_id.id,
|
|
519
|
-
}
|
|
520
|
-
|
|
521
380
|
@api.model
|
|
522
381
|
def _get_compute_partner_id_field_names(self):
|
|
523
|
-
return ["
|
|
382
|
+
return ["firstname", "lastname"]
|
|
524
383
|
|
|
525
384
|
def _completed_partner_creation_fields(self):
|
|
526
385
|
self.ensure_one()
|
|
@@ -541,36 +400,15 @@ class PmsCheckinPartner(models.Model):
|
|
|
541
400
|
def _compute_partner_id(self):
|
|
542
401
|
for record in self:
|
|
543
402
|
if not record.partner_id:
|
|
544
|
-
if record.
|
|
545
|
-
|
|
546
|
-
|
|
403
|
+
if record._completed_partner_creation_fields():
|
|
404
|
+
partner_values = record._get_partner_create_vals()
|
|
405
|
+
partner = (
|
|
406
|
+
self.env["res.partner"]
|
|
407
|
+
.with_context(avoid_document_restriction=True)
|
|
408
|
+
.create(partner_values)
|
|
547
409
|
)
|
|
548
|
-
if not partner:
|
|
549
|
-
if self._completed_partner_creation_fields():
|
|
550
|
-
partner_values = self._get_partner_create_vals()
|
|
551
|
-
partner = (
|
|
552
|
-
self.env["res.partner"]
|
|
553
|
-
.with_context(avoid_document_restriction=True)
|
|
554
|
-
.create(partner_values)
|
|
555
|
-
)
|
|
556
410
|
record.partner_id = partner
|
|
557
411
|
|
|
558
|
-
@api.model
|
|
559
|
-
def _get_partner_by_document(self, document_number, document_type):
|
|
560
|
-
number = (
|
|
561
|
-
self.sudo()
|
|
562
|
-
.env["res.partner.id_number"]
|
|
563
|
-
.search(
|
|
564
|
-
[
|
|
565
|
-
("name", "=", document_number),
|
|
566
|
-
("category_id", "=", document_type.id),
|
|
567
|
-
]
|
|
568
|
-
)
|
|
569
|
-
)
|
|
570
|
-
return (
|
|
571
|
-
self.sudo().env["res.partner"].search([("id", "=", number.partner_id.id)])
|
|
572
|
-
)
|
|
573
|
-
|
|
574
412
|
@api.depends("email", "mobile")
|
|
575
413
|
def _compute_possible_existing_customer_ids(self):
|
|
576
414
|
for record in self:
|
|
@@ -664,89 +502,41 @@ class PmsCheckinPartner(models.Model):
|
|
|
664
502
|
_("This guest is already registered in the room")
|
|
665
503
|
)
|
|
666
504
|
|
|
667
|
-
@api.constrains("document_number")
|
|
668
|
-
def check_document_number(self):
|
|
669
|
-
for record in self:
|
|
670
|
-
if record.partner_id:
|
|
671
|
-
for number in record.partner_id.id_numbers:
|
|
672
|
-
if record.document_type == number.category_id:
|
|
673
|
-
if record.document_number != number.name:
|
|
674
|
-
raise ValidationError(_("Document_type has already exists"))
|
|
675
|
-
|
|
676
505
|
def _validation_eval_context(self, id_number):
|
|
677
506
|
self.ensure_one()
|
|
678
507
|
return {"self": self, "id_number": id_number}
|
|
679
508
|
|
|
680
|
-
@api.constrains("
|
|
681
|
-
def
|
|
682
|
-
"""Validate the given ID number
|
|
683
|
-
The method raises an odoo.exceptions.ValidationError if the eval of
|
|
684
|
-
python validation code fails
|
|
685
|
-
"""
|
|
509
|
+
@api.constrains("state_id", "country_id")
|
|
510
|
+
def _check_state_id_country_id_consistence(self):
|
|
686
511
|
for record in self:
|
|
687
|
-
if record.
|
|
688
|
-
id_number = self.env["res.partner.id_number"].new(
|
|
689
|
-
{
|
|
690
|
-
"name": record.document_number,
|
|
691
|
-
"category_id": record.document_type,
|
|
692
|
-
}
|
|
693
|
-
)
|
|
512
|
+
if record.state_id and record.country_id:
|
|
694
513
|
if (
|
|
695
|
-
|
|
696
|
-
|
|
514
|
+
record.state_id.country_id
|
|
515
|
+
and record.country_id not in record.state_id.country_id
|
|
697
516
|
):
|
|
698
|
-
return
|
|
699
|
-
eval_context = record._validation_eval_context(id_number)
|
|
700
|
-
try:
|
|
701
|
-
safe_eval(
|
|
702
|
-
record.document_type.validation_code,
|
|
703
|
-
eval_context,
|
|
704
|
-
mode="exec",
|
|
705
|
-
nocopy=True,
|
|
706
|
-
)
|
|
707
|
-
except Exception as e:
|
|
708
|
-
raise UserError(
|
|
709
|
-
_(
|
|
710
|
-
"Error when evaluating the id_category "
|
|
711
|
-
"validation code:\n %(name)s \n(%(error)s)",
|
|
712
|
-
name=self.name,
|
|
713
|
-
error=e,
|
|
714
|
-
)
|
|
715
|
-
) from e
|
|
716
|
-
if eval_context.get("failed", False):
|
|
717
517
|
raise ValidationError(
|
|
718
|
-
_(
|
|
719
|
-
"%(doc_number)s is not a valid %(doc_type)s identifier",
|
|
720
|
-
doc_number=record.document_number,
|
|
721
|
-
doc_type=record.document_type.name,
|
|
722
|
-
)
|
|
723
|
-
)
|
|
724
|
-
|
|
725
|
-
@api.constrains("document_country_id", "document_type")
|
|
726
|
-
def _check_document_country_id_document_type_consistence(self):
|
|
727
|
-
for record in self:
|
|
728
|
-
if record.document_country_id and record.document_type:
|
|
729
|
-
if (
|
|
730
|
-
record.document_type.country_ids
|
|
731
|
-
and record.document_country_id
|
|
732
|
-
not in record.document_type.country_ids
|
|
733
|
-
):
|
|
734
|
-
raise ValidationError(
|
|
735
|
-
_("Document type and country of document do not match")
|
|
518
|
+
_("State and country of residence do not match")
|
|
736
519
|
)
|
|
737
520
|
|
|
738
|
-
|
|
739
|
-
|
|
521
|
+
def set_partner_address(self):
|
|
522
|
+
"""
|
|
523
|
+
Only sets the checkin.partner address in the associated partner if
|
|
524
|
+
the partner don't have any address field filled.
|
|
525
|
+
"""
|
|
740
526
|
for record in self:
|
|
741
|
-
if record.
|
|
742
|
-
|
|
743
|
-
record.
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
527
|
+
if record.partner_id:
|
|
528
|
+
residence_vals = {
|
|
529
|
+
"street": record.street,
|
|
530
|
+
"street2": record.street2,
|
|
531
|
+
"zip": record.zip,
|
|
532
|
+
"city": record.city,
|
|
533
|
+
"country_id": record.country_id.id,
|
|
534
|
+
"state_id": record.state_id.id,
|
|
535
|
+
}
|
|
536
|
+
if any(residence_vals.values()):
|
|
537
|
+
address_fields = residence_vals.keys()
|
|
538
|
+
if not any(record.partner_id[field] for field in address_fields):
|
|
539
|
+
record.partner_id.write(residence_vals)
|
|
750
540
|
|
|
751
541
|
@api.model_create_multi
|
|
752
542
|
def create(self, vals_list):
|
|
@@ -782,6 +572,7 @@ class PmsCheckinPartner(models.Model):
|
|
|
782
572
|
"check-in in this reservation"
|
|
783
573
|
)
|
|
784
574
|
)
|
|
575
|
+
records.set_partner_address()
|
|
785
576
|
return records
|
|
786
577
|
|
|
787
578
|
def write(self, vals):
|
|
@@ -791,6 +582,7 @@ class PmsCheckinPartner(models.Model):
|
|
|
791
582
|
tourist_tax_services_cmds = reservation._compute_tourist_tax_lines()
|
|
792
583
|
if tourist_tax_services_cmds:
|
|
793
584
|
reservation.write({"service_ids": tourist_tax_services_cmds})
|
|
585
|
+
self.set_partner_address()
|
|
794
586
|
return res
|
|
795
587
|
|
|
796
588
|
def unlink(self):
|
|
@@ -811,17 +603,13 @@ class PmsCheckinPartner(models.Model):
|
|
|
811
603
|
"firstname",
|
|
812
604
|
"lastname",
|
|
813
605
|
"birthdate_date",
|
|
814
|
-
"document_number",
|
|
815
|
-
"document_expedition_date",
|
|
816
606
|
"nationality_id",
|
|
817
|
-
"
|
|
818
|
-
"
|
|
819
|
-
"
|
|
820
|
-
"
|
|
821
|
-
"
|
|
822
|
-
"
|
|
823
|
-
"document_country_id",
|
|
824
|
-
"document_type",
|
|
607
|
+
"street",
|
|
608
|
+
"street2",
|
|
609
|
+
"zip",
|
|
610
|
+
"city",
|
|
611
|
+
"country_id",
|
|
612
|
+
"state_id",
|
|
825
613
|
]
|
|
826
614
|
return manual_fields
|
|
827
615
|
|
|
@@ -831,12 +619,13 @@ class PmsCheckinPartner(models.Model):
|
|
|
831
619
|
manual_fields.append("reservation_id.state")
|
|
832
620
|
return manual_fields
|
|
833
621
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
622
|
+
def _checkin_mandatory_fields(self):
|
|
623
|
+
"""
|
|
624
|
+
Auxiliar method to return the mandatory fields for checkin.
|
|
625
|
+
It can be extended by modules that need to add more mandatory fields.
|
|
626
|
+
"""
|
|
627
|
+
self.ensure_one()
|
|
628
|
+
return []
|
|
840
629
|
|
|
841
630
|
@api.model
|
|
842
631
|
def _checkin_partner_fields(self):
|
|
@@ -878,28 +667,6 @@ class PmsCheckinPartner(models.Model):
|
|
|
878
667
|
checkin_vals[key] = value
|
|
879
668
|
checkin.write(checkin_vals)
|
|
880
669
|
|
|
881
|
-
@api.model
|
|
882
|
-
def calculate_doc_type_expedition_date_from_validity_date(
|
|
883
|
-
self, doc_type, doc_date, birthdate
|
|
884
|
-
):
|
|
885
|
-
today = fields.datetime.today()
|
|
886
|
-
datetime_doc_date = datetime.strptime(doc_date, DEFAULT_SERVER_DATE_FORMAT)
|
|
887
|
-
if datetime_doc_date < today:
|
|
888
|
-
return datetime_doc_date
|
|
889
|
-
datetime_birthdate = datetime.strptime(birthdate, DEFAULT_SERVER_DATE_FORMAT)
|
|
890
|
-
age = today.year - datetime_birthdate.year
|
|
891
|
-
|
|
892
|
-
document_expedition_date = False
|
|
893
|
-
if doc_type.code == "D" or doc_type.code == "P":
|
|
894
|
-
if age < 30:
|
|
895
|
-
document_expedition_date = datetime_doc_date - relativedelta(years=5)
|
|
896
|
-
else:
|
|
897
|
-
document_expedition_date = datetime_doc_date - relativedelta(years=10)
|
|
898
|
-
if doc_type.code == "C":
|
|
899
|
-
if age < 70:
|
|
900
|
-
document_expedition_date = datetime_doc_date - relativedelta(years=10)
|
|
901
|
-
return document_expedition_date
|
|
902
|
-
|
|
903
670
|
def action_on_board(self):
|
|
904
671
|
for record in self:
|
|
905
672
|
if record.reservation_id.checkin > fields.Date.today():
|
|
@@ -908,7 +675,8 @@ class PmsCheckinPartner(models.Model):
|
|
|
908
675
|
raise ValidationError(_("Its too late to checkin"))
|
|
909
676
|
|
|
910
677
|
if any(
|
|
911
|
-
not getattr(record, field)
|
|
678
|
+
not getattr(record, field)
|
|
679
|
+
for field in record._checkin_mandatory_fields()
|
|
912
680
|
):
|
|
913
681
|
raise ValidationError(_("Personal data is missing for check-in"))
|
|
914
682
|
vals = {
|
|
@@ -969,52 +737,6 @@ class PmsCheckinPartner(models.Model):
|
|
|
969
737
|
"context": ctx,
|
|
970
738
|
}
|
|
971
739
|
|
|
972
|
-
def _save_data_from_portal(self, values):
|
|
973
|
-
checkin_partner = values.get("checkin_partner", "")
|
|
974
|
-
values.pop("checkin_partner")
|
|
975
|
-
values.pop("folio_access_token") if "folio_access_token" in values else None
|
|
976
|
-
if values.get("nationality"):
|
|
977
|
-
values.update({"nationality_id": int(values.get("nationality_id"))})
|
|
978
|
-
|
|
979
|
-
doc_type = (
|
|
980
|
-
self.sudo()
|
|
981
|
-
.env["res.partner.id_category"]
|
|
982
|
-
.browse(int(values.get("document_type")))
|
|
983
|
-
)
|
|
984
|
-
if values.get("document_type"):
|
|
985
|
-
values.update({"document_type": int(values.get("document_type"))})
|
|
986
|
-
if values.get("residence_state_id"):
|
|
987
|
-
values.update({"residence_state_id": int(values.get("residence_state_id"))})
|
|
988
|
-
if values.get("residence_country_id"):
|
|
989
|
-
values.update(
|
|
990
|
-
{"residence_country_id": int(values.get("residence_country_id"))}
|
|
991
|
-
)
|
|
992
|
-
|
|
993
|
-
if values.get("document_expedition_date"):
|
|
994
|
-
values.update(
|
|
995
|
-
{
|
|
996
|
-
"document_expedition_date": datetime.strptime(
|
|
997
|
-
values.get("document_expedition_date"), "%d/%m/%Y"
|
|
998
|
-
).strftime("%Y-%m-%d"),
|
|
999
|
-
"birthdate_date": datetime.strptime(
|
|
1000
|
-
values.get("birthdate_date"), "%d/%m/%Y"
|
|
1001
|
-
).strftime("%Y-%m-%d"),
|
|
1002
|
-
}
|
|
1003
|
-
)
|
|
1004
|
-
doc_date = values.get("document_expedition_date")
|
|
1005
|
-
birthdate = values.get("birthdate_date")
|
|
1006
|
-
document_expedition_date = (
|
|
1007
|
-
self.calculate_doc_type_expedition_date_from_validity_date(
|
|
1008
|
-
doc_type, doc_date, birthdate
|
|
1009
|
-
)
|
|
1010
|
-
)
|
|
1011
|
-
values.update(
|
|
1012
|
-
{
|
|
1013
|
-
"document_expedition_date": document_expedition_date,
|
|
1014
|
-
}
|
|
1015
|
-
)
|
|
1016
|
-
checkin_partner.sudo().write(values)
|
|
1017
|
-
|
|
1018
740
|
def send_portal_invitation_email(self, invitation_firstname=None, email=None):
|
|
1019
741
|
template = self.sudo().env.ref(
|
|
1020
742
|
"pms.precheckin_invitation_email", raise_if_not_found=False
|
|
@@ -527,7 +527,6 @@ class PmsFolio(models.Model):
|
|
|
527
527
|
string="Possible existing customer",
|
|
528
528
|
compute="_compute_possible_existing_customer_ids",
|
|
529
529
|
comodel_name="res.partner",
|
|
530
|
-
inverse_name="folio_possible_customer_id",
|
|
531
530
|
)
|
|
532
531
|
first_checkin = fields.Date(
|
|
533
532
|
string="First Folio Checkin",
|
|
@@ -644,7 +644,6 @@ class PmsReservation(models.Model):
|
|
|
644
644
|
string="Possible existing customer",
|
|
645
645
|
compute="_compute_possible_existing_customer_ids",
|
|
646
646
|
comodel_name="res.partner",
|
|
647
|
-
inverse_name="reservation_possible_customer_id",
|
|
648
647
|
)
|
|
649
648
|
|
|
650
649
|
avoid_mails = fields.Boolean(
|
|
@@ -43,12 +43,6 @@ class ResCompany(models.Model):
|
|
|
43
43
|
default="no",
|
|
44
44
|
)
|
|
45
45
|
|
|
46
|
-
document_partner_required = fields.Boolean(
|
|
47
|
-
help="""If true, the partner document is required
|
|
48
|
-
to create a new contact""",
|
|
49
|
-
default=False,
|
|
50
|
-
)
|
|
51
|
-
|
|
52
46
|
cancel_penalty_product_id = fields.Many2one(
|
|
53
47
|
string="Cancel penalty product",
|
|
54
48
|
help="Product used to calculate the cancel penalty",
|