Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions agreement_termination/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=====================
Agreement Termination
=====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3f07e0081786446c37b27ce860fc2844361c6dd79e794b9ac80b5976b5ce6175
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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%2Fagreement-lightgray.png?logo=github
:target: https://github.com/OCA/agreement/tree/19.0/agreement_termination
:alt: OCA/agreement
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/agreement-19-0/agreement-19-0-agreement_termination
: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/agreement&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds the "Term Dates" section to legal agreements, grouping
the signature/start/end dates together with the expiration and change
notice periods, the notification address and the termination tracking
dates (termination requested / terminated).

It also adds a review date to each agreement, computed as the end date
minus the expiration notice. A daily cron schedules a "review" activity
on that date, assigned to the user who last modified the agreement.

.. image:: https://raw.githubusercontent.com/OCA/agreement/19.0/agreement_termination/static/description/screenshot_form.png
:alt: Agreement Form

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/agreement/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 <https://github.com/OCA/agreement/issues/new?body=module:%20agreement_termination%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Pavlov Media
* Open Source Integrators
* Yves Goldberg (Ygol Internetwork)

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

- Pavlov Media
- Open Source Integrators
- Yves Goldberg (Ygol Internetwork)
- `glueckkanja AG <https://www.glueckkanja.com/>`__:

- Christopher Rogos

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/agreement <https://github.com/OCA/agreement/tree/19.0/agreement_termination>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions agreement_termination/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
23 changes: 23 additions & 0 deletions agreement_termination/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Agreement Termination",
"summary": "Term dates, notices, review reminders and termination tracking for "
"agreements",
"author": "Pavlov Media, "
"Open Source Integrators, "
"Yves Goldberg (Ygol Internetwork), "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/agreement",
"category": "Partner",
"license": "AGPL-3",
"version": "19.0.1.0.0",
"depends": ["agreement"],
"excludes": ["agreement_legal"],
"data": [
"data/cron.xml",
"views/agreement.xml",
],
"development_status": "Beta",
}
23 changes: 23 additions & 0 deletions agreement_termination/data/cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<!-- Activity scheduled on the review date -->
<record id="mail_activity_review_agreement" model="mail.activity.type">
<field name="name">Agreement needs a review</field>
<field name="summary">Review agreement before it ends</field>
<field name="category">default</field>
<field name="res_model">agreement</field>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
<!-- Daily check of agreements reaching their review date -->
<record model="ir.cron" forcecreate="True" id="ir_cron_alert_to_review_date">
<field name="name">Agreement: Check Review Date</field>
<field name="model_id" ref="agreement.model_agreement" />
<field name="state">code</field>
<field name="code">model._alert_to_review_date()</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="active" eval="True" />
</record>
</odoo>
3 changes: 3 additions & 0 deletions agreement_termination/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import agreement
76 changes: 76 additions & 0 deletions agreement_termination/models/agreement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import timedelta

from odoo import api, fields, models


class Agreement(models.Model):
_name = "agreement"
_inherit = ["agreement"]

expiration_notice = fields.Integer(
string="Exp. Notice (Days)",
tracking=True,
help="Number of Days before expiration to be notified.",
)
change_notice = fields.Integer(
string="Change Notice (Days)",
tracking=True,
help="Number of Days to be notified before changes.",
)
termination_requested = fields.Date(
string="Termination Requested Date",
tracking=True,
help="Date that a request for termination was received.",
)
termination_date = fields.Date(
tracking=True, help="Date that the contract was terminated."
)
notification_address_id = fields.Many2one(
"res.partner",
string="Notification Address",
help="The address to send notifications to, if different from "
"customer address.(Address Type = Other)",
)
to_review_date = fields.Date(
compute="_compute_to_review_date",
store=True,
readonly=False,
help="Date on which the last modifier is reminded to review the "
"agreement. Defaults to the end date minus the expiration notice.",
)

@api.depends("end_date", "expiration_notice")
def _compute_to_review_date(self):
for record in self:
if record.end_date:
record.to_review_date = record.end_date - timedelta(
days=record.expiration_notice
)

@api.model
def _alert_to_review_date(self):
"""Cron: schedule a review activity for agreements whose review date
is today, assigned to the user who last modified the agreement."""
activity_type = self.env.ref(
"agreement_termination.mail_activity_review_agreement"
)
agreements = self.search(
[
("to_review_date", "=", fields.Date.today()),
("is_template", "=", False),
]
)
for agreement in agreements:
if agreement.activity_ids.filtered(
lambda a: a.activity_type_id == activity_type
):
continue
reviewer = agreement.user_id or agreement.write_uid or agreement.create_uid
agreement.activity_schedule(
"agreement_termination.mail_activity_review_agreement",
user_id=reviewer.id,
note=self.env._("This agreement is going to end soon"),
)
3 changes: 3 additions & 0 deletions agreement_termination/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
5 changes: 5 additions & 0 deletions agreement_termination/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Pavlov Media
- Open Source Integrators
- Yves Goldberg (Ygol Internetwork)
- [glueckkanja AG](https://www.glueckkanja.com/):
- Christopher Rogos
10 changes: 10 additions & 0 deletions agreement_termination/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This module adds the "Term Dates" section to legal agreements, grouping the
signature/start/end dates together with the expiration and change notice
periods, the notification address and the termination tracking dates
(termination requested / terminated).

It also adds a review date to each agreement, computed as the end date minus
the expiration notice. A daily cron schedules a "review" activity on that date,
assigned to the user who last modified the agreement.

![Agreement Form](../static/description/screenshot_form.png)
Binary file added agreement_termination/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading