Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master crm onchange to compute fle tde #41955

Open
wants to merge 7 commits into
base: master
from

Conversation

@tde-banana-odoo
Copy link
Contributor

tde-banana-odoo commented Dec 16, 2019

No description provided.

@robodoo robodoo added the seen 🙂 label Dec 16, 2019
@C3POdoo C3POdoo added the RD label Dec 16, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 16, 2019
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Normally behavior should be the same (computed or set by user), with support
in create / write + onchange without additional code.

SPECIFICATIONS

Update classic fields with onchange to stored editable computed fields. It
means their value will come either from manual user input, either computed
based on triggers. Purpose is to remove all onchange and default_get when
possible.

Clean fields definition inconsistencies, like default / required on computed
fields. Indeed computed fields should always have a value, maybe coming from
user input. They should not have default / required that are attributes for
classic fields.

this commit as has purpose to replace onchange to compute fields.
There are some issues with fields being changed by onchange (view only).
The purpose of this task is
to move that behavior at model level by using computed fields now that they behave
more like onchange.

LINKS

Task ID 2088565
PR odoo#41955
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from d689b78 to f3351dc Dec 16, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
SPECIFICATIONS

Fixes following issue: when a lead is marked as lost, the probability is
correctly set to 0 but not the automatic one. If one clicks on the "Set to
automatic", the probability is updated, which un-archives it without really
restoring it, meaning we get in a very strange state outside the expected flow
(no Won/Lost buttons, ...).

With this commit the automated probability is set to 0 when setting as lost.
Moreover restoring a lead recomputes its probabilities.

LINKS

Task ID 2092799
PR odoo#41955
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
In this commit we perform some small code move in order to better understand
the huge crm_lead.py file. Notably

  * add some code sections headers (actions, PLS, opp/leads merge);
  * move crm.lead.tag and crm.lost.reason in their own file;

No functional change occur with this commit as it contains only some code
move.

LINKS

Task ID 2088565
PR odoo#41955
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Normally behavior should be the same (computed or set by user), with support
in create / write + onchange without additional code.

SPECIFICATIONS

Update classic fields with onchange to stored editable computed fields. It
means their value will come either from manual user input, either computed
based on triggers. Purpose is to remove all onchange and default_get when
possible.

Clean fields definition inconsistencies, like default / required on computed
fields. Indeed computed fields should always have a value, maybe coming from
user input. They should not have default / required that are attributes for
classic fields.

this commit as has purpose to replace onchange to compute fields.
There are some issues with fields being changed by onchange (view only).
The purpose of this task is
to move that behavior at model level by using computed fields now that they behave
more like onchange.

LINKS

Task ID 2092799
PR odoo#41955
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from f3351dc to 8b7ce4d Dec 17, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
SPECIFICATIONS

Fixes following issue: when a lead is marked as lost, the probability is
correctly set to 0 but not the automatic one. If one clicks on the "Set to
automatic", the probability is updated, which un-archives it without really
restoring it, meaning we get in a very strange state outside the expected flow
(no Won/Lost buttons, ...).

With this commit the automated probability is set to 0 when setting as lost.
Moreover restoring a lead recomputes its probabilities.

LINKS

Task ID 2092799
PR odoo#41955
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
In this commit we perform some small code move in order to better understand
the huge crm_lead.py file. Notably

  * add some code sections headers (actions, PLS, opp/leads merge);
  * move crm.lead.tag and crm.lost.reason in their own file;

No functional change occur with this commit as it contains only some code
move.

LINKS

Task ID 2088565
PR odoo#41955
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Normally behavior should be the same (computed or set by user), with support
in create / write + onchange without additional code.

SPECIFICATIONS

Update classic fields with onchange to stored editable computed fields. It
means their value will come either from manual user input, either computed
based on triggers. Purpose is to remove all onchange and default_get when
possible.

Clean fields definition inconsistencies, like default / required on computed
fields. Indeed computed fields should always have a value, maybe coming from
user input. They should not have default / required that are attributes for
classic fields.

this commit as has purpose to replace onchange to compute fields.
There are some issues with fields being changed by onchange (view only).
The purpose of this task is
to move that behavior at model level by using computed fields now that they behave
more like onchange.

LINKS

Task ID 2092799
PR odoo#41955
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from 8b7ce4d to 60ac6ee Dec 17, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
SPECIFICATIONS

Fixes following issue: when a lead is marked as lost, the probability is
correctly set to 0 but not the automatic one. If one clicks on the "Set to
automatic", the probability is updated, which un-archives it without really
restoring it, meaning we get in a very strange state outside the expected flow
(no Won/Lost buttons, ...).

With this commit the automated probability is set to 0 when setting as lost.
Moreover restoring a lead recomputes its probabilities.

LINKS

Task ID 2092799
PR odoo#41955
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
In this commit we perform some small code move in order to better understand
the huge crm_lead.py file. Notably

  * add some code sections headers (actions, PLS, opp/leads merge);
  * move crm.lead.tag and crm.lost.reason in their own file;

No functional change occur with this commit as it contains only some code
move.

LINKS

Task ID 2088565
PR odoo#41955
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Normally behavior should be the same (computed or set by user), with support
in create / write + onchange without additional code.

SPECIFICATIONS

Update classic fields with onchange to stored editable computed fields. It
means their value will come either from manual user input, either computed
based on triggers. Purpose is to remove all onchange and default_get when
possible.

Clean fields definition inconsistencies, like default / required on computed
fields. Indeed computed fields should always have a value, maybe coming from
user input. They should not have default / required that are attributes for
classic fields.

this commit as has purpose to replace onchange to compute fields.
There are some issues with fields being changed by onchange (view only).
The purpose of this task is
to move that behavior at model level by using computed fields now that they behave
more like onchange.

LINKS

Task ID 2092799
PR odoo#41955
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from 60ac6ee to f212572 Dec 17, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
In this commit we perform some small code move in order to better understand
the huge crm_lead.py file. Notably

  * add some code sections headers (actions, PLS, opp/leads merge);
  * move crm.lead.tag and crm.lost.reason in their own file;
  * reorganize fields by main category because it is a mess;

No functional change occur with this commit as it contains only some code
move.

LINKS

Task ID 2088565
PR odoo#41955
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Normally behavior should be the same (computed or set by user), with support
in create / write + onchange without additional code.

SPECIFICATIONS

Update classic fields with onchange to stored editable computed fields. It
means their value will come either from manual user input, either computed
based on triggers. Purpose is to remove all onchange and default_get when
possible.

Clean fields definition inconsistencies, like default / required on computed
fields. Indeed computed fields should always have a value, maybe coming from
user input. They should not have default / required that are attributes for
classic fields.

this commit as has purpose to replace onchange to compute fields.
There are some issues with fields being changed by onchange (view only).
The purpose of this task is
to move that behavior at model level by using computed fields now that they behave
more like onchange.

LINKS

Task ID 2092799
PR odoo#41955
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from f212572 to cca5a5d Dec 17, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
In this commit we perform some small code move in order to better understand
the huge crm_lead.py file. Notably

  * add some code sections headers (actions, PLS, opp/leads merge);
  * move crm.lead.tag and crm.lost.reason in their own file;
  * reorganize fields by main category because it is a mess;
  * remove some unnecessary help messages;
  * merge two _auto_init methods definition;

No functional change occur with this commit as it contains only some code
move.

LINKS

Task ID 2088565
PR odoo#41955
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Normally behavior should be the same (computed or set by user), with support
in create / write + onchange without additional code.

SPECIFICATIONS

Update classic fields with onchange to stored editable computed fields. It
means their value will come either from manual user input, either computed
based on triggers. Purpose is to remove all onchange and default_get when
possible.

Clean fields definition inconsistencies, like default / required on computed
fields. Indeed computed fields should always have a value, maybe coming from
user input. They should not have default / required that are attributes for
classic fields.

this commit as has purpose to replace onchange to compute fields.
There are some issues with fields being changed by onchange (view only).
The purpose of this task is
to move that behavior at model level by using computed fields now that they behave
more like onchange.

LINKS

Task ID 2092799
PR odoo#41955
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from cca5a5d to 52100a0 Dec 17, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
SPECIFICATIONS

Fixes following issue: when a lead is marked as lost, the probability is
correctly set to 0 but not the automatic one. If one clicks on the "Set to
automatic", the probability is updated, which un-archives it without really
restoring it, meaning we get in a very strange state outside the expected flow
(no Won/Lost buttons, ...).

With this commit the automated probability is set to 0 when setting as lost.
Moreover restoring a lead recomputes its probabilities.

LINKS

Task ID 2092799
PR odoo#41955
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
In this commit we perform some small code move in order to better understand
the huge crm_lead.py file. Notably

  * add some code sections headers (actions, PLS, opp/leads merge);
  * move crm.lead.tag and crm.lost.reason in their own file;
  * reorganize fields by main category because it is a mess;
  * remove some unnecessary help messages;
  * merge two _auto_init methods definition;

No functional change occur with this commit as it contains only some code
move.

LINKS

Task ID 2088565
PR odoo#41955
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Normally behavior should be the same (computed or set by user), with support
in create / write + onchange without additional code.

SPECIFICATIONS

Update classic fields with onchange to stored editable computed fields. It
means their value will come either from manual user input, either computed
based on triggers. Purpose is to remove all onchange and default_get when
possible.

Clean fields definition inconsistencies, like default / required on computed
fields. Indeed computed fields should always have a value, maybe coming from
user input. They should not have default / required that are attributes for
classic fields.

this commit as has purpose to replace onchange to compute fields.
There are some issues with fields being changed by onchange (view only).
The purpose of this task is
to move that behavior at model level by using computed fields now that they behave
more like onchange.

LINKS

Task ID 2092799
PR odoo#41955
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from 52100a0 to 60b96b7 Dec 17, 2019
@robodoo robodoo added the CI 🤖 label Dec 17, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 17, 2019
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Normally behavior should be the same (computed or set by user), with support
in create / write + onchange without additional code.

SPECIFICATIONS

Update classic fields with onchange to stored editable computed fields. It
means their value will come either from manual user input, either computed
based on triggers. Purpose is to remove all onchange and default_get when
possible.

Clean fields definition inconsistencies, like default / required on computed
fields. Indeed computed fields should always have a value, maybe coming from
user input. They should not have default / required that are attributes for
classic fields.

Some other fields attributes are cleaned whenever found while writing this
commit, notably removing unnecessary indexes, reordering tracking sequences,
removing useless helps / improving strings and helps.

In this commit we also remove all the better implementations of "not really a
constraint" constraint about user_id and team_id. Indeed as this is a computed
field normally we should not have to call the onchange manually, even through
a hackish call to a falsy constraint (see fdc8749, 222cca2, 4e8ebc7 ). You are
all inferior to SM team.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from 60b96b7 to 15f32a8 Dec 17, 2019
@robodoo robodoo removed the CI 🤖 label Dec 17, 2019
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from b7e0117 to 62b0011 Jan 17, 2020
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based computation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

SPECIFIATIONS: CONSTRAINT USER_ID / TEAM_ID

In this commit we also remove all the better implementations of "not really a
constraint" constraint about user_id and team_id. Indeed as this is a computed
field normally we should not have to call the onchange manually, even through
a hackish call to a falsy constraint (see fdc8749, 222cca2, 4e8ebc7 ). You are
all inferior to SM team.

SPECIFIATIONS: DATE_OPEN

Assignation field, namely ``date_open``, has a random definition as it seems
linked to assignation, with several behaviors intended

  * ce39ca8 : reset only when going from
    no salesman to a salesman (aka, keep assignation when changing)
  * 8e54055: reset when changing salesman

We choose to keep first implementation as it seems a bugfix broken again
by second commit. It will also replace the ``assign_date`` defined in
``website_crm_score`` module.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322

Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Florent Lejoly <fle@odoo.com>
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
…ored editable computed fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based coputation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

In this commit we also rename ``date_assign`` to ``date_partner_assign``, because
there are already ``date_open`` (crm_lead) and ``assign_date`` (website scoring)
fields available. It may be confusing. The field is therefore renamed to better
indicate it is linked to partner assignment.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
…am model

PURPOSE

Purpose of this commit is to clean statistics fields definition on crm.team.
Future tasks will improve the use of sales team in crm and first steps is to
clean a bit models linked to sales team.

SPECIFICATIONS

New statistic fields

  * ``lead_all_assigned_month_count``: all assigned lead and opportunities
    in the last 30 days; used notably for scoring mechanism;

Renaming performed on some statistic fields

  * ``unassigned_leads_count`` -> ``lead_unassigned_count``;
  * ``overdue_opportunities_count`` -> ``opportunities_overdue_count``;
  * ``overdue_opportunities_amount`` -> ``opportunities_overdue_amount``;

All those fields are used for display and management purpose, and are
computed not stored fields. No migration is therefore required.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
PURPOSE

This refactoring commit removes the crm.partner.binding mixin. Indeed it
defines a mixin for unnecessary fields, generally either redefined in
inheriting models, either not used at all. It also holds an utility method
we moved directly on crm.lead model.

SPECIFICATIONS

Code move

  * move _find_matching_partner to crm.lead model;
  * move action field into inheriting models, except crm.lead.convert2ticket
    that does not use it;
  * move partner_id to inheriting models;
  * remove crm.partner.binding model and inheritance;

Improve behavior

  * correctly store lead and partner many2one fields on all inheriting
    models. It allows to support a default_lead_id instead of always
    relying on active_model / active_id, making the wizards more generic;
  * update default_get accordingly in various inheriting models in order to
    correctly compute lead / partner values;

LINKS

Task ID 2056759 (remove crm.partner.binding mixin)
Task ID 2088565 (convert onchange / default to compute)
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
PURPOSE

As crm will soon evolve (onchange -> compute, code improvements, better
management of sales teams) cleaning and improving tests is necessary to avoid
regressions.

SPECIFICATIONS

Purpose of this commit is to rewrite code located in convert wizards. Indeed
it holds unnecessary variables, dictionaries manipulation that hides the
real business flow, badly named variables, unclear methods, ...

Logic of those wizards seem quite simple but is hidden behind a wall of
bloated code.

LINKS

Task ID 2056759 (remove crm.partner.binding mixin)
Task ID 2088565 (convert onchange / default to compute)
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from 62b0011 to 5141dd2 Jan 17, 2020
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based computation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

SPECIFIATIONS: CONSTRAINT USER_ID / TEAM_ID

In this commit we also remove all the better implementations of "not really a
constraint" constraint about user_id and team_id. Indeed as this is a computed
field normally we should not have to call the onchange manually, even through
a hackish call to a falsy constraint (see fdc8749, 222cca2, 4e8ebc7 ). You are
all inferior to SM team.

SPECIFIATIONS: DATE_OPEN

Assignation field, namely ``date_open``, has a random definition as it seems
linked to assignation, with several behaviors intended

  * ce39ca8 : reset only when going from
    no salesman to a salesman (aka, keep assignation when changing)
  * 8e54055: reset when changing salesman

We choose to keep first implementation as it seems a bugfix broken again
by second commit. It will also replace the ``assign_date`` defined in
``website_crm_score`` module.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322

Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Florent Lejoly <fle@odoo.com>
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
…ored editable computed fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based coputation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

In this commit we also rename ``date_assign`` to ``date_partner_assign``, because
there are already ``date_open`` (crm_lead) and ``assign_date`` (website scoring)
fields available. It may be confusing. The field is therefore renamed to better
indicate it is linked to partner assignment.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
…am model

PURPOSE

Purpose of this commit is to clean statistics fields definition on crm.team.
Future tasks will improve the use of sales team in crm and first steps is to
clean a bit models linked to sales team.

SPECIFICATIONS

New statistic fields

  * ``lead_all_assigned_month_count``: all assigned lead and opportunities
    in the last 30 days; used notably for scoring mechanism;

Renaming performed on some statistic fields

  * ``unassigned_leads_count`` -> ``lead_unassigned_count``;
  * ``overdue_opportunities_count`` -> ``opportunities_overdue_count``;
  * ``overdue_opportunities_amount`` -> ``opportunities_overdue_amount``;

All those fields are used for display and management purpose, and are
computed not stored fields. No migration is therefore required.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
PURPOSE

This refactoring commit removes the crm.partner.binding mixin. Indeed it
defines a mixin for unnecessary fields, generally either redefined in
inheriting models, either not used at all. It also holds an utility method
we moved directly on crm.lead model.

SPECIFICATIONS

Code move

  * move _find_matching_partner to crm.lead model;
  * move action field into inheriting models, except crm.lead.convert2ticket
    that does not use it;
  * move partner_id to inheriting models;
  * remove crm.partner.binding model and inheritance;

Improve behavior

  * correctly store lead and partner many2one fields on all inheriting
    models. It allows to support a default_lead_id instead of always
    relying on active_model / active_id, making the wizards more generic;
  * update default_get accordingly in various inheriting models in order to
    correctly compute lead / partner values;

LINKS

Task ID 2056759 (remove crm.partner.binding mixin)
Task ID 2088565 (convert onchange / default to compute)
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
PURPOSE

As crm will soon evolve (onchange -> compute, code improvements, better
management of sales teams) cleaning and improving tests is necessary to avoid
regressions.

SPECIFICATIONS

Purpose of this commit is to rewrite code located in convert wizards. Indeed
it holds unnecessary variables, dictionaries manipulation that hides the
real business flow, badly named variables, unclear methods, ...

Logic of those wizards seem quite simple but is hidden behind a wall of
bloated code.

LINKS

Task ID 2056759 (remove crm.partner.binding mixin)
Task ID 2088565 (convert onchange / default to compute)
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from 5141dd2 to f6c59dc Jan 17, 2020
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based computation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

SPECIFIATIONS: CONSTRAINT USER_ID / TEAM_ID

In this commit we also remove all the better implementations of "not really a
constraint" constraint about user_id and team_id. Indeed as this is a computed
field normally we should not have to call the onchange manually, even through
a hackish call to a falsy constraint (see fdc8749, 222cca2, 4e8ebc7 ). You are
all inferior to SM team.

SPECIFIATIONS: DATE_OPEN

Assignation field, namely ``date_open``, has a random definition as it seems
linked to assignation, with several behaviors intended

  * ce39ca8 : reset only when going from
    no salesman to a salesman (aka, keep assignation when changing)
  * 8e54055: reset when changing salesman

We choose to keep first implementation as it seems a bugfix broken again
by second commit. It will also replace the ``assign_date`` defined in
``website_crm_score`` module.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322

Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Florent Lejoly <fle@odoo.com>
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
…ored editable computed fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based coputation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

In this commit we also rename ``date_assign`` to ``date_partner_assign``, because
there are already ``date_open`` (crm_lead) and ``assign_date`` (website scoring)
fields available. It may be confusing. The field is therefore renamed to better
indicate it is linked to partner assignment.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2020
…am model

PURPOSE

Purpose of this commit is to clean statistics fields definition on crm.team.
Future tasks will improve the use of sales team in crm and first steps is to
clean a bit models linked to sales team.

SPECIFICATIONS

New statistic fields

  * ``lead_all_assigned_month_count``: all assigned lead and opportunities
    in the last 30 days; used notably for scoring mechanism;

Renaming performed on some statistic fields

  * ``unassigned_leads_count`` -> ``lead_unassigned_count``;
  * ``overdue_opportunities_count`` -> ``opportunities_overdue_count``;
  * ``overdue_opportunities_amount`` -> ``opportunities_overdue_amount``;

All those fields are used for display and management purpose, and are
computed not stored fields. No migration is therefore required.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 24, 2020
PURPOSE

This refactoring commit removes the crm.partner.binding mixin. Indeed it
defines a mixin for unnecessary fields, generally either redefined in
inheriting models, either not used at all. It also holds an utility method
we moved directly on crm.lead model.

SPECIFICATIONS

Code move

  * move _find_matching_partner to crm.lead model;
  * move action field into inheriting models, except crm.lead.convert2ticket
    that does not use it;
  * move partner_id to inheriting models;
  * remove crm.partner.binding model and inheritance;

Improve behavior

  * correctly store lead and partner many2one fields on all inheriting
    models. It allows to support a default_lead_id instead of always
    relying on active_model / active_id, making the wizards more generic;
  * update default_get accordingly in various inheriting models in order to
    correctly compute lead / partner values;

LINKS

Task ID 2056759 (remove crm.partner.binding mixin)
Task ID 2088565 (convert onchange / default to compute)
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 24, 2020
PURPOSE

As crm will soon evolve (onchange -> compute, code improvements, better
management of sales teams) cleaning and improving tests is necessary to avoid
regressions.

SPECIFICATIONS

Purpose of this commit is to rewrite code located in convert wizards. Indeed
it holds unnecessary variables, dictionaries manipulation that hides the
real business flow, badly named variables, unclear methods, ...

Logic of those wizards seem quite simple but is hidden behind a wall of
bloated code.

LINKS

Task ID 2056759 (remove crm.partner.binding mixin)
Task ID 2088565 (convert onchange / default to compute)
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from f6c59dc to a7e9e45 Jan 24, 2020
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 24, 2020
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based computation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

SPECIFIATIONS: CONSTRAINT USER_ID / TEAM_ID

In this commit we also remove all the better implementations of "not really a
constraint" constraint about user_id and team_id. Indeed as this is a computed
field normally we should not have to call the onchange manually, even through
a hackish call to a falsy constraint (see fdc8749, 222cca2, 4e8ebc7 ). You are
all inferior to SM team.

SPECIFIATIONS: DATE_OPEN

Assignation field, namely ``date_open``, has a random definition as it seems
linked to assignation, with several behaviors intended

  * ce39ca8 : reset only when going from
    no salesman to a salesman (aka, keep assignation when changing)
  * 8e54055: reset when changing salesman

We choose to keep first implementation as it seems a bugfix broken again
by second commit. It will also replace the ``assign_date`` defined in
``website_crm_score`` module.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322

Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Florent Lejoly <fle@odoo.com>
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 24, 2020
…ored editable computed fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based coputation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

In this commit we also rename ``date_assign`` to ``date_partner_assign``, because
there are already ``date_open`` (crm_lead) and ``assign_date`` (website scoring)
fields available. It may be confusing. The field is therefore renamed to better
indicate it is linked to partner assignment.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 24, 2020
…am model

PURPOSE

Purpose of this commit is to clean statistics fields definition on crm.team.
Future tasks will improve the use of sales team in crm and first steps is to
clean a bit models linked to sales team.

SPECIFICATIONS

New statistic fields

  * ``lead_all_assigned_month_count``: all assigned lead and opportunities
    in the last 30 days; used notably for scoring mechanism;

Renaming performed on some statistic fields

  * ``unassigned_leads_count`` -> ``lead_unassigned_count``;
  * ``overdue_opportunities_count`` -> ``opportunities_overdue_count``;
  * ``overdue_opportunities_amount`` -> ``opportunities_overdue_amount``;

All those fields are used for display and management purpose, and are
computed not stored fields. No migration is therefore required.

LINKS

Task ID 2088565
Community PR odoo#41955
Enterprise PR odoo/enterprise#7322
tde-banana-odoo and others added 7 commits Jan 15, 2020
Purpose of this commit is to clean mail composer call in website_crm by
separating composer preparation (context, values) from customer preparation
(creating partner). Indeed most of composer code is based on records having
a partner_id correctly set, unless some templates are used that dynamically
create the partner.

In this commit we move the partner assignation on lead and its visitor outside
of the composer context computation, to better understand what is done.

LINKS

Task ID 2056759 (remove crm.partner.binding mixin)
Task ID 2088565 (crm onchange -> compute)
Community PR #43127
Enterprise PR odoo/enterprise#7322
PURPOSE

This refactoring commit removes the crm.partner.binding mixin. Indeed it
defines a mixin for unnecessary fields, generally either redefined in
inheriting models, either not used at all. It also holds an utility method
we moved directly on crm.lead model.

SPECIFICATIONS

Code move

  * move _find_matching_partner to crm.lead model;
  * move action field into inheriting models, except crm.lead.convert2ticket
    that does not use it;
  * move partner_id to inheriting models;
  * remove crm.partner.binding model and inheritance;

Improve behavior

  * correctly store lead and partner many2one fields on all inheriting
    models. It allows to support a default_lead_id instead of always
    relying on active_model / active_id, making the wizards more generic;
  * update default_get accordingly in various inheriting models in order to
    correctly compute lead / partner values;

LINKS

Task ID 2056759 (remove crm.partner.binding mixin)
Task ID 2088565 (convert onchange / default to compute)
Community PR #41955
Enterprise PR odoo/enterprise#7322
…fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based computation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

SPECIFIATIONS: CONSTRAINT USER_ID / TEAM_ID

In this commit we also remove all the better implementations of "not really a
constraint" constraint about user_id and team_id. Indeed as this is a computed
field normally we should not have to call the onchange manually, even through
a hackish call to a falsy constraint (see fdc8749, 222cca2, 4e8ebc7 ). You are
all inferior to SM team.

SPECIFIATIONS: DATE_OPEN

Assignation field, namely ``date_open``, has a random definition as it seems
linked to assignation, with several behaviors intended

  * ce39ca8 : reset only when going from
    no salesman to a salesman (aka, keep assignation when changing)
  * 8e54055: reset when changing salesman

We choose to keep first implementation as it seems a bugfix broken again
by second commit. It will also replace the ``assign_date`` defined in
``website_crm_score`` module.

LINKS

Task ID 2088565
Community PR #41955
Enterprise PR odoo/enterprise#7322

Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Florent Lejoly <fle@odoo.com>
…ored editable computed fields

PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based coputation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

In this commit we also rename ``date_assign`` to ``date_partner_assign``, because
there are already ``date_open`` (crm_lead) and ``assign_date`` (website scoring)
fields available. It may be confusing. The field is therefore renamed to better
indicate it is linked to partner assignment.

LINKS

Task ID 2088565
Community PR #41955
Enterprise PR odoo/enterprise#7322
…am model

PURPOSE

Purpose of this commit is to clean statistics fields definition on crm.team.
Future tasks will improve the use of sales team in crm and first steps is to
clean a bit models linked to sales team.

SPECIFICATIONS

New statistic fields

  * ``lead_all_assigned_month_count``: all assigned lead and opportunities
    in the last 30 days; used notably for scoring mechanism;

Renaming performed on some statistic fields

  * ``unassigned_leads_count`` -> ``lead_unassigned_count``;
  * ``overdue_opportunities_count`` -> ``opportunities_overdue_count``;
  * ``overdue_opportunities_amount`` -> ``opportunities_overdue_amount``;

All those fields are used for display and management purpose, and are
computed not stored fields. No migration is therefore required.

LINKS

Task ID 2088565
Community PR #41955
Enterprise PR odoo/enterprise#7322
PURPOSE

As crm will soon evolve (onchange -> compute, code improvements, better
management of sales teams) cleaning and improving tests is necessary to avoid
regressions.

SPECIFICATIONS

Purpose of this commit is to rewrite code located in convert wizards. Indeed
it holds unnecessary variables, dictionaries manipulation that hides the
real business flow, badly named variables, unclear methods, ...

Logic of those wizards seem quite simple but is hidden behind a wall of
bloated code.

LINKS

Task ID 2056759 (remove crm.partner.binding mixin)
Task ID 2088565 (convert onchange / default to compute)
Community PR #41955
Enterprise PR odoo/enterprise#7322
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-crm-onchange-to-compute-fle-tde branch from a7e9e45 to 3a02002 Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.