diff --git a/crm_won_restrict_per_stage/README.rst b/crm_won_restrict_per_stage/README.rst new file mode 100644 index 000000000000..1bba2524735b --- /dev/null +++ b/crm_won_restrict_per_stage/README.rst @@ -0,0 +1,86 @@ +========================== +CRM Won Restrict Per Stage +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:504c79b322c3ce4e7481c9b95d4b10d426c8cbc26524a921e62f257c2127f432 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/15.0/crm_won_restrict_per_stage + :alt: OCA/crm +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/crm-15-0/crm-15-0-crm_won_restrict_per_stage + :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=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds possibility to set CRM stages that are being able to see won button and restrict change to an stage won that is not previous set to see won button + +**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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Carolina Fernandez + +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-carolina-fernandez| image:: https://github.com/carolina-fernandez.png?size=40px + :target: https://github.com/carolina-fernandez + :alt: carolina-fernandez + +Current `maintainer `__: + +|maintainer-carolina-fernandez| + +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_won_restrict_per_stage/__init__.py b/crm_won_restrict_per_stage/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/crm_won_restrict_per_stage/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/crm_won_restrict_per_stage/__manifest__.py b/crm_won_restrict_per_stage/__manifest__.py new file mode 100644 index 000000000000..5d59a86cc0f8 --- /dev/null +++ b/crm_won_restrict_per_stage/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2024 Tecnativa Carolina Fernandez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +{ + "name": "CRM Won Restrict Per Stage", + "version": "15.0.1.0.0", + "category": "Customer Relationship Management", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/crm", + "license": "AGPL-3", + "depends": ["crm"], + "data": ["views/crm_views.xml"], + "installable": True, + "maintainers": ["carolina-fernandez"], +} diff --git a/crm_won_restrict_per_stage/i18n/crm_won_restrict_per_stage.pot b/crm_won_restrict_per_stage/i18n/crm_won_restrict_per_stage.pot new file mode 100644 index 000000000000..27abffc5cb66 --- /dev/null +++ b/crm_won_restrict_per_stage/i18n/crm_won_restrict_per_stage.pot @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_won_restrict_per_stage +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-03-07 20:40+0000\n" +"PO-Revision-Date: 2024-03-07 20:40+0000\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_won_restrict_per_stage +#: model:ir.model,name:crm_won_restrict_per_stage.model_crm_stage +msgid "CRM Stages" +msgstr "" + +#. module: crm_won_restrict_per_stage +#: model:ir.model,name:crm_won_restrict_per_stage.model_crm_lead +msgid "Lead/Opportunity" +msgstr "" + +#. module: crm_won_restrict_per_stage +#: model:ir.model.fields,field_description:crm_won_restrict_per_stage.field_crm_lead__show_won_button +#: model:ir.model.fields,field_description:crm_won_restrict_per_stage.field_crm_stage__show_won_button +msgid "Show Won Button" +msgstr "" + +#. module: crm_won_restrict_per_stage +#: code:addons/crm_won_restrict_per_stage/models/crm_lead.py:0 +#, python-format +msgid "The stage must have checked Show won button" +msgstr "" diff --git a/crm_won_restrict_per_stage/i18n/es.po b/crm_won_restrict_per_stage/i18n/es.po new file mode 100644 index 000000000000..4e8d5fe484bd --- /dev/null +++ b/crm_won_restrict_per_stage/i18n/es.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_won_restrict_per_stage +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-03-07 20:40+0000\n" +"PO-Revision-Date: 2024-03-07 20:40+0000\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_won_restrict_per_stage +#: model:ir.model,name:crm_won_restrict_per_stage.model_crm_stage +msgid "CRM Stages" +msgstr "Etapas del CRM" + +#. module: crm_won_restrict_per_stage +#: model:ir.model,name:crm_won_restrict_per_stage.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Lead/Oportunidad" + +#. module: crm_won_restrict_per_stage +#: model:ir.model.fields,field_description:crm_won_restrict_per_stage.field_crm_lead__show_won_button +#: model:ir.model.fields,field_description:crm_won_restrict_per_stage.field_crm_stage__show_won_button +msgid "Show Won Button" +msgstr "Mostrar botón Ganado" + +#. module: crm_won_restrict_per_stage +#: code:addons/crm_won_restrict_per_stage/models/crm_lead.py:0 +#, python-format +msgid "The stage must have checked Show won button" +msgstr "La etapa tiene que tener configurada Mostrar botón Ganado" diff --git a/crm_won_restrict_per_stage/models/__init__.py b/crm_won_restrict_per_stage/models/__init__.py new file mode 100644 index 000000000000..bad3e0d449a9 --- /dev/null +++ b/crm_won_restrict_per_stage/models/__init__.py @@ -0,0 +1,2 @@ +from . import crm_stage +from . import crm_lead diff --git a/crm_won_restrict_per_stage/models/crm_lead.py b/crm_won_restrict_per_stage/models/crm_lead.py new file mode 100644 index 000000000000..6fa91262631b --- /dev/null +++ b/crm_won_restrict_per_stage/models/crm_lead.py @@ -0,0 +1,18 @@ +# Copyright 2024 Tecnativa - Carolina Fernandez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import _, fields, models +from odoo.exceptions import ValidationError + + +class CrmStage(models.Model): + _inherit = "crm.lead" + + show_won_button = fields.Boolean(related="stage_id.show_won_button") + + def write(self, vals): + if vals.get("stage_id"): + stage = self.env["crm.stage"].browse(vals.get("stage_id")) + if stage.is_won and not self.stage_id.show_won_button: + raise ValidationError(_("The stage must have checked Show won button")) + return super().write(vals) diff --git a/crm_won_restrict_per_stage/models/crm_stage.py b/crm_won_restrict_per_stage/models/crm_stage.py new file mode 100644 index 000000000000..186fb1c8bdfc --- /dev/null +++ b/crm_won_restrict_per_stage/models/crm_stage.py @@ -0,0 +1,10 @@ +# Copyright 2024 Tecnativa - Carolina Fernandez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import fields, models + + +class CrmStage(models.Model): + _inherit = "crm.stage" + + show_won_button = fields.Boolean(default=True) diff --git a/crm_won_restrict_per_stage/readme/CONTRIBUTORS.rst b/crm_won_restrict_per_stage/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..30dc7127ed93 --- /dev/null +++ b/crm_won_restrict_per_stage/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Tecnativa `_: + + * Carolina Fernandez diff --git a/crm_won_restrict_per_stage/readme/DESCRIPTION.rst b/crm_won_restrict_per_stage/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..eb5f8835e279 --- /dev/null +++ b/crm_won_restrict_per_stage/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds possibility to set CRM stages that are being able to see won button and restrict change to an stage won that is not previous set to see won button diff --git a/crm_won_restrict_per_stage/static/description/icon.png b/crm_won_restrict_per_stage/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/crm_won_restrict_per_stage/static/description/icon.png differ diff --git a/crm_won_restrict_per_stage/static/description/index.html b/crm_won_restrict_per_stage/static/description/index.html new file mode 100644 index 000000000000..52b991e71cc0 --- /dev/null +++ b/crm_won_restrict_per_stage/static/description/index.html @@ -0,0 +1,429 @@ + + + + + + +CRM Won Restrict Per Stage + + + +
+

CRM Won Restrict Per Stage

+ + +

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

+

This module adds possibility to set CRM stages that are being able to see won button and restrict change to an stage won that is not previous set to see won button

+

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

+
    +
  • Tecnativa
  • +
+
+
+

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:

+

carolina-fernandez

+

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_won_restrict_per_stage/tests/__init__.py b/crm_won_restrict_per_stage/tests/__init__.py new file mode 100644 index 000000000000..abce0675a0f0 --- /dev/null +++ b/crm_won_restrict_per_stage/tests/__init__.py @@ -0,0 +1 @@ +from . import test_crm_lead diff --git a/crm_won_restrict_per_stage/tests/test_crm_lead.py b/crm_won_restrict_per_stage/tests/test_crm_lead.py new file mode 100644 index 000000000000..85b9e3e0f565 --- /dev/null +++ b/crm_won_restrict_per_stage/tests/test_crm_lead.py @@ -0,0 +1,24 @@ +# Copyright 2024 Tecnativa - Carolina Fernandez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo.exceptions import ValidationError +from odoo.tests.common import TransactionCase + + +class TestCrmStage(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.crm_lead = cls.env["crm.lead"].create({"name": "Test Lead"}) + cls.stage_new = cls.env.ref("crm.stage_lead1") + cls.stage_won = cls.env.ref("crm.stage_lead4") + + def test_change_crm_stage_won_without_show_button(self): + self.stage_new.show_won_button = False + with self.assertRaises(ValidationError): + self.crm_lead.stage_id = self.stage_won + + def test_change_crm_stage_to_won_with_show_button(self): + self.stage_new.show_won_button = True + self.crm_lead.stage_id = self.stage_won + self.assertEqual(self.crm_lead.stage_id, self.stage_won) diff --git a/crm_won_restrict_per_stage/views/crm_views.xml b/crm_won_restrict_per_stage/views/crm_views.xml new file mode 100644 index 000000000000..b9dde9a4c80a --- /dev/null +++ b/crm_won_restrict_per_stage/views/crm_views.xml @@ -0,0 +1,28 @@ + + + + crm.stage.form.inherit + crm.stage + + + + + + + + + crm.lead.form.inherit + crm.lead + + + + + + + + + diff --git a/setup/crm_won_restrict_per_stage/odoo/addons/crm_won_restrict_per_stage b/setup/crm_won_restrict_per_stage/odoo/addons/crm_won_restrict_per_stage new file mode 120000 index 000000000000..ebc2503a1165 --- /dev/null +++ b/setup/crm_won_restrict_per_stage/odoo/addons/crm_won_restrict_per_stage @@ -0,0 +1 @@ +../../../../crm_won_restrict_per_stage \ No newline at end of file diff --git a/setup/crm_won_restrict_per_stage/setup.py b/setup/crm_won_restrict_per_stage/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/crm_won_restrict_per_stage/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)