diff --git a/addons/crm/views/utm_campaign_views.xml b/addons/crm/views/utm_campaign_views.xml index a134c2b1b0d..baff90d8c33 100644 --- a/addons/crm/views/utm_campaign_views.xml +++ b/addons/crm/views/utm_campaign_views.xml @@ -8,12 +8,21 @@ - -
- -
+ + + Leads + + + Opportunities + + + + + + + diff --git a/addons/link_tracker/views/utm_campaign_views.xml b/addons/link_tracker/views/utm_campaign_views.xml index 21d9b4a3ede..8da189f3198 100644 --- a/addons/link_tracker/views/utm_campaign_views.xml +++ b/addons/link_tracker/views/utm_campaign_views.xml @@ -22,12 +22,16 @@ - -
- -
+ + + + + + + - diff --git a/addons/sale/views/utm_campaign_views.xml b/addons/sale/views/utm_campaign_views.xml index 7e2132d72f4..d47a9ddabab 100644 --- a/addons/sale/views/utm_campaign_views.xml +++ b/addons/sale/views/utm_campaign_views.xml @@ -6,16 +6,23 @@ utm.campaign - -
- - + + + + - -
-
- -
+ +
+ + + + + +
diff --git a/addons/utm/models/utm_campaign.py b/addons/utm/models/utm_campaign.py index ecf5f77a73f..603f6c6ae74 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) @@ -19,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/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..ed945e9f1b0 100644 --- a/addons/utm/views/utm_campaign_views.xml +++ b/addons/utm/views/utm_campaign_views.xml @@ -9,11 +9,17 @@ + + + + @@ -30,7 +36,9 @@
+ + @@ -48,10 +56,10 @@ utm.campaign - + - - + + @@ -67,7 +75,7 @@ - +
@@ -81,6 +89,7 @@ + @@ -89,6 +98,10 @@ Delete + + Archive + Restore +
-
+
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 - + 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