Rational
When doing marketing campaign, it is often useful to be able to measure its impact. So it will be great to be able to link together documents created thanks to the campaign.
The common data that are collected are the UTM parameters - Wikipedia.
Proposal
In a new module marketing_campaign:
We add three models: marketing.campaign, marketing.medium, marketing.source with:
nameactive
with a unique constraint on the name.
We define a mixin with:
marketing_campaign:Many2Onetomarketing.campaignmarketing_medium:Many2Onetomarketing.mediummarketing_source:Many2Onetomarketing.source
they are filled using default value in the context by creating if necessary the record if the name does not already exist.
The sale.sale model is extended with the mixin (using extra_depends) and the fields are added to the form view for manual encoding.
The sale.reporting.context is also extended to add the three fields as filter and all sale_reporting.Abstract classes are extended to filter by those values.
A new report is added to group by one or more of the three fields.
The sale.opportunity model is also extended with the mixin and the values are passed to the created sales.
The sale.point.sale model is also extended with the mixin and the reporting must include the new fields.
The Sale.get_from_shopify is extended to parse the landing_site attribute and find the UTM parameters (as suggested by How to get the UTM parameters associated with the order through rest admin API - Customers Discounts And Orders - Shopify Community).