Skip to content

Commit 20ad3a4

Browse files
unaiberisanajuaristi
authored andcommitted
[ADD] crm_last_dates
1 parent d7e62a9 commit 20ad3a4

File tree

8 files changed

+158
-0
lines changed

8 files changed

+158
-0
lines changed

crm_last_dates/README.rst

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.svg
2+
:target: https://opensource.org/licenses/LGPL-3.0
3+
:alt: License: LGPL-3
4+
5+
========================================================
6+
CRM Last Dates
7+
========================================================
8+
9+
Overview
10+
========
11+
12+
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.
13+
14+
Features
15+
========
16+
17+
- **Last Lead Date**: Displays the create date of the last lead associated with the partner.
18+
- **Last Meeting Date**: Shows the date of the most recent meeting related to the partner.
19+
- **Last Invoice Date**: Indicates the date of the latest invoice issued to the partner.
20+
21+
Usage
22+
=====
23+
24+
1. **Install the Module**:
25+
26+
- Install the module through the Odoo apps interface or by placing it in your Odoo addons directory.
27+
28+
2. **Access Partner Records**:
29+
30+
- Navigate to **Contacts** > **Partners**.
31+
32+
3. **View Last Dates**:
33+
34+
- Open any partner record to view the new fields under the **Sales & Purchases** tab.
35+
36+
Configuration
37+
=============
38+
39+
- **User Permissions**:
40+
41+
- Ensure that users have the necessary permissions to view partner records and related information.
42+
43+
Testing
44+
=======
45+
46+
Test the following scenarios:
47+
48+
- **Field Visibility**:
49+
50+
- Verify that the `Last Lead Date`, `Last Meeting Date`, and `Last Invoice Date` fields are correctly displayed in the partner form view.
51+
52+
- **Data Accuracy**:
53+
54+
- Ensure that the dates reflect the correct last lead, meeting, and invoice information for various partners.
55+
56+
Bug Tracker
57+
===========
58+
59+
For bugs and issues, please visit `GitHub Issues <https://github.com/avanzosc/crm-addons/issues>`_ to report or track issues.
60+
61+
Credits
62+
=======
63+
64+
Contributors
65+
------------
66+
67+
* Unai Beristain <unaiberistain@avanzosc.es>
68+
69+
* Ana Juaristi <anajuaristi@avanzosc.es>
70+
71+
Please contact contributors for module-specific questions, but direct support requests should be made through the official channels.
72+
73+
License
74+
=======
75+
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>.

crm_last_dates/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

crm_last_dates/__manifest__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "CRM Last Dates",
3+
"version": "14.0.1.0.0",
4+
"author": "Avanzosc",
5+
"summary": "Add last lead, meeting, and invoice dates to res.partner.",
6+
"website": "https://github.com/avanzosc/crm-addons",
7+
"license": "LGPL-3",
8+
"depends": ["crm", "calendar.event", "account "],
9+
"data": ["views/res_partner_view.xml"],
10+
"installable": True,
11+
"application": False,
12+
}

crm_last_dates/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import res_partner

crm_last_dates/models/res_partner.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from odoo import api, fields, models
2+
3+
4+
class ResPartner(models.Model):
5+
_inherit = "res.partner"
6+
7+
last_lead_date = fields.Datetime(
8+
compute="_compute_last_dates",
9+
store=True,
10+
)
11+
last_meeting_date = fields.Datetime(
12+
compute="_compute_last_dates",
13+
store=True,
14+
)
15+
last_invoice_date = fields.Datetime(
16+
compute="_compute_last_dates",
17+
store=True,
18+
)
19+
20+
@api.depends("commercial_partner_id")
21+
def _compute_last_dates(self):
22+
for partner in self:
23+
lead = self.env["crm.lead"].search(
24+
[("partner_id", "=", partner.commercial_partner_id.id)],
25+
order="create_date desc",
26+
limit=1,
27+
)
28+
partner.last_lead_date = lead.create_date if lead else False
29+
30+
meeting = self.env["calendar.event"].search(
31+
[("partner_ids", "in", partner.commercial_partner_id.id)],
32+
order="create_date desc",
33+
limit=1,
34+
)
35+
partner.last_meeting_date = meeting.create_date if meeting else False
36+
37+
invoice = self.env["account.move"].search(
38+
[
39+
("partner_id", "=", partner.commercial_partner_id.id),
40+
("move_type", "=", "out_invoice"),
41+
],
42+
order="invoice_date desc",
43+
limit=1,
44+
)
45+
partner.last_invoice_date = invoice.invoice_date if invoice else False
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="view_res_partner_form_inherit_last_dates" model="ir.ui.view">
4+
<field name="name">res.partner.form.inherit.last.dates</field>
5+
<field name="model">res.partner</field>
6+
<field name="inherit_id" ref="base.view_partner_form" />
7+
<field name="arch" type="xml">
8+
<xpath expr="//page[2]" position="inside">
9+
<group string="Last Dates">
10+
<field name="last_lead_date" />
11+
<field name="last_meeting_date" />
12+
<field name="last_invoice_date" />
13+
</group>
14+
</xpath>
15+
</field>
16+
</record>
17+
</odoo>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../crm_last_dates

setup/crm_last_dates/setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

0 commit comments

Comments
 (0)