feat: add x_fc_authorizer_number, x_fc_account_number, x_marked_for fields; auto-link authorizer from XML
- fusion_claims: added x_fc_authorizer_number to res.partner for ADP authorizer registration numbers - fusion_claims: XML parser auto-links authorizer contact to sale order by ADP number - fusion_claims: removed size=9 constraint from x_fc_odsp_member_id - fusion_claims: authorizer number shown on OT/PT contact form - fusion_so_to_po: added x_marked_for (Many2one) field definition on purchase.order - fusion_so_to_po: added x_fc_account_number on res.partner for vendor account numbers
This commit is contained in:
@@ -45,9 +45,8 @@ class ResPartner(models.Model):
|
||||
# ==========================================================================
|
||||
x_fc_odsp_member_id = fields.Char(
|
||||
string='ODSP Member ID',
|
||||
size=9,
|
||||
tracking=True,
|
||||
help='9-digit Ontario Disability Support Program Member ID',
|
||||
help='Ontario Disability Support Program Member ID',
|
||||
)
|
||||
x_fc_case_worker_id = fields.Many2one(
|
||||
'res.partner',
|
||||
@@ -69,6 +68,17 @@ 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.',
|
||||
)
|
||||
|
||||
@api.depends('x_fc_contact_type')
|
||||
def _compute_is_odsp_office(self):
|
||||
for partner in self:
|
||||
|
||||
@@ -66,6 +66,10 @@ class FusionXmlParser(models.AbstractModel):
|
||||
# Step 3: Create/update profile
|
||||
profile = self._find_or_create_profile(model_vals, sale_order)
|
||||
|
||||
# Step 3b: Auto-link authorizer on sale order by ADP number
|
||||
if sale_order:
|
||||
self._link_authorizer_by_adp_number(model_vals, sale_order)
|
||||
|
||||
# Step 4: Create application data record
|
||||
model_vals['profile_id'] = profile.id
|
||||
model_vals['sale_order_id'] = sale_order.id if sale_order else False
|
||||
@@ -637,6 +641,39 @@ class FusionXmlParser(models.AbstractModel):
|
||||
# ------------------------------------------------------------------
|
||||
# PROFILE MANAGEMENT
|
||||
# ------------------------------------------------------------------
|
||||
def _link_authorizer_by_adp_number(self, vals, sale_order):
|
||||
"""Auto-link the authorizer contact on the sale order using the ADP number from XML."""
|
||||
adp_number = (vals.get('authorizer_adp_number') or '').strip()
|
||||
if not adp_number or adp_number.upper() in ('NA', 'N/A', ''):
|
||||
return
|
||||
|
||||
if sale_order.x_fc_authorizer_id:
|
||||
return
|
||||
|
||||
Partner = self.env['res.partner']
|
||||
authorizer = Partner.search([
|
||||
('x_fc_authorizer_number', '=', adp_number),
|
||||
], limit=1)
|
||||
|
||||
if not authorizer:
|
||||
first = (vals.get('authorizer_first_name') or '').strip()
|
||||
last = (vals.get('authorizer_last_name') or '').strip()
|
||||
if first and last:
|
||||
authorizer = Partner.search([
|
||||
'|',
|
||||
('name', 'ilike', f'{first} {last}'),
|
||||
('name', 'ilike', f'{last}, {first}'),
|
||||
], limit=1)
|
||||
if authorizer and not authorizer.x_fc_authorizer_number:
|
||||
authorizer.write({'x_fc_authorizer_number': adp_number})
|
||||
|
||||
if authorizer:
|
||||
sale_order.write({'x_fc_authorizer_id': authorizer.id})
|
||||
_logger.info(
|
||||
'Auto-linked authorizer %s (ADP# %s) to SO %s',
|
||||
authorizer.name, adp_number, sale_order.name,
|
||||
)
|
||||
|
||||
def _find_or_create_profile(self, vals, sale_order=None):
|
||||
"""Find or create a client profile from parsed application data."""
|
||||
Profile = self.env['fusion.client.profile']
|
||||
|
||||
@@ -16,6 +16,13 @@
|
||||
<field name="x_fc_contact_type" placeholder="Select contact type..."/>
|
||||
</xpath>
|
||||
|
||||
<!-- Authorizer number for OTs/PTs/authorizer contacts -->
|
||||
<xpath expr="//field[@name='x_fc_contact_type']" position="after">
|
||||
<field name="x_fc_authorizer_number" string="ADP Reg. Number"
|
||||
invisible="x_fc_contact_type not in ('occupational_therapist', 'physiotherapist', 'adp_agent')"
|
||||
placeholder="e.g. 3000001234"/>
|
||||
</xpath>
|
||||
|
||||
<!-- ODSP section in notebook -->
|
||||
<xpath expr="//notebook" position="inside">
|
||||
<page string="ODSP" name="odsp_info"
|
||||
|
||||
Reference in New Issue
Block a user