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.
In a new module
We add three models:
with a unique constraint on the name.
We define a mixin with:
they are filled using default value in the context by creating if necessary the record if the name does not already exist.
sale.sale model is extended with the mixin (using extra_depends) and the fields are added to the form view for manual encoding.
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.
sale.opportunity model is also extended with the mixin and the values are passed to the created sales.
sale.point.sale model is also extended with the mixin and the reporting must include the new fields.
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 - Shopify Community).