diff --git a/crm_lead_currency/README.rst b/crm_lead_currency/README.rst new file mode 100644 index 00000000000..97cab61ad31 --- /dev/null +++ b/crm_lead_currency/README.rst @@ -0,0 +1,114 @@ +================= +CRM Lead Currency +================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9bf41df2f27035661a45d16c182ca683c50c7ba630cbbd2ad588da573a67a86a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-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/18.0/crm_lead_currency + :alt: OCA/crm +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/crm-18-0/crm-18-0-crm_lead_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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to select a specific currency for a lead or an +opportunity. If the selected currency is different to the company +currency, an amount in the customer currency can be set and the expected +revenue of the opportunity will automatically be computed in the company +currency. The default rate used for the computation is the rate of the +day. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +Just install the module. + +Configuration +============= + +No specific configuration is needed but multi-currency should be enabled +for the module to make sense. + +Usage +===== + +To use this module, you need to: + +1. Created a new opportunity in the CRM and set a customer currency on + it. + +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 SA +* Vauxoo + +Contributors +------------ + +- Thierry Ducrest +- `APSL-Nagarro `__: + + - Bernat Obrador + +- ``Heliconia Solutions Pvt. Ltd. ``\ \_ + +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-luisg123v| image:: https://github.com/luisg123v.png?size=40px + :target: https://github.com/luisg123v + :alt: luisg123v + +Current `maintainer `__: + +|maintainer-luisg123v| + +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_lead_currency/__init__.py b/crm_lead_currency/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/crm_lead_currency/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/crm_lead_currency/__manifest__.py b/crm_lead_currency/__manifest__.py new file mode 100644 index 00000000000..d191e308552 --- /dev/null +++ b/crm_lead_currency/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2019 Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "CRM Lead Currency", + "summary": """ + On leads/opportunities, add the amount in the customer's currency.""", + "maintainers": [ + "luisg123v", + ], + "version": "18.0.1.0.0", + "license": "AGPL-3", + "author": "Camptocamp SA,Odoo Community Association (OCA),Vauxoo", + "website": "https://github.com/OCA/crm", + "depends": [ + "crm", + ], + "data": [ + "views/crm_lead_views.xml", + ], + "installable": True, +} diff --git a/crm_lead_currency/i18n/crm_lead_currency.pot b/crm_lead_currency/i18n/crm_lead_currency.pot new file mode 100644 index 00000000000..e784672daa6 --- /dev/null +++ b/crm_lead_currency/i18n/crm_lead_currency.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_lead_currency +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_lead_currency +#: model:ir.model.fields,field_description:crm_lead_currency.field_crm_lead__amount_customer_currency +msgid "Customer amount" +msgstr "" + +#. module: crm_lead_currency +#: model:ir.model.fields,field_description:crm_lead_currency.field_crm_lead__customer_currency_id +msgid "Customer currency" +msgstr "" + +#. module: crm_lead_currency +#: model:ir.model,name:crm_lead_currency.model_crm_lead +msgid "Lead/Opportunity" +msgstr "" + +#. module: crm_lead_currency +#: model:ir.model.fields,field_description:crm_lead_currency.field_crm_lead__is_same_currency +msgid "Same currency" +msgstr "" diff --git a/crm_lead_currency/i18n/es.po b/crm_lead_currency/i18n/es.po new file mode 100644 index 00000000000..8cdb7166049 --- /dev/null +++ b/crm_lead_currency/i18n/es.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_lead_currency +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-06-20 18:02+0000\n" +"PO-Revision-Date: 2023-06-20 18:02+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: crm_lead_currency +#: model:ir.model.fields,field_description:crm_lead_currency.field_crm_lead__amount_customer_currency +msgid "Customer amount" +msgstr "Monto cliente" + +#. module: crm_lead_currency +#: model:ir.model.fields,field_description:crm_lead_currency.field_crm_lead__customer_currency_id +msgid "Customer currency" +msgstr "Moneda cliente" + +#. module: crm_lead_currency +#: model:ir.model,name:crm_lead_currency.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Iniciativa/Oportunidad" + +#. module: crm_lead_currency +#: model:ir.model.fields,field_description:crm_lead_currency.field_crm_lead__is_same_currency +msgid "Same currency" +msgstr "Misma moneda" diff --git a/crm_lead_currency/i18n/it.po b/crm_lead_currency/i18n/it.po new file mode 100644 index 00000000000..58f16866ba8 --- /dev/null +++ b/crm_lead_currency/i18n/it.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_lead_currency +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-14 15:08+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_lead_currency +#: model:ir.model.fields,field_description:crm_lead_currency.field_crm_lead__amount_customer_currency +msgid "Customer amount" +msgstr "Valore cliente" + +#. module: crm_lead_currency +#: model:ir.model.fields,field_description:crm_lead_currency.field_crm_lead__customer_currency_id +msgid "Customer currency" +msgstr "Valuta cliente" + +#. module: crm_lead_currency +#: model:ir.model,name:crm_lead_currency.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Contatto/Opportunità" + +#. module: crm_lead_currency +#: model:ir.model.fields,field_description:crm_lead_currency.field_crm_lead__is_same_currency +msgid "Same currency" +msgstr "Stessa valuta" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/crm_lead_currency/models/__init__.py b/crm_lead_currency/models/__init__.py new file mode 100644 index 00000000000..e66f0d6cf4e --- /dev/null +++ b/crm_lead_currency/models/__init__.py @@ -0,0 +1 @@ +from . import crm_lead diff --git a/crm_lead_currency/models/crm_lead.py b/crm_lead_currency/models/crm_lead.py new file mode 100644 index 00000000000..36c4331d9d5 --- /dev/null +++ b/crm_lead_currency/models/crm_lead.py @@ -0,0 +1,49 @@ +# Copyright 2018 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): + _inherit = "crm.lead" + + customer_currency_id = fields.Many2one( + string="Customer currency", + comodel_name="res.currency", + default=lambda self: self.env.company.currency_id, + ) + amount_customer_currency = fields.Monetary( + string="Customer amount", + currency_field="customer_currency_id", + ) + is_same_currency = fields.Boolean( + string="Same currency", + compute="_compute_is_same_currency", + ) + + @api.onchange("customer_currency_id", "amount_customer_currency") + def _onchange_currency(self): + self.expected_revenue = self.get_revenue_in_company_currency() + + def get_revenue_in_company_currency(self): + """Compute the expected revenue in the company currency. + + If the customer currency is different than the company currency, + the expected revenue is computed in the company currency. + """ + self.ensure_one() + if self.is_same_currency: + return self.expected_revenue + return self.customer_currency_id._convert( + self.amount_customer_currency or 0, + self.company_currency, + self.env.company, + fields.Datetime.now(), + ) + + @api.depends("customer_currency_id", "company_currency") + def _compute_is_same_currency(self): + for lead in self: + lead.is_same_currency = lead.customer_currency_id == ( + lead.company_currency or self.env.company.currency_id + ) diff --git a/crm_lead_currency/pyproject.toml b/crm_lead_currency/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/crm_lead_currency/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/crm_lead_currency/readme/CONFIGURE.md b/crm_lead_currency/readme/CONFIGURE.md new file mode 100644 index 00000000000..2634129665e --- /dev/null +++ b/crm_lead_currency/readme/CONFIGURE.md @@ -0,0 +1,2 @@ +No specific configuration is needed but multi-currency should be enabled +for the module to make sense. diff --git a/crm_lead_currency/readme/CONTRIBUTORS.md b/crm_lead_currency/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..640df50231a --- /dev/null +++ b/crm_lead_currency/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Thierry Ducrest \<\> +- [APSL-Nagarro](): + - Bernat Obrador \<\> +- `Heliconia Solutions Pvt. Ltd. `_ diff --git a/crm_lead_currency/readme/DESCRIPTION.md b/crm_lead_currency/readme/DESCRIPTION.md new file mode 100644 index 00000000000..eaedbb31130 --- /dev/null +++ b/crm_lead_currency/readme/DESCRIPTION.md @@ -0,0 +1,6 @@ +This module allows to select a specific currency for a lead or an +opportunity. If the selected currency is different to the company +currency, an amount in the customer currency can be set and the expected +revenue of the opportunity will automatically be computed in the company +currency. The default rate used for the computation is the rate of the +day. diff --git a/crm_lead_currency/readme/INSTALL.md b/crm_lead_currency/readme/INSTALL.md new file mode 100644 index 00000000000..4129bc4b1df --- /dev/null +++ b/crm_lead_currency/readme/INSTALL.md @@ -0,0 +1 @@ +Just install the module. diff --git a/crm_lead_currency/readme/USAGE.md b/crm_lead_currency/readme/USAGE.md new file mode 100644 index 00000000000..c0e69bc8b42 --- /dev/null +++ b/crm_lead_currency/readme/USAGE.md @@ -0,0 +1,4 @@ +To use this module, you need to: + +1. Created a new opportunity in the CRM and set a customer currency on + it. diff --git a/crm_lead_currency/static/description/icon.png b/crm_lead_currency/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/crm_lead_currency/static/description/icon.png differ diff --git a/crm_lead_currency/static/description/index.html b/crm_lead_currency/static/description/index.html new file mode 100644 index 00000000000..bbe7c802f1b --- /dev/null +++ b/crm_lead_currency/static/description/index.html @@ -0,0 +1,456 @@ + + + + + +CRM Lead Currency + + + +
+

CRM Lead Currency

+ + +

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

+

This module allows to select a specific currency for a lead or an +opportunity. If the selected currency is different to the company +currency, an amount in the customer currency can be set and the expected +revenue of the opportunity will automatically be computed in the company +currency. The default rate used for the computation is the rate of the +day.

+

Table of contents

+ +
+

Installation

+

Just install the module.

+
+
+

Configuration

+

No specific configuration is needed but multi-currency should be enabled +for the module to make sense.

+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Created a new opportunity in the CRM and set a customer currency on +it.
  2. +
+
+
+

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 SA
  • +
  • Vauxoo
  • +
+
+
+

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:

+

luisg123v

+

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_lead_currency/tests/__init__.py b/crm_lead_currency/tests/__init__.py new file mode 100644 index 00000000000..3fd2987073f --- /dev/null +++ b/crm_lead_currency/tests/__init__.py @@ -0,0 +1 @@ +from . import test_crm_opportunity_currency diff --git a/crm_lead_currency/tests/test_crm_opportunity_currency.py b/crm_lead_currency/tests/test_crm_opportunity_currency.py new file mode 100644 index 00000000000..5809c999b68 --- /dev/null +++ b/crm_lead_currency/tests/test_crm_opportunity_currency.py @@ -0,0 +1,31 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo.tests import TransactionCase + + +class TestCrmOpportunityCurrency(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.lead = cls.env["crm.lead"].create({"name": "test lead"}) + + def test_is_same_currency(self): + self.lead.customer_currency_id = self.lead.company_currency + self.assertTrue(self.lead.is_same_currency) + self.lead.customer_currency_id = self.env.ref("base.CHF") + self.assertFalse(self.lead.is_same_currency) + + def test_same_currency_expected_revenue_not_updated(self): + self.lead.customer_currency_id = self.lead.company_currency + self.lead.expected_revenue = 100 + self.lead.amount_customer_currency = 124 + self.lead._onchange_currency() + self.assertEqual(self.lead.expected_revenue, 100) + + def test_different_currency_expected_revenue_updated(self): + self.lead.expected_revenue = 100 + self.lead.customer_currency_id = self.env.ref("base.CHF") + self.lead.amount_customer_currency = 124 + self.lead._onchange_currency() + self.assertNotEqual(self.lead.expected_revenue, 100) diff --git a/crm_lead_currency/views/crm_lead_views.xml b/crm_lead_currency/views/crm_lead_views.xml new file mode 100644 index 00000000000..b1d222d537d --- /dev/null +++ b/crm_lead_currency/views/crm_lead_views.xml @@ -0,0 +1,56 @@ + + + + crm.lead.form + crm.lead + + + + + + + + + not is_same_currency + 1 + + + + + + + crm.lead.kanban.lead + crm.lead + + 99 + + + + + + + + + + + + + + + + +