feat(fusion_tasks): delivery-specific fields + reduced task types
Add delivery integration fields (delivery_id, sale_order_id, portal_job_id, packages_count, weight_total, requires_signature, requires_photo, coc_attachment_id). Reduce task_type selection to delivery/pickup/return/rush with matching duration defaults. Add delivery cascade in action_complete_task() that calls delivery_id.action_mark_delivered() on completion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -73,6 +73,19 @@ class FusionTechnicianTask(models.Model):
|
|||||||
)
|
)
|
||||||
active = fields.Boolean(default=True)
|
active = fields.Boolean(default=True)
|
||||||
|
|
||||||
|
# ----- Delivery integration -----
|
||||||
|
delivery_id = fields.Many2one(
|
||||||
|
'fusion.plating.delivery', string='Delivery',
|
||||||
|
help='Linked delivery record from fusion_plating_logistics.',
|
||||||
|
)
|
||||||
|
sale_order_id = fields.Many2one('sale.order', string='Sale Order')
|
||||||
|
portal_job_id = fields.Many2one('fusion.plating.portal.job', string='Portal Job')
|
||||||
|
packages_count = fields.Integer(string='Packages', help='Number of boxes/crates.')
|
||||||
|
weight_total = fields.Float(string='Total Weight (kg)')
|
||||||
|
requires_signature = fields.Boolean(string='Requires Signature')
|
||||||
|
requires_photo = fields.Boolean(string='Requires Photo')
|
||||||
|
coc_attachment_id = fields.Many2one('ir.attachment', string='CoC Document')
|
||||||
|
|
||||||
client_display_name = fields.Char(
|
client_display_name = fields.Char(
|
||||||
compute='_compute_client_display', string='Client Name (Display)',
|
compute='_compute_client_display', string='Client Name (Display)',
|
||||||
)
|
)
|
||||||
@@ -135,14 +148,9 @@ class FusionTechnicianTask(models.Model):
|
|||||||
|
|
||||||
task_type = fields.Selection([
|
task_type = fields.Selection([
|
||||||
('delivery', 'Delivery'),
|
('delivery', 'Delivery'),
|
||||||
('repair', 'Repair'),
|
|
||||||
('pickup', 'Pickup'),
|
('pickup', 'Pickup'),
|
||||||
('troubleshoot', 'Troubleshooting'),
|
('return', 'Return'),
|
||||||
('assessment', 'Assessment'),
|
('rush', 'Rush Delivery'),
|
||||||
('installation', 'Installation'),
|
|
||||||
('maintenance', 'Maintenance'),
|
|
||||||
('ltc_visit', 'LTC Visit'),
|
|
||||||
('other', 'Other'),
|
|
||||||
], string='Task Type', required=True, default='delivery', tracking=True)
|
], string='Task Type', required=True, default='delivery', tracking=True)
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
@@ -201,14 +209,9 @@ class FusionTechnicianTask(models.Model):
|
|||||||
# Task type -> default duration mapping
|
# Task type -> default duration mapping
|
||||||
TASK_TYPE_DURATIONS = {
|
TASK_TYPE_DURATIONS = {
|
||||||
'delivery': 1.0,
|
'delivery': 1.0,
|
||||||
'repair': 2.0,
|
|
||||||
'pickup': 0.5,
|
'pickup': 0.5,
|
||||||
'troubleshoot': 1.5,
|
'return': 1.0,
|
||||||
'assessment': 1.5,
|
'rush': 0.5,
|
||||||
'installation': 2.0,
|
|
||||||
'maintenance': 1.5,
|
|
||||||
'ltc_visit': 3.0,
|
|
||||||
'other': 1.0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Previous task travel warning banner
|
# Previous task travel warning banner
|
||||||
@@ -1909,6 +1912,13 @@ class FusionTechnicianTask(models.Model):
|
|||||||
# Recalculate travel for remaining tasks from this completion location
|
# Recalculate travel for remaining tasks from this completion location
|
||||||
task._recalculate_remaining_tasks_travel()
|
task._recalculate_remaining_tasks_travel()
|
||||||
|
|
||||||
|
# Cascade to delivery if linked
|
||||||
|
if task.delivery_id:
|
||||||
|
try:
|
||||||
|
task.delivery_id.action_mark_delivered()
|
||||||
|
except Exception:
|
||||||
|
pass # Delivery cascade is best-effort
|
||||||
|
|
||||||
task._on_complete_extra()
|
task._on_complete_extra()
|
||||||
|
|
||||||
def _check_completion_requirements(self):
|
def _check_completion_requirements(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user