From 7f6c66bd5e662fdc58b0abe8056185178331ba40 Mon Sep 17 00:00:00 2001 From: amdi-odoo Date: Wed, 29 Mar 2023 12:19:34 +0000 Subject: [PATCH 1/4] [IMP] utm: allow archiving campaigns Allow archiving campaigns from the form and kanban views. Add the "Archived" filter. Task-3240966 Part-of: odoo/odoo#116230 --- addons/utm/models/utm_campaign.py | 1 + addons/utm/models/utm_mixin.py | 2 +- addons/utm/tests/test_utm.py | 8 ++++++++ addons/utm/views/utm_campaign_views.xml | 8 ++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/addons/utm/models/utm_campaign.py b/addons/utm/models/utm_campaign.py index ecf5f77a73f..924a67a3214 100644 --- a/addons/utm/models/utm_campaign.py +++ b/addons/utm/models/utm_campaign.py @@ -9,6 +9,7 @@ class UtmCampaign(models.Model): _description = 'UTM Campaign' _rec_name = 'title' + active = fields.Boolean('Active', default=True) name = fields.Char(string='Campaign Identifier', required=True, compute='_compute_name', store=True, readonly=False, precompute=True, translate=False) title = fields.Char(string='Campaign Name', required=True, translate=True) diff --git a/addons/utm/models/utm_mixin.py b/addons/utm/models/utm_mixin.py index 515c244826c..afb4b78b975 100644 --- a/addons/utm/models/utm_mixin.py +++ b/addons/utm/models/utm_mixin.py @@ -62,7 +62,7 @@ class UtmMixin(models.AbstractModel): """Based on the model name and on the name of the record, retrieve the corresponding record or create it.""" Model = self.env[model_name] - record = Model.search([('name', '=', name)], limit=1) + record = Model.with_context(active_test=False).search([('name', '=', name)], limit=1) if not record: # No record found, create a new one diff --git a/addons/utm/tests/test_utm.py b/addons/utm/tests/test_utm.py index 5a05724061c..133490489d0 100644 --- a/addons/utm/tests/test_utm.py +++ b/addons/utm/tests/test_utm.py @@ -21,6 +21,14 @@ class TestUtm(TestUTMCommon): self.assertNotIn(source_4, source_1 | source_2) self.assertEqual(source_4.name, 'Source 3') + def test_find_or_create_with_archived_record(self): + archived_campaign = self.env['utm.campaign'].create([{ + 'active': False, + 'name': 'Archived Campaign', + }]) + campaign = self.env['utm.mixin']._find_or_create_record('utm.campaign', 'Archived Campaign') + self.assertEqual(archived_campaign, campaign, "An archived record must be found instead of re-created.") + def test_name_generation(self): """Test that the name is always unique. diff --git a/addons/utm/views/utm_campaign_views.xml b/addons/utm/views/utm_campaign_views.xml index b86561ed3f4..cb34c83235e 100644 --- a/addons/utm/views/utm_campaign_views.xml +++ b/addons/utm/views/utm_campaign_views.xml @@ -9,6 +9,7 @@ + @@ -30,7 +31,9 @@
+ + @@ -81,6 +84,7 @@ + @@ -89,6 +93,10 @@ Delete + + Archive + Restore +
-
+
From d9eea928b3379f481dd17afe830a9cb738829f68 Mon Sep 17 00:00:00 2001 From: amdi-odoo Date: Wed, 12 Apr 2023 09:57:16 +0000 Subject: [PATCH 3/4] [IMP] utm: improve campaign UI Purpose ======= Give users a better experience while using the utm campaign module. Specifications ============== * Add a filter called "My Campaigns" filtering on the current user_id. * Add a groupby Tags. * Always underline the Tags field in the campaign quick create. * When duplicating a campaign, do not copy the stage and make it restart the pipe. * In the list view: - Change the column name from "Campaign Name" to "Name". - Add bold on the stage field. - Add the avatar widget to the Responsible field. * For the edit stage modal: - Make the dialog smaller. - Only display the name field. - Add a placeholder to the name field. Task-3240966 Part-of: odoo/odoo#116230 --- addons/utm/models/utm_campaign.py | 2 +- addons/utm/views/utm_campaign_views.xml | 13 +++++++++---- addons/utm/views/utm_stage_views.xml | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/addons/utm/models/utm_campaign.py b/addons/utm/models/utm_campaign.py index 924a67a3214..603f6c6ae74 100644 --- a/addons/utm/models/utm_campaign.py +++ b/addons/utm/models/utm_campaign.py @@ -20,7 +20,7 @@ class UtmCampaign(models.Model): stage_id = fields.Many2one( 'utm.stage', string='Stage', ondelete='restrict', required=True, default=lambda self: self.env['utm.stage'].search([], limit=1), - group_expand='_group_expand_stage_ids') + copy=False, group_expand='_group_expand_stage_ids') tag_ids = fields.Many2many( 'utm.tag', 'utm_tag_rel', 'tag_id', 'campaign_id', string='Tags') diff --git a/addons/utm/views/utm_campaign_views.xml b/addons/utm/views/utm_campaign_views.xml index 9a5b25d2ad8..ed945e9f1b0 100644 --- a/addons/utm/views/utm_campaign_views.xml +++ b/addons/utm/views/utm_campaign_views.xml @@ -9,12 +9,17 @@ + + + @@ -51,10 +56,10 @@ utm.campaign - + - - + + @@ -70,7 +75,7 @@ - + diff --git a/addons/utm/views/utm_stage_views.xml b/addons/utm/views/utm_stage_views.xml index 1500e29e6d8..bbc6c9caaf5 100644 --- a/addons/utm/views/utm_stage_views.xml +++ b/addons/utm/views/utm_stage_views.xml @@ -22,6 +22,22 @@ + + utm.stage.view.form + utm.stage + +
+ + + + + + + +
+
+
+ UTM Stages utm.stage From 64dd4bed9d2860fbed01266e9656aa83330ea211 Mon Sep 17 00:00:00 2001 From: amdi-odoo Date: Wed, 22 Mar 2023 15:06:02 +0000 Subject: [PATCH 4/4] [IMP] link_tracker: add placeholders Add placeholders to the mediums and sources tree views. Task-3240966 Part-of: odoo/odoo#116230 --- addons/utm/views/utm_medium_views.xml | 2 +- addons/utm/views/utm_source_views.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/utm/views/utm_medium_views.xml b/addons/utm/views/utm_medium_views.xml index 394bca00436..74ee151e1f1 100644 --- a/addons/utm/views/utm_medium_views.xml +++ b/addons/utm/views/utm_medium_views.xml @@ -5,7 +5,7 @@ utm.medium - + diff --git a/addons/utm/views/utm_source_views.xml b/addons/utm/views/utm_source_views.xml index af2fee6fa08..f9fb4fd7553 100644 --- a/addons/utm/views/utm_source_views.xml +++ b/addons/utm/views/utm_source_views.xml @@ -5,7 +5,7 @@ utm.source - +