From ace82de88c94e21b6ec95dadb6da3b044f12b5c6 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Thu, 21 May 2026 03:50:58 -0400 Subject: [PATCH] feat(fusion_claims): add dashboard create-SO hotlinks Co-Authored-By: Claude Opus 4.7 (1M context) --- fusion_claims/models/dashboard.py | 50 +++++++++++++++++++++++++++ fusion_claims/tests/test_dashboard.py | 38 ++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/fusion_claims/models/dashboard.py b/fusion_claims/models/dashboard.py index 29386954..0db3f61a 100644 --- a/fusion_claims/models/dashboard.py +++ b/fusion_claims/models/dashboard.py @@ -495,3 +495,53 @@ class FusionClaimsDashboard(models.TransientModel): ], 'target': 'current', } + + # ========================================================================= + # Create-SO hotlinks + # ========================================================================= + def _create_so_action(self, name, ctx_extra): + context = dict(self.env.context) + context.update(ctx_extra) + return { + 'type': 'ir.actions.act_window', + 'name': name, + 'res_model': 'sale.order', + 'view_mode': 'form', + 'view_id': False, + 'context': context, + 'target': 'current', + } + + def action_create_adp_so(self): + return self._create_so_action('New ADP Order', + {'default_x_fc_sale_type': 'adp'}) + + def action_create_mod_so(self): + return self._create_so_action('New MOD Order', + {'default_x_fc_sale_type': 'march_of_dimes'}) + + def action_create_odsp_so(self): + return self._create_so_action('New ODSP Order', { + 'default_x_fc_sale_type': 'odsp', + 'default_x_fc_odsp_division': 'standard', + }) + + def action_create_wsib_so(self): + return self._create_so_action('New WSIB Order', + {'default_x_fc_sale_type': 'wsib'}) + + def action_create_insurance_so(self): + return self._create_so_action('New Insurance Order', + {'default_x_fc_sale_type': 'insurance'}) + + def action_create_mdc_so(self): + return self._create_so_action('New MDC Order', + {'default_x_fc_sale_type': 'muscular_dystrophy'}) + + def action_create_hardship_so(self): + return self._create_so_action('New Hardship Order', + {'default_x_fc_sale_type': 'hardship'}) + + def action_create_private_so(self): + return self._create_so_action('New Private Order', + {'default_x_fc_sale_type': 'direct_private'}) diff --git a/fusion_claims/tests/test_dashboard.py b/fusion_claims/tests/test_dashboard.py index d87f4c94..b15003ef 100644 --- a/fusion_claims/tests/test_dashboard.py +++ b/fusion_claims/tests/test_dashboard.py @@ -327,3 +327,41 @@ class TestFusionClaimsDashboard(TransactionCase): dashboard = self.Dashboard.with_user(self.manager).create({}) action = dashboard.action_open_my_activities() self.assertEqual(action['res_model'], 'mail.activity') + + # ------------------------------------------------------------------------- + # Task 8 — Create-SO hotlinks + # ------------------------------------------------------------------------- + def test_action_create_adp_so_has_default_sale_type(self): + dashboard = self.Dashboard.with_user(self.manager).create({}) + action = dashboard.action_create_adp_so() + self.assertEqual(action['res_model'], 'sale.order') + self.assertEqual(action['view_mode'], 'form') + self.assertEqual(action['context']['default_x_fc_sale_type'], 'adp') + + def test_action_create_mod_so_has_default_sale_type(self): + dashboard = self.Dashboard.with_user(self.manager).create({}) + action = dashboard.action_create_mod_so() + self.assertEqual(action['context']['default_x_fc_sale_type'], 'march_of_dimes') + + def test_action_create_odsp_so_has_division_default(self): + dashboard = self.Dashboard.with_user(self.manager).create({}) + action = dashboard.action_create_odsp_so() + self.assertEqual(action['context']['default_x_fc_sale_type'], 'odsp') + self.assertEqual(action['context']['default_x_fc_odsp_division'], 'standard') + + def test_all_create_so_actions_exist(self): + dashboard = self.Dashboard.with_user(self.manager).create({}) + for method_name, expected_type in [ + ('action_create_adp_so', 'adp'), + ('action_create_mod_so', 'march_of_dimes'), + ('action_create_odsp_so', 'odsp'), + ('action_create_wsib_so', 'wsib'), + ('action_create_insurance_so', 'insurance'), + ('action_create_mdc_so', 'muscular_dystrophy'), + ('action_create_hardship_so', 'hardship'), + ('action_create_private_so', 'direct_private'), + ]: + action = getattr(dashboard, method_name)() + self.assertEqual(action['res_model'], 'sale.order') + self.assertEqual(action['context']['default_x_fc_sale_type'], expected_type, + f"{method_name} returned wrong default sale type")