diff --git a/fusion_claims/models/sale_order.py b/fusion_claims/models/sale_order.py index b0f4e738..7fdc4cba 100644 --- a/fusion_claims/models/sale_order.py +++ b/fusion_claims/models/sale_order.py @@ -338,6 +338,11 @@ class SaleOrder(models.Model): help='Type of sale for billing purposes. This field determines the workflow and billing rules.', ) + x_fc_is_service_repair = fields.Boolean( + string='Service Repair', copy=False, + help='Auto-created from the technician service booking wizard.', + ) + x_fc_sale_type_locked = fields.Boolean( string='Sale Type Locked', compute='_compute_sale_type_locked', diff --git a/fusion_claims/models/technician_task.py b/fusion_claims/models/technician_task.py index 3c18d8e3..a74a80cc 100644 --- a/fusion_claims/models/technician_task.py +++ b/fusion_claims/models/technician_task.py @@ -9,7 +9,7 @@ features to the base fusion.technician.task model. """ from odoo import models, fields, api, _ -from odoo.exceptions import UserError, ValidationError +from odoo.exceptions import UserError from markupsafe import Markup import logging @@ -104,15 +104,9 @@ class FusionTechnicianTaskClaims(models.Model): @api.constrains('sale_order_id', 'purchase_order_id') def _check_order_link(self): - for task in self: - if task.x_fc_sync_source: - continue - if task.task_type == 'ltc_visit': - continue - if not task.sale_order_id and not task.purchase_order_id: - raise ValidationError(_( - "A task must be linked to either a Sale Order (Case) or a Purchase Order." - )) + # Relaxed 2026-06: service bookings auto-create their SO, and in-shop / + # walk-in tasks may legitimately have none. No order link is required anymore. + return # ------------------------------------------------------------------ # HOOK OVERRIDES diff --git a/fusion_claims/tests/__init__.py b/fusion_claims/tests/__init__.py index 3d63968a..da3b5e31 100644 --- a/fusion_claims/tests/__init__.py +++ b/fusion_claims/tests/__init__.py @@ -4,3 +4,4 @@ from . import test_signed_pages_gate from . import test_application_received_wizard from . import test_dashboard from . import test_service_rate +from . import test_service_booking diff --git a/fusion_claims/tests/test_service_booking.py b/fusion_claims/tests/test_service_booking.py new file mode 100644 index 00000000..699ddc0a --- /dev/null +++ b/fusion_claims/tests/test_service_booking.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from datetime import date +from odoo.tests.common import TransactionCase, tagged + + +@tagged('post_install', '-at_install') +class TestServiceBooking(TransactionCase): + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.Task = cls.env['fusion.technician.task'] + # technician_id is required on a task (domain x_fc_is_field_staff=True). + cls.tech = cls.env['res.users'].create({ + 'name': 'Service Booking Tech', + 'login': 'svcbook_tech', + 'x_fc_is_field_staff': True, + }) + + def test_task_without_order_is_allowed(self): + # repair for a brand-new client: no SO/PO must NOT raise after the relax + t = self.Task.create({ + 'task_type': 'repair', + 'technician_id': self.tech.id, + 'scheduled_date': date(2026, 6, 3), + }) + self.assertTrue(t.id) + + def test_sale_order_has_service_repair_flag(self): + so = self.env['sale.order'].new({}) + self.assertIn('x_fc_is_service_repair', so._fields)