diff --git a/crm_last_dates/README.rst b/crm_last_dates/README.rst new file mode 100644 index 00000000..8b7e2106 --- /dev/null +++ b/crm_last_dates/README.rst @@ -0,0 +1,75 @@ +.. image:: https://img.shields.io/badge/license-LGPL--3-blue.svg + :target: https://opensource.org/licenses/LGPL-3.0 + :alt: License: LGPL-3 + +======================================================== +CRM Last Dates +======================================================== + +Overview +======== + +The **CRM Last Dates** module adds the last lead, meeting, and invoice dates to the `res.partner` model. This enhancement provides valuable information for sales and account management by allowing users to easily track the most recent interactions and transactions with partners. + +Features +======== + +- **Last Lead Date**: Displays the create date of the last lead associated with the partner. +- **Last Meeting Date**: Shows the date of the most recent meeting related to the partner. +- **Last Invoice Date**: Indicates the date of the latest invoice issued to the partner. + +Usage +===== + +1. **Install the Module**: + + - Install the module through the Odoo apps interface or by placing it in your Odoo addons directory. + +2. **Access Partner Records**: + + - Navigate to **Contacts** > **Partners**. + +3. **View Last Dates**: + + - Open any partner record to view the new fields under the **Sales & Purchases** tab. + +Configuration +============= + +- **User Permissions**: + + - Ensure that users have the necessary permissions to view partner records and related information. + +Testing +======= + +Test the following scenarios: + +- **Field Visibility**: + + - Verify that the `Last Lead Date`, `Last Meeting Date`, and `Last Invoice Date` fields are correctly displayed in the partner form view. + +- **Data Accuracy**: + + - Ensure that the dates reflect the correct last lead, meeting, and invoice information for various partners. + +Bug Tracker +=========== + +For bugs and issues, please visit `GitHub Issues `_ to report or track issues. + +Credits +======= + +Contributors +------------ + +* Unai Beristain + +* Ana Juaristi + +Please contact contributors for module-specific questions, but direct support requests should be made through the official channels. + +License +======= +This project is licensed under the LGPL-3 License. For more details, please refer to the LICENSE file or visit . diff --git a/crm_last_dates/__init__.py b/crm_last_dates/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/crm_last_dates/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/crm_last_dates/__manifest__.py b/crm_last_dates/__manifest__.py new file mode 100644 index 00000000..c9285541 --- /dev/null +++ b/crm_last_dates/__manifest__.py @@ -0,0 +1,12 @@ +{ + "name": "CRM Last Dates", + "version": "14.0.1.0.0", + "author": "Avanzosc", + "summary": "Add last lead, meeting, and invoice dates to res.partner.", + "website": "https://github.com/avanzosc/crm-addons", + "license": "LGPL-3", + "depends": ["crm", "calendar.event", "account "], + "data": ["views/res_partner_view.xml"], + "installable": True, + "application": False, +} diff --git a/crm_last_dates/models/__init__.py b/crm_last_dates/models/__init__.py new file mode 100644 index 00000000..91fed54d --- /dev/null +++ b/crm_last_dates/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/crm_last_dates/models/res_partner.py b/crm_last_dates/models/res_partner.py new file mode 100644 index 00000000..fe6e7417 --- /dev/null +++ b/crm_last_dates/models/res_partner.py @@ -0,0 +1,45 @@ +from odoo import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + last_lead_date = fields.Datetime( + compute="_compute_last_dates", + store=True, + ) + last_meeting_date = fields.Datetime( + compute="_compute_last_dates", + store=True, + ) + last_invoice_date = fields.Datetime( + compute="_compute_last_dates", + store=True, + ) + + @api.depends("commercial_partner_id") + def _compute_last_dates(self): + for partner in self: + lead = self.env["crm.lead"].search( + [("partner_id", "=", partner.commercial_partner_id.id)], + order="create_date desc", + limit=1, + ) + partner.last_lead_date = lead.create_date if lead else False + + meeting = self.env["calendar.event"].search( + [("partner_ids", "in", partner.commercial_partner_id.id)], + order="create_date desc", + limit=1, + ) + partner.last_meeting_date = meeting.create_date if meeting else False + + invoice = self.env["account.move"].search( + [ + ("partner_id", "=", partner.commercial_partner_id.id), + ("move_type", "=", "out_invoice"), + ], + order="invoice_date desc", + limit=1, + ) + partner.last_invoice_date = invoice.invoice_date if invoice else False diff --git a/crm_last_dates/views/res_partner_view.xml b/crm_last_dates/views/res_partner_view.xml new file mode 100644 index 00000000..d9fcfd2a --- /dev/null +++ b/crm_last_dates/views/res_partner_view.xml @@ -0,0 +1,17 @@ + + + + res.partner.form.inherit.last.dates + res.partner + + + + + + + + + + + + diff --git a/setup/crm_last_dates/odoo/addons/crm_last_dates b/setup/crm_last_dates/odoo/addons/crm_last_dates new file mode 120000 index 00000000..2c76300f --- /dev/null +++ b/setup/crm_last_dates/odoo/addons/crm_last_dates @@ -0,0 +1 @@ +../../../../crm_last_dates \ No newline at end of file diff --git a/setup/crm_last_dates/setup.py b/setup/crm_last_dates/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/crm_last_dates/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)