This commit is contained in:
gsinghpal
2026-03-13 12:38:28 -04:00
parent db4b9aa278
commit fc3c966484
2975 changed files with 1614 additions and 498 deletions

View File

@@ -69,7 +69,60 @@ class ResPartner(models.Model):
store=True,
)
# ==========================================================================
# AUTHORIZER FIELDS
# ==========================================================================
x_fc_authorizer_number = fields.Char(
string='ADP Authorizer Number',
tracking=True,
index=True,
help='ADP Registration Number for this authorizer (e.g. OT). '
'Used to auto-link authorizers when processing ADP XML files.',
)
x_fc_adp_application_count = fields.Integer(
string='ADP Applications',
compute='_compute_adp_application_count',
)
@api.depends('x_fc_contact_type')
def _compute_is_odsp_office(self):
for partner in self:
partner.x_fc_is_odsp_office = partner.x_fc_contact_type == 'odsp_office'
def _compute_adp_application_count(self):
AppData = self.env['fusion.adp.application.data']
for partner in self:
domain = self._get_authorizer_application_domain(partner)
partner.x_fc_adp_application_count = AppData.search_count(domain) if domain else 0
def _get_authorizer_application_domain(self, partner):
"""Build domain to find applications linked to this authorizer."""
conditions = []
if partner.x_fc_authorizer_number:
conditions.append(('authorizer_adp_number', '=', partner.x_fc_authorizer_number))
name = (partner.name or '').strip()
if name:
parts = name.replace(',', ' ').split()
if len(parts) >= 2:
conditions.append(
'&',
)
conditions.append(('authorizer_last_name', 'ilike', parts[0]))
conditions.append(('authorizer_first_name', 'ilike', parts[-1]))
if not conditions:
return []
if len(conditions) > 3:
return ['|'] + conditions
return conditions
def action_view_adp_applications(self):
self.ensure_one()
domain = self._get_authorizer_application_domain(self)
return {
'name': 'ADP Applications',
'type': 'ir.actions.act_window',
'res_model': 'fusion.adp.application.data',
'view_mode': 'list,form',
'domain': domain,
'context': {'default_authorizer_adp_number': self.x_fc_authorizer_number or ''},
}