Skip to content

Conversation

@lade-odoo
Copy link
Contributor

In a multi-company environment, when we transform a lead (which has
no salesperson) into an opportunity, we get an error.

To reproduce the issue:

  1. Create a new company
  2. Create a Lead for a customer with the Company set
  3. Remove the Sales Team
  4. Set the company on the Lead
  5. Convert to an opportunity and you will see an error showing up

Solution:
A previous commit (1fad826) adapted the _compute_company_id
computation in which a case was forgotten (the case described here-above). The fix was to force
the company_id to the one of the partner_id if it has one.

opw-2805181

@robodoo
Copy link
Contributor

robodoo commented Apr 6, 2022

Pull request status dashboard

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Apr 6, 2022
@lade-odoo lade-odoo force-pushed the 15.0-opw-2805181-lead_2_opportunity_no_salesperson-lade branch from 872f971 to 33526d7 Compare April 13, 2022 14:20
Copy link
Contributor

@kitan191 kitan191 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, LGTM

@lade-odoo lade-odoo marked this pull request as ready for review April 14, 2022 07:18
@C3POdoo C3POdoo requested a review from a team April 14, 2022 07:19
@lade-odoo
Copy link
Contributor Author

@tde-banana-odoo Can you review this ? Thanks !

@tde-banana-odoo
Copy link
Contributor

FYI: some discussions are ongoing on task 2824913

@lade-odoo lade-odoo closed this Apr 26, 2022
@lade-odoo lade-odoo reopened this Apr 26, 2022
@lade-odoo
Copy link
Contributor Author

@tde-banana-odoo Is there any news regarding this issue ? Have you had the time to discuss it with others in the team ?

1 similar comment
@lade-odoo
Copy link
Contributor Author

@tde-banana-odoo Is there any news regarding this issue ? Have you had the time to discuss it with others in the team ?

Copy link
Contributor

@tde-banana-odoo tde-banana-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation !

proposal = lead.user_id.company_id & self.env.companies
elif lead.team_id:
proposal = lead.team_id.company_id
elif lead.partner_id and lead.partner_id.company_id:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to force a new company based on the customer's one ... shouldn't we keep it void instead ? Generally this means less issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This review contradicts your first one concerning splitting the if condition. We cannot apply both reviews, it would break the fix.
  2. I would say that it's best to avoid having a void company in most cases as there are validation upon saving the record. Plus, the way the new condition is placed enforced to avoid having unnecessary warning message upon saving.

proposal = False
# no user and no team -> void company and let assignment do its job
if not lead.team_id and not lead.user_id:
if not lead.team_id and not lead.user_id and not (lead.partner_id and proposal == lead.partner_id.company_id):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About code: would make a new entry in the "if" list to clearly explain the case, aka something like

# no user and no team -> void company and let assignment do its job
if not lead.team_id and not lead.user_id:
    proposal = False
# incompatible with partner's company
if proposal and lead.partner_id.company_id != proposal:
    proposal= False

@lade-odoo
Copy link
Contributor Author

@tde-banana-odoo Is the changes ok for you now ?

@tde-banana-odoo
Copy link
Contributor

Hello,

I still did not have time to test in details. I am unsure this fix is the right one, and for tricky process like that I would prefer taking time to review it carefully. Will try to have a look soon :)

@tde-banana-odoo tde-banana-odoo force-pushed the 15.0-opw-2805181-lead_2_opportunity_no_salesperson-lade branch from 33526d7 to beab457 Compare June 20, 2022 10:38
Currently using a customer with a company set on a lead without company
crashes, as it keep a void company on the lead. This is not compatible
with the company set on the partner itself.

OPW-2805181
Task-2888330
@tde-banana-odoo tde-banana-odoo force-pushed the 15.0-opw-2805181-lead_2_opportunity_no_salesperson-lade branch 2 times, most recently from 40d97a5 to 0807e80 Compare June 20, 2022 11:41
@tde-banana-odoo
Copy link
Contributor

Hello,

I added some tests and rebased. @tfr-odoo could you have a look and see if it is ok for you ?

Cheers !

In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330
@tde-banana-odoo tde-banana-odoo force-pushed the 15.0-opw-2805181-lead_2_opportunity_no_salesperson-lade branch from 0807e80 to 644c6e5 Compare June 20, 2022 12:14
@tfr-odoo
Copy link
Contributor

Hello,

I added some tests and rebased. @tfr-odoo could you have a look and see if it is ok for you ?

Cheers !

For odoo.com it won't make any difference since our partner have no company and check_company is False on crm.lead.

I found a bit sad to reach this level of complexity to ensure the company consistency on a object like lead where is not really needed but that's my humble opinion

Nevertheless this fix seems consistent

@tde-banana-odoo
Copy link
Contributor

@tfr-odoo I agree this should probably be simplified, company check is a bit too aggressive for lead. But in stable we have to ensure it runs smoothly :) .

@tde-banana-odoo
Copy link
Contributor

@robodoo r+ rebase-ff

@robodoo
Copy link
Contributor

robodoo commented Jun 21, 2022

Merge method set to rebase and fast-forward

@robodoo
Copy link
Contributor

robodoo commented Jun 21, 2022

Staging failed: ci/runbot (view more at https://runbot.odoo.com/runbot/build/16681036)

@tde-banana-odoo
Copy link
Contributor

@robodoo retry

fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Jun 23, 2022
Currently using a customer with a company set on a lead without company
crashes, as it keep a void company on the lead. This is not compatible
with the company set on the partner itself.

OPW-2805181
Task-2888330

Part-of: odoo#88108
X-original-commit: 51be6ca
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Jun 23, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes odoo#88108

Signed-off-by: Thibault Delavallee (tde) <[email protected]>
X-original-commit: fc3bb66
robodoo pushed a commit that referenced this pull request Jun 24, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes #88108

closes #94483

X-original-commit: fc3bb66
Signed-off-by: Thibault Delavallee (tde) <[email protected]>
robodoo pushed a commit that referenced this pull request Jun 24, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes #88108

closes #94493

X-original-commit: fc3bb66
Signed-off-by: Thibault Delavallee (tde) <[email protected]>
robodoo pushed a commit that referenced this pull request Jun 24, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes #88108

closes #94473

X-original-commit: fc3bb66
Signed-off-by: Thibault Delavallee (tde) <[email protected]>
robodoo pushed a commit that referenced this pull request Jun 24, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes #88108

closes #94462

X-original-commit: fc3bb66
Signed-off-by: Thibault Delavallee (tde) <[email protected]>
robodoo pushed a commit that referenced this pull request Jun 24, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes #88108

closes #94473

X-original-commit: fc3bb66
Signed-off-by: Thibault Delavallee (tde) <[email protected]>
@fw-bot
Copy link
Contributor

fw-bot commented Jun 25, 2022

This pull request has forward-port PRs awaiting action (not merged or closed): #94462, #94473

robodoo pushed a commit that referenced this pull request Jun 25, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes #88108

closes #94462

X-original-commit: fc3bb66
Signed-off-by: Thibault Delavallee (tde) <[email protected]>
robodoo pushed a commit that referenced this pull request Jun 25, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes #88108

closes #94473

X-original-commit: fc3bb66
Signed-off-by: Thibault Delavallee (tde) <[email protected]>
@fw-bot
Copy link
Contributor

fw-bot commented Jun 26, 2022

This pull request has forward-port PRs awaiting action (not merged or closed): #94462, #94473

1 similar comment
@fw-bot
Copy link
Contributor

fw-bot commented Jun 27, 2022

This pull request has forward-port PRs awaiting action (not merged or closed): #94462, #94473

tde-banana-odoo pushed a commit to odoo-dev/odoo that referenced this pull request Jun 27, 2022
Currently using a customer with a company set on a lead without company
crashes, as it keep a void company on the lead. This is not compatible
with the company set on the partner itself.

OPW-2805181
Task-2888330

Part-of: odoo#88108
X-original-commit: 51be6ca
tde-banana-odoo pushed a commit to odoo-dev/odoo that referenced this pull request Jun 27, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes odoo#88108

Signed-off-by: Thibault Delavallee (tde) <[email protected]>
X-original-commit: fc3bb66
tde-banana-odoo pushed a commit to odoo-dev/odoo that referenced this pull request Jun 27, 2022
Currently using a customer with a company set on a lead without company
crashes, as it keep a void company on the lead. This is not compatible
with the company set on the partner itself.

OPW-2805181
Task-2888330

Part-of: odoo#88108
X-original-commit: 51be6ca
tde-banana-odoo pushed a commit to odoo-dev/odoo that referenced this pull request Jun 27, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes odoo#88108

Signed-off-by: Thibault Delavallee (tde) <[email protected]>
X-original-commit: fc3bb66
robodoo pushed a commit that referenced this pull request Jun 27, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes #88108

closes #94473

X-original-commit: fc3bb66
Signed-off-by: Thibault Delavallee (tde) <[email protected]>
robodoo pushed a commit that referenced this pull request Jun 27, 2022
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes #88108

closes #94462

X-original-commit: fc3bb66
Signed-off-by: Thibault Delavallee (tde) <[email protected]>
@fw-bot fw-bot deleted the 15.0-opw-2805181-lead_2_opportunity_no_salesperson-lade branch July 5, 2022 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OE the report is linked to a support ticket (opw-...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants