diff --git a/crm_multicompany_reporting_currency/README.rst b/crm_multicompany_reporting_currency/README.rst new file mode 100644 index 00000000000..610ab5c95e3 --- /dev/null +++ b/crm_multicompany_reporting_currency/README.rst @@ -0,0 +1,96 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=================================== +CRM Multicompany Reporting Currency +=================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:78bf368fdccb7c191b50fbb1ab671d9a9b703eaebdcdcf4333234269de2d92d0 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcrm-lightgray.png?logo=github + :target: https://github.com/OCA/crm/tree/19.0/crm_multicompany_reporting_currency + :alt: OCA/crm +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/crm-19-0/crm-19-0-crm_multicompany_reporting_currency + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/crm&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This Module adds Amount in multicompany reporting currency to CRM Lead +which can be used as a reporting tool. You can then compare Expected +Revenue in company currency to amount in multicompany reporting +currency. Multicompany reporting currency is installed from dependent +https://github.com/OCA/sale-reporting/tree/19.0/base_multicompany_reporting_currency +module. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Camptocamp + +Contributors +------------ + +- [Camptocamp SA](https://www.camptocamp.com): + + - Maksym Yankin + - Silvio Gregorini + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-yankinmax| image:: https://github.com/yankinmax.png?size=40px + :target: https://github.com/yankinmax + :alt: yankinmax + +Current `maintainer `__: + +|maintainer-yankinmax| + +This module is part of the `OCA/crm `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/crm_multicompany_reporting_currency/__init__.py b/crm_multicompany_reporting_currency/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/crm_multicompany_reporting_currency/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/crm_multicompany_reporting_currency/__manifest__.py b/crm_multicompany_reporting_currency/__manifest__.py new file mode 100644 index 00000000000..bbbb497e5fa --- /dev/null +++ b/crm_multicompany_reporting_currency/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2022 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "CRM Multicompany Reporting Currency", + "summary": "Adds Amount in multicompany reporting currency to CRM Lead", + "version": "19.0.1.0.0", + "category": "Sales", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + # OCA/crm + "crm_lead_company_currency_fix", + # OCA/sale-reporting + "base_multicompany_reporting_currency", + ], + "website": "https://github.com/OCA/crm", + "data": [ + # Views + "views/crm_lead.xml" + ], + "installable": True, + "maintainers": ["yankinmax"], +} diff --git a/crm_multicompany_reporting_currency/i18n/crm_multicompany_reporting_currency.pot b/crm_multicompany_reporting_currency/i18n/crm_multicompany_reporting_currency.pot new file mode 100644 index 00000000000..84c6075a6ae --- /dev/null +++ b/crm_multicompany_reporting_currency/i18n/crm_multicompany_reporting_currency.pot @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_multicompany_reporting_currency +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model.fields,field_description:crm_multicompany_reporting_currency.field_crm_lead__amount_multicompany_reporting_currency +msgid "Amount Multicompany Reporting Currency" +msgstr "" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model,name:crm_multicompany_reporting_currency.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model.fields,field_description:crm_multicompany_reporting_currency.field_crm_lead__currency_rate +msgid "Currency Rate" +msgstr "" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model,name:crm_multicompany_reporting_currency.model_crm_lead +msgid "Lead/Opportunity" +msgstr "" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model.fields,field_description:crm_multicompany_reporting_currency.field_crm_lead__multicompany_reporting_currency_id +msgid "Multicompany Reporting Currency" +msgstr "" + +#. module: crm_multicompany_reporting_currency +#: model_terms:ir.ui.view,arch_db:crm_multicompany_reporting_currency.crm_case_tree_view_oppor +msgid "Total" +msgstr "" + +#. module: crm_multicompany_reporting_currency +#: model_terms:ir.ui.view,arch_db:crm_multicompany_reporting_currency.crm_case_tree_view_oppor +#: model_terms:ir.ui.view,arch_db:crm_multicompany_reporting_currency.crm_lead_view_form +msgid "Total (Multicompany Reporting Currency)" +msgstr "" diff --git a/crm_multicompany_reporting_currency/i18n/es.po b/crm_multicompany_reporting_currency/i18n/es.po new file mode 100644 index 00000000000..7375983e0a0 --- /dev/null +++ b/crm_multicompany_reporting_currency/i18n/es.po @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_multicompany_reporting_currency +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-09-26 14:18+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model.fields,field_description:crm_multicompany_reporting_currency.field_crm_lead__amount_multicompany_reporting_currency +msgid "Amount Multicompany Reporting Currency" +msgstr "Importe Divisa de referencia multicompañía" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model,name:crm_multicompany_reporting_currency.model_res_config_settings +msgid "Config Settings" +msgstr "Configuración de Ajustes" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model.fields,field_description:crm_multicompany_reporting_currency.field_crm_lead__currency_rate +msgid "Currency Rate" +msgstr "Tipo de divisa" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model,name:crm_multicompany_reporting_currency.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Iniciativa/Oportundad" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model.fields,field_description:crm_multicompany_reporting_currency.field_crm_lead__multicompany_reporting_currency_id +msgid "Multicompany Reporting Currency" +msgstr "Divisa de referencia de varias compañías" + +#. module: crm_multicompany_reporting_currency +#: model_terms:ir.ui.view,arch_db:crm_multicompany_reporting_currency.crm_case_tree_view_oppor +msgid "Total" +msgstr "Total" + +#. module: crm_multicompany_reporting_currency +#: model_terms:ir.ui.view,arch_db:crm_multicompany_reporting_currency.crm_case_tree_view_oppor +#: model_terms:ir.ui.view,arch_db:crm_multicompany_reporting_currency.crm_lead_view_form +msgid "Total (Multicompany Reporting Currency)" +msgstr "Total (divisa de referencia de varias compañías)" diff --git a/crm_multicompany_reporting_currency/i18n/it.po b/crm_multicompany_reporting_currency/i18n/it.po new file mode 100644 index 00000000000..b57d1c29cea --- /dev/null +++ b/crm_multicompany_reporting_currency/i18n/it.po @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_multicompany_reporting_currency +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-13 12:36+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model.fields,field_description:crm_multicompany_reporting_currency.field_crm_lead__amount_multicompany_reporting_currency +msgid "Amount Multicompany Reporting Currency" +msgstr "Valuta resoconto valore multiazienda" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model,name:crm_multicompany_reporting_currency.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni configurazione" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model.fields,field_description:crm_multicompany_reporting_currency.field_crm_lead__currency_rate +msgid "Currency Rate" +msgstr "Tasso di cambio" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model,name:crm_multicompany_reporting_currency.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Contatto/Opportunità" + +#. module: crm_multicompany_reporting_currency +#: model:ir.model.fields,field_description:crm_multicompany_reporting_currency.field_crm_lead__multicompany_reporting_currency_id +msgid "Multicompany Reporting Currency" +msgstr "Valuta resoconto multi azienda" + +#. module: crm_multicompany_reporting_currency +#: model_terms:ir.ui.view,arch_db:crm_multicompany_reporting_currency.crm_case_tree_view_oppor +msgid "Total" +msgstr "Totale" + +#. module: crm_multicompany_reporting_currency +#: model_terms:ir.ui.view,arch_db:crm_multicompany_reporting_currency.crm_case_tree_view_oppor +#: model_terms:ir.ui.view,arch_db:crm_multicompany_reporting_currency.crm_lead_view_form +msgid "Total (Multicompany Reporting Currency)" +msgstr "Totale (valuta resoconto multi azienda)" diff --git a/crm_multicompany_reporting_currency/models/__init__.py b/crm_multicompany_reporting_currency/models/__init__.py new file mode 100644 index 00000000000..e66f0d6cf4e --- /dev/null +++ b/crm_multicompany_reporting_currency/models/__init__.py @@ -0,0 +1 @@ +from . import crm_lead diff --git a/crm_multicompany_reporting_currency/models/crm_lead.py b/crm_multicompany_reporting_currency/models/crm_lead.py new file mode 100644 index 00000000000..a69d55ffafc --- /dev/null +++ b/crm_multicompany_reporting_currency/models/crm_lead.py @@ -0,0 +1,40 @@ +# Copyright 2022 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo import api, fields, models + + +class CrmLead(models.Model): + _name = "crm.lead" + _inherit = ["crm.lead", "multicompany.reporting.currency.mixin"] + + amount_multicompany_reporting_currency = fields.Monetary( + currency_field="multicompany_reporting_currency_id", + compute="_compute_amount_multicompany_reporting_currency", + store=True, + ) + + @api.depends( + "create_date", + "expected_revenue", + # Dependency on ``crm_lead_company_currency_fix`` grants this field is stored + "company_currency", + # Inherited from ``multicompany.reporting.currency.mixin`` + "multicompany_reporting_currency_id", + ) + def _compute_amount_multicompany_reporting_currency(self): + for lead in self: + amount = lead.expected_revenue + from_curr = lead.company_currency + to_curr = lead.multicompany_reporting_currency_id + if from_curr != to_curr: + amount = from_curr._convert( + from_amount=amount, + to_currency=to_curr, + # Let ``res.currency._convert()`` handle company and date if empty + company=lead.company_id or None, + date=lead.create_date or None, + # Leave roundings to field's ``convert_to_[cache|column_insert]()`` + round=False, + ) + lead.amount_multicompany_reporting_currency = amount diff --git a/crm_multicompany_reporting_currency/pyproject.toml b/crm_multicompany_reporting_currency/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/crm_multicompany_reporting_currency/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/crm_multicompany_reporting_currency/readme/CONTRIBUTORS.md b/crm_multicompany_reporting_currency/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..15882e6f5c7 --- /dev/null +++ b/crm_multicompany_reporting_currency/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- \[Camptocamp SA\](): + - Maksym Yankin \<\> + - Silvio Gregorini \<\> diff --git a/crm_multicompany_reporting_currency/readme/DESCRIPTION.md b/crm_multicompany_reporting_currency/readme/DESCRIPTION.md new file mode 100644 index 00000000000..d46807ef96d --- /dev/null +++ b/crm_multicompany_reporting_currency/readme/DESCRIPTION.md @@ -0,0 +1,6 @@ +This Module adds Amount in multicompany reporting currency to CRM Lead +which can be used as a reporting tool. You can then compare Expected +Revenue in company currency to amount in multicompany reporting +currency. Multicompany reporting currency is installed from dependent + +module. diff --git a/crm_multicompany_reporting_currency/static/description/icon.png b/crm_multicompany_reporting_currency/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/crm_multicompany_reporting_currency/static/description/icon.png differ diff --git a/crm_multicompany_reporting_currency/static/description/index.html b/crm_multicompany_reporting_currency/static/description/index.html new file mode 100644 index 00000000000..7e3185bdeb4 --- /dev/null +++ b/crm_multicompany_reporting_currency/static/description/index.html @@ -0,0 +1,440 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

CRM Multicompany Reporting Currency

+ +

Beta License: AGPL-3 OCA/crm Translate me on Weblate Try me on Runboat

+

This Module adds Amount in multicompany reporting currency to CRM Lead +which can be used as a reporting tool. You can then compare Expected +Revenue in company currency to amount in multicompany reporting +currency. Multicompany reporting currency is installed from dependent +https://github.com/OCA/sale-reporting/tree/19.0/base_multicompany_reporting_currency +module.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

yankinmax

+

This module is part of the OCA/crm project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/crm_multicompany_reporting_currency/tests/__init__.py b/crm_multicompany_reporting_currency/tests/__init__.py new file mode 100644 index 00000000000..e01af85b705 --- /dev/null +++ b/crm_multicompany_reporting_currency/tests/__init__.py @@ -0,0 +1 @@ +from . import test_amount_multicompany_reporting_currency diff --git a/crm_multicompany_reporting_currency/tests/common.py b/crm_multicompany_reporting_currency/tests/common.py new file mode 100644 index 00000000000..d45989990ee --- /dev/null +++ b/crm_multicompany_reporting_currency/tests/common.py @@ -0,0 +1,37 @@ +# Copyright 2026 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +from datetime import date + +from dateutil.relativedelta import relativedelta + +from odoo.addons.base_multicompany_reporting_currency.tests.common import ( + Common as BaseMulticompanyReportingCurrencyCommon, +) +from odoo.addons.crm_lead_company_currency_fix.tests.common import ( + Common as CrmLeadCompanyCurrencyFixCommon, +) + + +class Common(BaseMulticompanyReportingCurrencyCommon, CrmLeadCompanyCurrencyFixCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + # Setup currencies rates + yesterday = date.today() - relativedelta(days=1) + cls.env["res.currency.rate"].create( + [ + { + "name": yesterday, + "rate": 0.80, # 1.00 EUR = 0.80 CHF + "currency_id": cls.currency_chf.id, + "company_id": cls.company_eur.id, + }, + { + "name": yesterday, + "rate": 1.25, # 1.00 CHF = 1.25 EUR + "currency_id": cls.currency_eur.id, + "company_id": cls.company_chf.id, + }, + ] + ) diff --git a/crm_multicompany_reporting_currency/tests/test_amount_multicompany_reporting_currency.py b/crm_multicompany_reporting_currency/tests/test_amount_multicompany_reporting_currency.py new file mode 100644 index 00000000000..f4ff9ba120c --- /dev/null +++ b/crm_multicompany_reporting_currency/tests/test_amount_multicompany_reporting_currency.py @@ -0,0 +1,174 @@ +# Copyright 2022 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +from odoo.tests.common import users + +from .common import Common + + +class TestAmountMulticompanyReportingCurrency(Common): + def test_00_crm_lead_detected_by_multicompany_reporting_currency_mixin(self): + mcrc_mixin = self.env["multicompany.reporting.currency.mixin"] + crm_lead = self.env["crm.lead"] + self.assertIn( + crm_lead, + mcrc_mixin._get_multicompany_reporting_currency_inheriting_models(), + ) + + @users("user_eur") + def test_01_leads_with_same_currencies(self): + # Set EUR as multicompany reporting currency + self._set_multicompany_reporting_currency_param(self.currency_eur.id) + + lead_vals = {"name": "Lead", "expected_revenue": 1000} + exp_vals = { + "company_id": self.company_eur.id, + "company_currency": self.currency_eur.id, + "expected_revenue": 1000.00, + "multicompany_reporting_currency_id": self.currency_eur.id, + "amount_multicompany_reporting_currency": 1000.00, + } + + # Test 3 leads: + # 1) lead created without ``company_id``: + # - user's company is assigned to the lead by default (see method + # ``crm.lead._compute_company_id()``) + # - ``company_currency`` will be computed as the company currency => EUR + # - multicompany reporting currency is EUR + # 2) lead created with ``company_id = False``: + # - no company is set, and it's not recomputed (because an explicit value has + # been used at creation) + # - ``company_currency`` will be computed as the user company currency => EUR + # - multicompany reporting currency is EUR + # 2) lead created with ``company_id = ``: + # - company is set + # - ``company_currency`` will be computed as the company currency => EUR + # - multicompany reporting currency is EUR + self.assertRecordValues( + records=self.env["crm.lead"].create( + [ + lead_vals, + dict(lead_vals, company_id=False), + dict(lead_vals, company_id=self.company_eur.id), + ] + ), + expected_values=[ + exp_vals, + dict(exp_vals, company_id=False), + exp_vals, + ], + ) + + @users("user_eur") + def test_02_leads_with_different_currencies(self): + # Set CHF as multicompany reporting currency + self._set_multicompany_reporting_currency_param(self.currency_chf.id) + + lead_vals = {"name": "Lead", "expected_revenue": 1000} + exp_vals = { + "company_id": self.company_eur.id, + "company_currency": self.currency_eur.id, + "expected_revenue": 1000.00, + "multicompany_reporting_currency_id": self.currency_chf.id, + "amount_multicompany_reporting_currency": 800.00, + } + + # Test 3 leads: + # 1) lead created without ``company_id``: + # - user's company is assigned to the lead by default (see method + # ``crm.lead._compute_company_id()``) + # - ``company_currency`` will be computed as the company currency => EUR + # - multicompany reporting currency is CHF + # 2) lead created with ``company_id = False``: + # - no company is set, and it's not recomputed (because an explicit value has + # been used at creation) + # - ``company_currency`` will be computed as the user company currency => EUR + # - multicompany reporting currency is CHF + # 2) lead created with ``company_id = ``: + # - company is set + # - ``company_currency`` will be computed as the company currency => EUR + # - multicompany reporting currency is CHF + self.assertRecordValues( + records=self.env["crm.lead"].create( + [ + lead_vals, + dict(lead_vals, company_id=False), + dict(lead_vals, company_id=self.company_eur.id), + ] + ), + expected_values=[ + exp_vals, + dict(exp_vals, company_id=False), + exp_vals, + ], + ) + + @users("user_eur") + def test_03_check_amount_when_lead_company_currency_changes(self): + # Set EUR as multicompany reporting currency + self._set_multicompany_reporting_currency_param(self.currency_eur.id) + + # Create a lead with the EUR company (inherited from the user) + lead = self.env["crm.lead"].create({"name": "Lead", "expected_revenue": 1000}) + self.assertRecordValues( + lead, + [ + { + "company_id": self.company_eur.id, + "company_currency": self.currency_eur.id, + "expected_revenue": 1000.00, + "multicompany_reporting_currency_id": self.currency_eur.id, + "amount_multicompany_reporting_currency": 1000.00, + }, + ], + ) + + # Change the lead to the CHF company + lead.company_id = self.company_chf + self.assertRecordValues( + lead, + [ + { + "company_id": self.company_chf.id, + "company_currency": self.currency_chf.id, + "expected_revenue": 1000.00, + "multicompany_reporting_currency_id": self.currency_eur.id, + "amount_multicompany_reporting_currency": 1250.00, + }, + ], + ) + + @users("user_chf") + def test_04_check_amount_when_multicompany_reporting_currency_changes(self): + # Set EUR as multicompany reporting currency + self._set_multicompany_reporting_currency_param(self.currency_eur.id) + + # Create a lead with the CHF company (inherited from the user) + lead = self.env["crm.lead"].create({"name": "Lead", "expected_revenue": 1000}) + self.assertRecordValues( + lead, + [ + { + "company_id": self.company_chf.id, + "company_currency": self.currency_chf.id, + "expected_revenue": 1000.00, + "multicompany_reporting_currency_id": self.currency_eur.id, + "amount_multicompany_reporting_currency": 1250.00, + }, + ], + ) + + # Set CHF as multicompany reporting currency + self._set_multicompany_reporting_currency_param(self.currency_chf.id) + self.assertRecordValues( + lead, + [ + { + "company_id": self.company_chf.id, + "company_currency": self.currency_chf.id, + "expected_revenue": 1000.00, + "multicompany_reporting_currency_id": self.currency_chf.id, + "amount_multicompany_reporting_currency": 1000.00, + }, + ], + ) diff --git a/crm_multicompany_reporting_currency/views/crm_lead.xml b/crm_multicompany_reporting_currency/views/crm_lead.xml new file mode 100644 index 00000000000..b74bc6cfe81 --- /dev/null +++ b/crm_multicompany_reporting_currency/views/crm_lead.xml @@ -0,0 +1,58 @@ + + + + crm.lead + + + + Expected Revenues (company currency) + + + + + + + + + + + crm.lead + + + +
+

+
+
+

+
+
+
+
diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000000..aed06df899e --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +odoo-addon-base_multicompany_reporting_currency @ git+https://github.com/OCA/sale-reporting.git@refs/pull/351/head#subdirectory=base_multicompany_reporting_currency +odoo-addon-crm_lead_company_currency_fix @ git+https://github.com/OCA/crm.git@refs/pull/722/head#subdirectory=crm_lead_company_currency_fix