refactor(fusion_tasks): update deps, config, crons for delivery context
- Change depends to [base, mail, hr, fusion_plating_logistics] - Rename module to 'Fusion Plating -- Delivery Tasks' - Replace all fusion_claims.* config params with fusion_tasks.* - Remove sync crons (pull_remote_tasks, cleanup_old_shadows) - Remove sync config ACL lines from ir.model.access.csv - Replace sales_team group refs with hr/base equivalents - Update license from OPL-1 to LGPL-3 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -52,11 +52,11 @@ class FusionTechnicianTask(models.Model):
|
||||
"""Return (open_hour, close_hour) from settings. Defaults 9.0 / 18.0."""
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
try:
|
||||
open_h = float(ICP.get_param('fusion_claims.store_open_hour', '9.0') or '9.0')
|
||||
open_h = float(ICP.get_param('fusion_tasks.store_open_hour', '9.0') or '9.0')
|
||||
except (ValueError, TypeError):
|
||||
open_h = 9.0
|
||||
try:
|
||||
close_h = float(ICP.get_param('fusion_claims.store_close_hour', '18.0') or '18.0')
|
||||
close_h = float(ICP.get_param('fusion_tasks.store_close_hour', '18.0') or '18.0')
|
||||
except (ValueError, TypeError):
|
||||
close_h = 18.0
|
||||
return (open_h, close_h)
|
||||
@@ -938,7 +938,7 @@ class FusionTechnicianTask(models.Model):
|
||||
Returns travel time in minutes, or 0 if unavailable."""
|
||||
try:
|
||||
api_key = self.env['ir.config_parameter'].sudo().get_param(
|
||||
'fusion_claims.google_maps_api_key', '')
|
||||
'fusion_tasks.google_maps_api_key', '')
|
||||
if not api_key:
|
||||
return 0
|
||||
|
||||
@@ -1385,7 +1385,7 @@ class FusionTechnicianTask(models.Model):
|
||||
def _create_vals_fill(self, vals):
|
||||
"""Hook: fill address from linked records during create.
|
||||
|
||||
Base implementation fills from partner_id. Override in fusion_claims
|
||||
Base implementation fills from partner_id. Override in subclass
|
||||
to also fill from sale_order_id or purchase_order_id.
|
||||
"""
|
||||
if vals.get('partner_id') and not vals.get('address_street'):
|
||||
@@ -1396,7 +1396,7 @@ class FusionTechnicianTask(models.Model):
|
||||
def _on_create_post_actions(self):
|
||||
"""Hook: post-create side-effects for linked records.
|
||||
|
||||
Override in fusion_claims to post chatter messages to linked orders,
|
||||
Override in subclass to post chatter messages to linked orders,
|
||||
mark sale orders as ready for delivery, etc.
|
||||
"""
|
||||
pass
|
||||
@@ -1556,12 +1556,12 @@ class FusionTechnicianTask(models.Model):
|
||||
|
||||
def _post_task_created_to_linked_order(self):
|
||||
"""Hook: post task creation notice to linked order chatter.
|
||||
Override in fusion_claims."""
|
||||
Override in fusion_tasks."""
|
||||
pass
|
||||
|
||||
def _mark_sale_order_ready_for_delivery(self):
|
||||
"""Hook: mark linked sale orders as ready for delivery.
|
||||
Override in fusion_claims."""
|
||||
Override in fusion_tasks."""
|
||||
pass
|
||||
|
||||
def _recalculate_day_travel_chains(self):
|
||||
@@ -1584,7 +1584,7 @@ class FusionTechnicianTask(models.Model):
|
||||
|
||||
Priority:
|
||||
1. Technician's personal x_fc_start_address (if set)
|
||||
2. Company default HQ address (fusion_claims.technician_start_address)
|
||||
2. Company default HQ address (fusion_tasks.technician_start_address)
|
||||
Returns the address string or ''.
|
||||
"""
|
||||
tech_user = self.env['res.users'].sudo().browse(tech_id)
|
||||
@@ -1592,7 +1592,7 @@ class FusionTechnicianTask(models.Model):
|
||||
return tech_user.x_fc_start_address.strip()
|
||||
# Fallback to company default
|
||||
return (self.env['ir.config_parameter'].sudo()
|
||||
.get_param('fusion_claims.technician_start_address', '') or '').strip()
|
||||
.get_param('fusion_tasks.technician_start_address', '') or '').strip()
|
||||
|
||||
def _geocode_address_string(self, address, api_key):
|
||||
"""Geocode an address string and return (lat, lng) or (0.0, 0.0)."""
|
||||
@@ -1621,7 +1621,7 @@ class FusionTechnicianTask(models.Model):
|
||||
For future dates, only 3 and 4 apply.
|
||||
"""
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
enabled = ICP.get_param('fusion_claims.google_distance_matrix_enabled', False)
|
||||
enabled = ICP.get_param('fusion_tasks.google_distance_matrix_enabled', False)
|
||||
if not enabled:
|
||||
return
|
||||
api_key = self._get_google_maps_api_key()
|
||||
@@ -1731,7 +1731,7 @@ class FusionTechnicianTask(models.Model):
|
||||
"""
|
||||
self.ensure_one()
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
if not ICP.get_param('fusion_claims.google_distance_matrix_enabled', False):
|
||||
if not ICP.get_param('fusion_tasks.google_distance_matrix_enabled', False):
|
||||
return
|
||||
tech_id = self.technician_id.id
|
||||
if not tech_id:
|
||||
@@ -1752,7 +1752,7 @@ class FusionTechnicianTask(models.Model):
|
||||
"""
|
||||
self.ensure_one()
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
if not ICP.get_param('fusion_claims.google_distance_matrix_enabled', False):
|
||||
if not ICP.get_param('fusion_tasks.google_distance_matrix_enabled', False):
|
||||
return
|
||||
|
||||
tech_id = self.technician_id.id
|
||||
@@ -1913,12 +1913,12 @@ class FusionTechnicianTask(models.Model):
|
||||
|
||||
def _check_completion_requirements(self):
|
||||
"""Hook: check additional requirements before task completion.
|
||||
Override in fusion_claims for rental inspection checks."""
|
||||
Override in subclass for rental inspection checks."""
|
||||
pass
|
||||
|
||||
def _on_complete_extra(self):
|
||||
"""Hook: additional side-effects after task completion.
|
||||
Override in fusion_claims for ODSP advancement and rental inspection."""
|
||||
Override in subclass for ODSP advancement and rental inspection."""
|
||||
pass
|
||||
|
||||
def action_cancel_task(self):
|
||||
@@ -1933,7 +1933,7 @@ class FusionTechnicianTask(models.Model):
|
||||
|
||||
def _on_cancel_extra(self):
|
||||
"""Hook: additional side-effects after task cancellation.
|
||||
Override in fusion_claims for sale order revert and email."""
|
||||
Override in subclass for sale order revert and email."""
|
||||
self._send_task_cancelled_email()
|
||||
|
||||
def action_reschedule(self):
|
||||
@@ -1985,7 +1985,7 @@ class FusionTechnicianTask(models.Model):
|
||||
|
||||
def _post_completion_to_linked_order(self):
|
||||
"""Hook: post completion notes to linked order chatter.
|
||||
Override in fusion_claims."""
|
||||
Override in fusion_tasks."""
|
||||
pass
|
||||
|
||||
def _notify_scheduler_on_completion(self):
|
||||
@@ -2086,15 +2086,15 @@ class FusionTechnicianTask(models.Model):
|
||||
return {'to': to_emails, 'cc': list(set(cc_emails))}
|
||||
|
||||
def _send_task_cancelled_email(self):
|
||||
"""Send cancellation email. Base: no-op. Override in fusion_claims."""
|
||||
"""Send cancellation email. Base: no-op. Override in fusion_tasks."""
|
||||
return False
|
||||
|
||||
def _send_task_scheduled_email(self):
|
||||
"""Send scheduled email. Base: no-op. Override in fusion_claims."""
|
||||
"""Send scheduled email. Base: no-op. Override in fusion_tasks."""
|
||||
return False
|
||||
|
||||
def _send_task_rescheduled_email(self, old_date=None, old_start=None, old_end=None):
|
||||
"""Send rescheduled email. Base: no-op. Override in fusion_claims."""
|
||||
"""Send rescheduled email. Base: no-op. Override in fusion_tasks."""
|
||||
return False
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
@@ -2105,14 +2105,14 @@ class FusionTechnicianTask(models.Model):
|
||||
"""Return a record that has the _email_build mixin.
|
||||
|
||||
Base: returns self (task model inherits mixin).
|
||||
Override in fusion_claims to prefer linked sale order.
|
||||
Override in subclass to prefer linked sale order.
|
||||
"""
|
||||
return self
|
||||
|
||||
def _is_email_notifications_enabled(self):
|
||||
"""Check if email notifications are enabled.
|
||||
|
||||
Base: always True. Override in fusion_claims to check
|
||||
Base: always True. Override in subclass to check
|
||||
linked sale order's notification settings.
|
||||
"""
|
||||
return True
|
||||
@@ -2120,7 +2120,7 @@ class FusionTechnicianTask(models.Model):
|
||||
def _get_linked_order(self):
|
||||
"""Return the linked order record (SO or PO), or False.
|
||||
|
||||
Base: always False. Override in fusion_claims to return
|
||||
Base: always False. Override in subclass to return
|
||||
sale_order_id or purchase_order_id.
|
||||
"""
|
||||
return False
|
||||
@@ -2336,7 +2336,7 @@ class FusionTechnicianTask(models.Model):
|
||||
def _get_google_maps_api_key(self):
|
||||
"""Get the Google Maps API key from config."""
|
||||
return self.env['ir.config_parameter'].sudo().get_param(
|
||||
'fusion_claims.google_maps_api_key', ''
|
||||
'fusion_tasks.google_maps_api_key', ''
|
||||
)
|
||||
|
||||
@api.model
|
||||
@@ -2347,9 +2347,9 @@ class FusionTechnicianTask(models.Model):
|
||||
domain: optional extra domain from the search bar filters.
|
||||
"""
|
||||
api_key = self.env['ir.config_parameter'].sudo().get_param(
|
||||
'fusion_claims.google_maps_api_key', '')
|
||||
'fusion_tasks.google_maps_api_key', '')
|
||||
local_instance = self.env['ir.config_parameter'].sudo().get_param(
|
||||
'fusion_claims.sync_instance_id', '')
|
||||
'fusion_tasks.sync_instance_id', '')
|
||||
base_domain = [
|
||||
('status', 'not in', ['cancelled']),
|
||||
]
|
||||
@@ -2399,7 +2399,7 @@ class FusionTechnicianTask(models.Model):
|
||||
|
||||
hq_address = (
|
||||
self.env['ir.config_parameter'].sudo()
|
||||
.get_param('fusion_claims.technician_start_address', '') or ''
|
||||
.get_param('fusion_tasks.technician_start_address', '') or ''
|
||||
).strip()
|
||||
hq_lat, hq_lng = 0.0, 0.0
|
||||
|
||||
@@ -2693,7 +2693,7 @@ class FusionTechnicianTask(models.Model):
|
||||
tech and an in-app notification to the office (once per task).
|
||||
"""
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
push_enabled = ICP.get_param('fusion_claims.push_enabled', 'False')
|
||||
push_enabled = ICP.get_param('fusion_tasks.push_enabled', 'False')
|
||||
if push_enabled.lower() not in ('true', '1', 'yes'):
|
||||
return
|
||||
|
||||
@@ -2801,8 +2801,8 @@ class FusionTechnicianTask(models.Model):
|
||||
return
|
||||
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
vapid_private = ICP.get_param('fusion_claims.vapid_private_key', '')
|
||||
vapid_public = ICP.get_param('fusion_claims.vapid_public_key', '')
|
||||
vapid_private = ICP.get_param('fusion_tasks.vapid_private_key', '')
|
||||
vapid_public = ICP.get_param('fusion_tasks.vapid_public_key', '')
|
||||
if not vapid_private or not vapid_public:
|
||||
_logger.warning("VAPID keys not configured, cannot send push notification")
|
||||
return
|
||||
@@ -2850,10 +2850,10 @@ class FusionTechnicianTask(models.Model):
|
||||
def _cron_send_push_notifications(self):
|
||||
"""Cron: Send push notifications for upcoming tasks."""
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
if not ICP.get_param('fusion_claims.push_enabled', False):
|
||||
if not ICP.get_param('fusion_tasks.push_enabled', False):
|
||||
return
|
||||
|
||||
advance_minutes = int(ICP.get_param('fusion_claims.push_advance_minutes', '30'))
|
||||
advance_minutes = int(ICP.get_param('fusion_tasks.push_advance_minutes', '30'))
|
||||
local_now = self._local_now()
|
||||
|
||||
tasks = self.search([
|
||||
|
||||
Reference in New Issue
Block a user