Skip to content

Commit

Permalink
[FIX]pms_l10n_es: support number is not overwritten if the field does…
Browse files Browse the repository at this point in the history
… not exist in the last saved checkin
  • Loading branch information
braisab committed Feb 15, 2024
1 parent 66a764c commit 19f5931
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions pms_l10n_es/models/res_partner_id_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class ResPartnerIdNumber(models.Model):
support_number = fields.Char(
string="Support number",
help="DNI support number",
store=True,
readonly=False,
compute="_compute_support_number",
)

Expand All @@ -16,17 +18,19 @@ def _compute_support_number(self):
if hasattr(super(), "_compute_support_number"):
super()._compute_support_number()
for record in self:
if not record.support_number and record.partner_id.pms_checkin_partner_ids:
support_number = list(
set(
record.partner_id.pms_checkin_partner_ids.mapped(
"support_number"
if record.partner_id.pms_checkin_partner_ids:
last_update_support_number = (
record.partner_id.pms_checkin_partner_ids.filtered(
lambda x: x.write_date
== max(
record.partner_id.pms_checkin_partner_ids.mapped(
"write_date"
)
)
)
)
if len(support_number) == 1:
record.support_number = support_number[0]
else:
record.support_number = False
elif not record.support_number:
record.support_number = False
if (
last_update_support_number
and last_update_support_number[0].support_number
):
record.support_number = last_update_support_number[0].support_number

0 comments on commit 19f5931

Please sign in to comment.