diff --git a/crm_proposal_due_date/README.rst b/crm_proposal_due_date/README.rst new file mode 100644 index 00000000000..16febaaef56 --- /dev/null +++ b/crm_proposal_due_date/README.rst @@ -0,0 +1,97 @@ +===================== +CRM Proposal Due Date +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e4f8d992995dbb6fc626f546a69e38a83fbfc0c108851156018579a7aec8a2d6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcrm-lightgray.png?logo=github + :target: https://github.com/OCA/crm/tree/16.0/crm_proposal_due_date + :alt: OCA/crm +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/crm-16-0/crm-16-0-crm_proposal_due_date + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the CRM *Opportunity* form with an **Expected +Proposal Submission Date** field (``proposal_due_date``). + +Whenever this date is set or changed on an opportunity, an activity of +type *"Remettre la proposition"* is automatically scheduled with the +same deadline, giving the responsible salesperson a visible reminder in +their activity feed. If the date is cleared the corresponding activity +is automatically removed. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +1. Open an opportunity in the CRM pipeline. +2. Fill in the **Expected Proposal Submission Date** field. +3. Save the record — a *"Submit Proposal"* activity is automatically + created in the chatter. Its deadline can be adjusted independently. +4. Clearing the date removes the activity. + +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 +------- + +* Ctrl-a + +Contributors +------------ + +- Simon Maillard simon@ogesta.fr + +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. + +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_proposal_due_date/__init__.py b/crm_proposal_due_date/__init__.py new file mode 100644 index 00000000000..5eb2c5135c7 --- /dev/null +++ b/crm_proposal_due_date/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2026 Ctrl-a +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from . import models diff --git a/crm_proposal_due_date/__manifest__.py b/crm_proposal_due_date/__manifest__.py new file mode 100644 index 00000000000..fbf1c403774 --- /dev/null +++ b/crm_proposal_due_date/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2026 Ctrl-a +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +{ + "name": "CRM Proposal Due Date", + "summary": "Track proposal submission date and auto-schedule a dedicated activity", + "version": "16.0.1.0.0", + "development_status": "Alpha", + "category": "Sales/CRM", + "website": "https://github.com/OCA/crm", + "author": "Ctrl-a, Odoo Community Association (OCA)", + "license": "LGPL-3", + "application": False, + "installable": True, + "depends": [ + "crm", + ], + "data": [ + "data/mail_activity_type.xml", + "views/crm_lead_view.xml", + ], +} diff --git a/crm_proposal_due_date/data/mail_activity_type.xml b/crm_proposal_due_date/data/mail_activity_type.xml new file mode 100644 index 00000000000..f523e8c915a --- /dev/null +++ b/crm_proposal_due_date/data/mail_activity_type.xml @@ -0,0 +1,10 @@ + + + + + Submit Proposal + fa-file-text-o + crm.lead + + diff --git a/crm_proposal_due_date/i18n/crm_proposal_due_date.pot b/crm_proposal_due_date/i18n/crm_proposal_due_date.pot new file mode 100644 index 00000000000..cbe880f7786 --- /dev/null +++ b/crm_proposal_due_date/i18n/crm_proposal_due_date.pot @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_proposal_due_date +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_proposal_due_date +#: model:ir.model.fields,field_description:crm_proposal_due_date.field_crm_lead__proposal_due_date +msgid "Expected Proposal Submission Date" +msgstr "" + +#. module: crm_proposal_due_date +#: model:ir.model,name:crm_proposal_due_date.model_crm_lead +msgid "Lead/Opportunity" +msgstr "" + +#. module: crm_proposal_due_date +#. odoo-python +#: code:addons/crm_proposal_due_date/models/crm_lead.py:0 +#: model:mail.activity.type,name:crm_proposal_due_date.mail_activity_type_proposal +#, python-format +msgid "Submit Proposal" +msgstr "" diff --git a/crm_proposal_due_date/i18n/fr.po b/crm_proposal_due_date/i18n/fr.po new file mode 100644 index 00000000000..db11938f656 --- /dev/null +++ b/crm_proposal_due_date/i18n/fr.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_proposal_due_date +# +# Translators: +# Simon Maillard , 2026 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Simon Maillard \n" +"Language-Team: French \n" +"Language: fr\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" + +#. module: crm_proposal_due_date +#: model:ir.model.fields,field_description:crm_proposal_due_date.field_crm_lead__proposal_due_date +msgid "Expected Proposal Submission Date" +msgstr "Date prévue de remise de la proposition" + +#. module: crm_proposal_due_date +#: model:ir.model,name:crm_proposal_due_date.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Piste/Opportunité" + +#. module: crm_proposal_due_date +#. odoo-python +#: code:addons/crm_proposal_due_date/models/crm_lead.py:0 +#: model:mail.activity.type,name:crm_proposal_due_date.mail_activity_type_proposal +#, python-format +msgid "Submit Proposal" +msgstr "Remettre la proposition" diff --git a/crm_proposal_due_date/models/__init__.py b/crm_proposal_due_date/models/__init__.py new file mode 100644 index 00000000000..5f4f2251921 --- /dev/null +++ b/crm_proposal_due_date/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2026 Ctrl-a +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from . import crm_lead diff --git a/crm_proposal_due_date/models/crm_lead.py b/crm_proposal_due_date/models/crm_lead.py new file mode 100644 index 00000000000..0b93a83add7 --- /dev/null +++ b/crm_proposal_due_date/models/crm_lead.py @@ -0,0 +1,75 @@ +# Copyright 2026 Ctrl-a +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from odoo import _, api, fields, models + +_ACTIVITY_XMLID = "crm_proposal_due_date.mail_activity_type_proposal" + + +class CrmLead(models.Model): + _inherit = "crm.lead" + + proposal_due_date = fields.Date( + string="Expected Proposal Submission Date", + tracking=True, + index=True, + ) + + # ------------------------------------------------------------------ + # CRUD + # ------------------------------------------------------------------ + + @api.model_create_multi + def create(self, vals_list): + records = super().create(vals_list) + for record in records: + if record.proposal_due_date: + record._sync_proposal_activity() + return records + + def write(self, vals): + if "proposal_due_date" not in vals: + return super().write(vals) + # Track which records already had a date before writing + already_set_ids = set(self.filtered("proposal_due_date").ids) + res = super().write(vals) + for record in self: + record._sync_proposal_activity(was_already_set=record.id in already_set_ids) + return res + + # ------------------------------------------------------------------ + # Helpers + # ------------------------------------------------------------------ + + def _sync_proposal_activity(self, was_already_set=False): + """Create or remove the 'Submit Proposal' activity. + + The activity deadline is managed independently by the user and is + never overwritten when ``proposal_due_date`` changes. + + - First time ``proposal_due_date`` is set: schedule a new activity. + - ``proposal_due_date`` changed (was already set): leave the existing + activity untouched. + - ``proposal_due_date`` cleared: remove any automated activity of this + type. + """ + self.ensure_one() + activity_type = self.env.ref(_ACTIVITY_XMLID, raise_if_not_found=False) + if not activity_type: + return + + existing = self.activity_ids.filtered( + lambda a: a.activity_type_id == activity_type and a.automated + ) + + if not self.proposal_due_date: + existing.unlink() + return + + if not existing and not was_already_set: + # Only schedule when the date is set for the first time + self.activity_schedule( + act_type_xmlid=_ACTIVITY_XMLID, + date_deadline=self.proposal_due_date, + summary=_("Submit Proposal"), + ) diff --git a/crm_proposal_due_date/readme/CONTRIBUTORS.md b/crm_proposal_due_date/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..f2c9b49168f --- /dev/null +++ b/crm_proposal_due_date/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Simon Maillard diff --git a/crm_proposal_due_date/readme/DESCRIPTION.md b/crm_proposal_due_date/readme/DESCRIPTION.md new file mode 100644 index 00000000000..74123fba072 --- /dev/null +++ b/crm_proposal_due_date/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +This module extends the CRM *Opportunity* form with an **Expected Proposal +Submission Date** field (``proposal_due_date``). + +Whenever this date is set or changed on an opportunity, an activity of type +*"Remettre la proposition"* is automatically scheduled with the same deadline, +giving the responsible salesperson a visible reminder in their activity feed. +If the date is cleared the corresponding activity is automatically removed. diff --git a/crm_proposal_due_date/readme/USAGE.md b/crm_proposal_due_date/readme/USAGE.md new file mode 100644 index 00000000000..d80e1b22b10 --- /dev/null +++ b/crm_proposal_due_date/readme/USAGE.md @@ -0,0 +1,5 @@ +1. Open an opportunity in the CRM pipeline. +2. Fill in the **Expected Proposal Submission Date** field. +3. Save the record — a *"Submit Proposal"* activity is automatically + created in the chatter. Its deadline can be adjusted independently. +4. Clearing the date removes the activity. diff --git a/crm_proposal_due_date/static/description/index.html b/crm_proposal_due_date/static/description/index.html new file mode 100644 index 00000000000..d77db4b7a34 --- /dev/null +++ b/crm_proposal_due_date/static/description/index.html @@ -0,0 +1,446 @@ + + + + + +CRM Proposal Due Date + + + +
+

CRM Proposal Due Date

+ + +

Alpha License: LGPL-3 OCA/crm Translate me on Weblate Try me on Runboat

+

This module extends the CRM Opportunity form with an Expected +Proposal Submission Date field (proposal_due_date).

+

Whenever this date is set or changed on an opportunity, an activity of +type “Remettre la proposition” is automatically scheduled with the +same deadline, giving the responsible salesperson a visible reminder in +their activity feed. If the date is cleared the corresponding activity +is automatically removed.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Usage

+
    +
  1. Open an opportunity in the CRM pipeline.
  2. +
  3. Fill in the Expected Proposal Submission Date field.
  4. +
  5. Save the record — a “Submit Proposal” activity is automatically +created in the chatter. Its deadline can be adjusted independently.
  6. +
  7. Clearing the date removes the activity.
  8. +
+
+
+

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

+
    +
  • Ctrl-a
  • +
+
+
+

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.

+

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_proposal_due_date/tests/__init__.py b/crm_proposal_due_date/tests/__init__.py new file mode 100644 index 00000000000..b53173ac938 --- /dev/null +++ b/crm_proposal_due_date/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2026 Ctrl-a +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from . import test_crm_proposal_due_date diff --git a/crm_proposal_due_date/tests/test_crm_proposal_due_date.py b/crm_proposal_due_date/tests/test_crm_proposal_due_date.py new file mode 100644 index 00000000000..b284ef7fab7 --- /dev/null +++ b/crm_proposal_due_date/tests/test_crm_proposal_due_date.py @@ -0,0 +1,74 @@ +# Copyright 2026 Ctrl-a +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from datetime import date, timedelta + +from odoo.tests.common import TransactionCase + + +class TestCrmProposalDueDate(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.activity_type = cls.env.ref( + "crm_proposal_due_date.mail_activity_type_proposal" + ) + cls.lead = cls.env["crm.lead"].create( + { + "name": "Test Lead", + "type": "opportunity", + } + ) + + def _get_proposal_activities(self, lead): + return lead.activity_ids.filtered( + lambda a: a.activity_type_id == self.activity_type and a.automated + ) + + def test_no_activity_without_due_date(self): + """No proposal activity should exist when proposal_due_date is not set.""" + self.assertFalse(self.lead.proposal_due_date) + self.assertFalse(self._get_proposal_activities(self.lead)) + + def test_activity_created_on_date_set(self): + """Setting proposal_due_date for the first time schedules a proposal activity.""" + due = date.today() + timedelta(days=7) + self.lead.write({"proposal_due_date": due}) + activities = self._get_proposal_activities(self.lead) + self.assertEqual(len(activities), 1) + + def test_activity_created_on_create_with_date(self): + """Creating a lead with proposal_due_date immediately schedules the activity.""" + due = date.today() + timedelta(days=14) + lead = self.env["crm.lead"].create( + { + "name": "Lead with due date", + "type": "opportunity", + "proposal_due_date": due, + } + ) + activities = self._get_proposal_activities(lead) + self.assertEqual(len(activities), 1) + + def test_no_duplicate_activity_on_date_change(self): + """Changing proposal_due_date does not create a second activity.""" + due1 = date.today() + timedelta(days=7) + due2 = date.today() + timedelta(days=14) + self.lead.write({"proposal_due_date": due1}) + self.lead.write({"proposal_due_date": due2}) + activities = self._get_proposal_activities(self.lead) + self.assertEqual(len(activities), 1) + + def test_activity_removed_on_date_cleared(self): + """Clearing proposal_due_date removes the proposal activity.""" + due = date.today() + timedelta(days=7) + self.lead.write({"proposal_due_date": due}) + self.assertTrue(self._get_proposal_activities(self.lead)) + self.lead.write({"proposal_due_date": False}) + self.assertFalse(self._get_proposal_activities(self.lead)) + + def test_no_activity_for_write_without_date_change(self): + """Writing unrelated fields does not create a spurious activity.""" + initial_count = len(self.lead.activity_ids) + self.lead.write({"name": "Updated Lead Name"}) + self.assertEqual(len(self.lead.activity_ids), initial_count) diff --git a/crm_proposal_due_date/views/crm_lead_view.xml b/crm_proposal_due_date/views/crm_lead_view.xml new file mode 100644 index 00000000000..395a7a1a2d8 --- /dev/null +++ b/crm_proposal_due_date/views/crm_lead_view.xml @@ -0,0 +1,46 @@ + + + + + + crm.lead.view.form.inherit.proposal.due.date + crm.lead + + + + + + + + + + + crm.lead.tree.opportunity.inherit.proposal.due.date + crm.lead + + + + + + + + + + + crm.lead.search.opportunity.inherit.proposal.due.date + crm.lead + + + + + + + + diff --git a/setup/crm_proposal_due_date/odoo/addons/crm_proposal_due_date b/setup/crm_proposal_due_date/odoo/addons/crm_proposal_due_date new file mode 120000 index 00000000000..9dd8264b2c7 --- /dev/null +++ b/setup/crm_proposal_due_date/odoo/addons/crm_proposal_due_date @@ -0,0 +1 @@ +../../../../crm_proposal_due_date \ No newline at end of file diff --git a/setup/crm_proposal_due_date/setup.py b/setup/crm_proposal_due_date/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/crm_proposal_due_date/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)