Skip to content

Commit

Permalink
[ADD] crm_last_dates
Browse files Browse the repository at this point in the history
  • Loading branch information
unaiberis authored and anajuaristi committed Sep 23, 2024
1 parent d7e62a9 commit 20ad3a4
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 0 deletions.
75 changes: 75 additions & 0 deletions crm_last_dates/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/avanzosc/crm-addons/issues>`_ to report or track issues.

Credits
=======

Contributors
------------

* Unai Beristain <unaiberistain@avanzosc.es>

* Ana Juaristi <anajuaristi@avanzosc.es>

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 <https://opensource.org/licenses/LGPL-3.0>.
1 change: 1 addition & 0 deletions crm_last_dates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
12 changes: 12 additions & 0 deletions crm_last_dates/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
1 change: 1 addition & 0 deletions crm_last_dates/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_partner
45 changes: 45 additions & 0 deletions crm_last_dates/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions crm_last_dates/views/res_partner_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_res_partner_form_inherit_last_dates" model="ir.ui.view">
<field name="name">res.partner.form.inherit.last.dates</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//page[2]" position="inside">
<group string="Last Dates">
<field name="last_lead_date" />
<field name="last_meeting_date" />
<field name="last_invoice_date" />
</group>
</xpath>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions setup/crm_last_dates/odoo/addons/crm_last_dates
6 changes: 6 additions & 0 deletions setup/crm_last_dates/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 20ad3a4

Please sign in to comment.