diff options
| author | David Beguin <dbe@odoo.com> | 2020-05-11 10:36:26 +0000 |
|---|---|---|
| committer | David Beguin <dbe@odoo.com> | 2020-09-14 14:26:19 +0000 |
| commit | cd291b79eb2d2df80899867263ec71438ab8fe87 (patch) | |
| tree | 57694f7a4c98deac88e36084316278c4e48bfee3 /addons/crm/data | |
| parent | 9606e9e231be9e1e7d15ea0efdedbf5afff47102 (diff) | |
[IMP] crm: Disable pls cron and autoincrement frequencies when won/lost
Purpose
=======
Get rid of the cron.
Always have an up to date frequency table to compute lead probability.
Clean PLS code and ensure to remove unnecessary code
Specifications
==============
Disable the cron:
- Increment won and lost count for lead PLS params from frequency table at
each won/lost
- The complete set of leads won't be recomputed anymore every day
- A lead probability will only be recomputed if one of the PLS parameter will
be modified (stage_id, team_id + the ones checked in settings)
- No more onboarding phase : as frequency table is always up to date and only
the modified leads are recomputed, we can drop this. (So even on onboarding,
winning or losing a lead won't impact other leads, except the ones we modify
manually afterwards)
- Add an button to force the recompute of all the lead probabilities
(kind of reset) in the settings.
The cron has been disabled by default.
Users can know choose to reactivate it if they want to continue updating their
lead probabilities on a daily basis.
Code have been reorganised for better structure and understanding.
Some code parts have been factorised to be usable in both Live Increment and
Full Rebuild mode.
In this commit, we also update probabilities using only computes
Before this commit, _update_probability was called during write and create,
to ensure both probability and automated_probability were correct. That was
necessary because of onchanges and readonly field (automated_probability
was not given to the write method while saving after a change on the lead).
After this commit, we use the force_save tag on the readonly field
automated_probability. So we ensure that write always receives the new
automated_probability value and everything can be handled directly by the
compute. Also, we force the lead to start in automated probability mode.
So when creating a new lead, both probability and automated probability are
computed and aligned.
Finally, when winning a lead, we ensure that both probabilities are aligned
(=100), so that if user take the lead back to a previous stage, the
probabilities are correctly recomputed, and the lead will not be stuck to
100%.
Also, this commit applies some fix and minor changes listed here under:
- Ensure to have always positive frequencies
- Fix lost counts for team not set in pls computation
- optimise set_won : write only once per values
Finally, include tag in frequency table even if less than 50 occurences:
Due to refactoring in which we increment frequency table at each won/lost
instead of rebuilding the frequency table each day, the tags are never added
in frequency table.
This is due to the 50 occurence conditions that avoid to create the frequency
if we have less than 50 won or lost for a tag.
After this commit, we include the tag_ids in the frequency table, no matter
the number of occurences. But, during the PLS computation, we skip the tag
frequencies if the number of occurences for this tag is under 50.
This allows to have a complete vision on the tag frequencies, even for
small number of occurences.
Task ID : 2254543
Diffstat (limited to 'addons/crm/data')
| -rw-r--r-- | addons/crm/data/crm_lead_prediction_data.xml | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/addons/crm/data/crm_lead_prediction_data.xml b/addons/crm/data/crm_lead_prediction_data.xml index e37c6c36e7c..83e62782b3c 100644 --- a/addons/crm/data/crm_lead_prediction_data.xml +++ b/addons/crm/data/crm_lead_prediction_data.xml @@ -28,21 +28,17 @@ <field name="key">crm.pls_start_date</field> <field name="value" eval="(datetime.now() - timedelta(days=8)).strftime('%Y-%m-%d')"/> </record> - <record id="crm_pls_rebuild_threshold_param" model="ir.config_parameter"> - <field name="key">crm.pls_rebuild_threshold</field> - <field name="value">100</field> - </record> </data> <record id="website_crm_score_cron" model="ir.cron"> - <field name="name">Predictive Lead Scoring: Rebuild Frequencies table</field> + <field name="name">Predictive Lead Scoring: Recompute Automated Probabilities</field> <field name="model_id" ref="model_crm_lead"/> <field name="state">code</field> <field name="code">model._cron_update_automated_probabilities()</field> <field name="interval_number">1</field> <field name="interval_type">days</field> <field name="numbercall">-1</field> - <field name="active" eval="True"/> + <field name="active" eval="False"/> <field name="doall" eval="False"/> </record> </odoo> |
