Skip to content

[19.0][ADD] crm_lead_company_currency_fix: new module#722

Open
SilvioC2C wants to merge 2 commits into
OCA:19.0from
camptocamp:19.0-add-crm_lead_company_currency_fix
Open

[19.0][ADD] crm_lead_company_currency_fix: new module#722
SilvioC2C wants to merge 2 commits into
OCA:19.0from
camptocamp:19.0-add-crm_lead_company_currency_fix

Conversation

@SilvioC2C
Copy link
Copy Markdown
Contributor

@SilvioC2C SilvioC2C commented Jan 14, 2026

In Odoo standard source code, leads' currency is defined as a computed, non-stored field, which follows this workflow:

  • if the lead's company is set, then the company currency is used
  • if the lead's company is not set, then the user's company currency is used

Since the field is not stored, it leads to 2 main issues:

  1. Changing a company's currency will change the currency on all the existing leads linked to that company, but not the amounts. Eg:

    • you have a lead linked to a company in EUR
    • the lead's expected revenue is 1000 EUR
    • you change the company currency to USD
    • the lead's expected revenue becomes 1000 USD
  2. If a lead is not linked to a specific company, then 2 users that are logged in with 2 different companies and different currencies will see the lead's amounts with different currencies. Eg:

    • you have a lead where the company is not set
    • accessing the lead with a user whose main company is in EUR will display an expected revenue of 1000 EUR
    • accessing the lead with a user whose main company is in USD will display an expected revenue of 1000 USD

This module stores the field in the DB to keep data consistency, and will only update the lead's currency only if the lead's company itself is updated. The behavior for computing the lead's currency will remain the same (currency is retrieved from the lead's company or the current user's company), but the issues are fixed:

  1. Changing a company's currency will not change the currency on existing leads, only on the ones created after the currency has been updated. Eg:

    • you have a lead linked to a company in EUR
    • the lead's expected revenue is 1000 EUR
    • you change the company currency to USD
    • the lead's expected revenue is still 1000 EUR
    • a newly created lead's expected revenue will be in USD, not EUR
  2. If a lead is not linked to a specific company, then 2 users that are logged in with 2 different companies and different currencies will see the lead's amounts with the same currency (computed from the company of the first user that triggers the recomputation). Eg:

    • you have a lead where the company is not set
    • accessing the lead with a 1st user whose main company is in EUR will display an expected revenue of 1000 EUR
    • accessing the lead with a 2nd user whose main company is in USD will display an expected revenue of 1000 EUR, because the currency was set from the previous user's company

@SilvioC2C SilvioC2C force-pushed the 19.0-add-crm_lead_company_currency_fix branch 2 times, most recently from 92d306f to 4910c2a Compare January 15, 2026 11:47
@SilvioC2C SilvioC2C force-pushed the 19.0-add-crm_lead_company_currency_fix branch from 4910c2a to c9683fb Compare January 15, 2026 11:47
Copy link
Copy Markdown

@yankinmax yankinmax left a comment

Choose a reason for hiding this comment

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

Thanks for the deep analysis.
This probably needs to be backported to older versions.

@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

1 similar comment
@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Copy Markdown

@luisDIXMIT luisDIXMIT left a comment

Choose a reason for hiding this comment

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

Code review and LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants